mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-15 15:55:56 +01:00
Fixed crash with relative paths that have ".."
Fixed compilation bug in Delphi 7
This commit is contained in:
parent
5e5b775608
commit
09685f56e1
@ -211,7 +211,7 @@ end;
|
||||
|
||||
procedure TJSWindowBindingWithArrayBufferFrm.BrowserCreatedMsg(var aMessage : TMessage);
|
||||
begin
|
||||
Caption := 'JSWindowBindingWithObject';
|
||||
Caption := 'JSWindowBindingWithArrayBuffer';
|
||||
CEFWindowParent1.UpdateSize;
|
||||
NavControlPnl.Enabled := True;
|
||||
GoBtn.Click;
|
||||
|
@ -22,8 +22,8 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="127"/>
|
||||
<CursorPos X="81" Y="141"/>
|
||||
<TopLine Value="184"/>
|
||||
<CursorPos X="45" Y="216"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
|
@ -213,7 +213,7 @@ end;
|
||||
|
||||
procedure TJSWindowBindingWithArrayBufferFrm.BrowserCreatedMsg(var aMessage : TMessage);
|
||||
begin
|
||||
Caption := 'JSWindowBindingWithObject';
|
||||
Caption := 'JSWindowBindingWithArrayBuffer';
|
||||
CEFWindowParent1.UpdateSize;
|
||||
NavControlPnl.Enabled := True;
|
||||
GoBtn.Click;
|
||||
|
@ -23,7 +23,7 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="116"/>
|
||||
<CursorPos X="77" Y="125"/>
|
||||
<CursorPos X="41" Y="129"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
|
@ -822,76 +822,28 @@ end;
|
||||
|
||||
procedure TCefApplication.SetCache(const aValue : ustring);
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
FCache := GetModulePath + aValue
|
||||
else
|
||||
FCache := aValue;
|
||||
end
|
||||
else
|
||||
FCache := '';
|
||||
|
||||
FCache := CustomAbsolutePath(aValue);
|
||||
FDisableGPUCache := (length(FCache) = 0);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.SetRootCache(const aValue : ustring);
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
FRootCache := GetModulePath + aValue
|
||||
else
|
||||
FRootCache := aValue;
|
||||
end
|
||||
else
|
||||
FRootCache := '';
|
||||
FRootCache := CustomAbsolutePath(aValue);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.SetUserDataPath(const aValue : ustring);
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
FUserDataPath := GetModulePath + aValue
|
||||
else
|
||||
FUserDataPath := aValue;
|
||||
end
|
||||
else
|
||||
FUserDataPath := '';
|
||||
FUserDataPath := CustomAbsolutePath(aValue);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.SetBrowserSubprocessPath(const aValue : ustring);
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
FBrowserSubprocessPath := GetModulePath + aValue
|
||||
else
|
||||
FBrowserSubprocessPath := aValue;
|
||||
end
|
||||
else
|
||||
FBrowserSubprocessPath := '';
|
||||
FBrowserSubprocessPath := CustomAbsolutePath(aValue);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.SetFrameworkDirPath(const aValue : ustring);
|
||||
var
|
||||
TempPath : string;
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
TempPath := GetModulePath + aValue
|
||||
else
|
||||
TempPath := aValue;
|
||||
|
||||
if DirectoryExists(TempPath) then
|
||||
FFrameworkDirPath := TempPath
|
||||
else
|
||||
FFrameworkDirPath := '';
|
||||
end
|
||||
else
|
||||
FFrameworkDirPath := '';
|
||||
FFrameworkDirPath := CustomAbsolutePath(aValue, True);
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
if (FProcessType = ptBrowser) then GetDLLVersion(ChromeElfPath, FChromeVersionInfo);
|
||||
@ -899,43 +851,13 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCefApplication.SetResourcesDirPath(const aValue : ustring);
|
||||
var
|
||||
TempPath : string;
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
TempPath := GetModulePath + aValue
|
||||
else
|
||||
TempPath := aValue;
|
||||
|
||||
if DirectoryExists(TempPath) then
|
||||
FResourcesDirPath := TempPath
|
||||
else
|
||||
FResourcesDirPath := '';
|
||||
end
|
||||
else
|
||||
FResourcesDirPath := '';
|
||||
FResourcesDirPath := CustomAbsolutePath(aValue, True);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.SetLocalesDirPath(const aValue : ustring);
|
||||
var
|
||||
TempPath : string;
|
||||
begin
|
||||
if (length(aValue) > 0) then
|
||||
begin
|
||||
if CustomPathIsRelative(aValue) then
|
||||
TempPath := GetModulePath + aValue
|
||||
else
|
||||
TempPath := aValue;
|
||||
|
||||
if DirectoryExists(TempPath) then
|
||||
FLocalesDirPath := TempPath
|
||||
else
|
||||
FLocalesDirPath := '';
|
||||
end
|
||||
else
|
||||
FLocalesDirPath := '';
|
||||
FLocalesDirPath := CustomAbsolutePath(aValue, True);
|
||||
end;
|
||||
|
||||
function TCefApplication.CheckCEFLibrary : boolean;
|
||||
|
@ -163,7 +163,7 @@ constructor TCefCustomCompletionCallback.Create(const aEvents : IChromiumEvents)
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := aEvents;
|
||||
FEvents := Pointer(aEvents);
|
||||
end;
|
||||
|
||||
destructor TCefCustomCompletionCallback.Destroy;
|
||||
|
@ -123,10 +123,11 @@ procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCe
|
||||
function ProcessUnderWow64(hProcess: THandle; var Wow64Process: BOOL): BOOL; external Kernel32DLL name 'IsWow64Process';
|
||||
function TzSpecificLocalTimeToSystemTime(lpTimeZoneInformation: PTimeZoneInformation; lpLocalTime, lpUniversalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL;
|
||||
function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: PTimeZoneInformation; lpUniversalTime, lpLocalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL;
|
||||
|
||||
function PathIsRelativeAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeA';
|
||||
function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeW';
|
||||
function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx';
|
||||
function PathCanonicalizeAnsi(pszBuf: LPSTR; pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeA';
|
||||
function PathCanonicalizeUnicode(pszBuf: LPWSTR; pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeW';
|
||||
|
||||
{$IFNDEF DELPHI12_UP}
|
||||
{$IFDEF WIN64}
|
||||
@ -139,6 +140,8 @@ function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall;
|
||||
{$ENDIF}
|
||||
|
||||
function CustomPathIsRelative(const aPath : string) : boolean;
|
||||
function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean;
|
||||
function CustomAbsolutePath(const aPath : string; aMustExist : boolean = False) : string;
|
||||
function GetModulePath : string;
|
||||
|
||||
function CefIsCertStatusError(Status : TCefCertStatus) : boolean;
|
||||
@ -879,14 +882,8 @@ begin
|
||||
|
||||
if (length(aSrcPath) > 0) then
|
||||
begin
|
||||
aRsltPath := IncludeTrailingPathDelimiter(aSrcPath);
|
||||
|
||||
if DirectoryExists(aSrcPath) then
|
||||
begin
|
||||
if CustomPathIsRelative(aRsltPath) then aRsltPath := GetModulePath + aRsltPath;
|
||||
end
|
||||
else
|
||||
Result := False;
|
||||
aRsltPath := IncludeTrailingPathDelimiter(CustomAbsolutePath(aSrcPath));
|
||||
Result := DirectoryExists(aRsltPath);
|
||||
end
|
||||
else
|
||||
aRsltPath := '';
|
||||
@ -1422,6 +1419,50 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean;
|
||||
var
|
||||
TempBuffer: array [0..pred(MAX_PATH)] of Char;
|
||||
begin
|
||||
Result := False;
|
||||
aCanonicalPath := '';
|
||||
|
||||
FillChar(TempBuffer, MAX_PATH * SizeOf(Char), 0);
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
{$IFDEF DELPHI12_UP}
|
||||
if PathCanonicalizeUnicode(@TempBuffer[0], PChar(aOriginalPath)) then
|
||||
begin
|
||||
aCanonicalPath := TempBuffer;
|
||||
Result := True;
|
||||
end;
|
||||
{$ELSE}
|
||||
if PathCanonicalizeAnsi(@TempBuffer[0], PChar(aOriginalPath)) then
|
||||
begin
|
||||
aCanonicalPath := TempBuffer;
|
||||
Result := True;
|
||||
end;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function CustomAbsolutePath(const aPath : string; aMustExist : boolean) : string;
|
||||
var
|
||||
TempPath : string;
|
||||
begin
|
||||
if (length(aPath) > 0) then
|
||||
begin
|
||||
if not(CustomPathIsRelative(aPath) and CustomPathCanonicalize(GetModulePath + aPath, TempPath)) then
|
||||
TempPath := aPath;
|
||||
|
||||
if aMustExist and not(DirectoryExists(TempPath)) then
|
||||
Result := ''
|
||||
else
|
||||
Result := TempPath;
|
||||
end
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function GetModulePath : string;
|
||||
begin
|
||||
Result := IncludeTrailingPathDelimiter(ExtractFileDir(GetModuleName(HINSTANCE{$IFDEF FPC}(){$ENDIF})));
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 30,
|
||||
"InternalVersion" : 31,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "76.1.13.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user