mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-02 10:25:26 +02:00
Allow AppHelper to read FrameworkDirPath from argv
This commit is contained in:
parent
4bbf59fbb3
commit
06bcf00dd7
@ -21,7 +21,7 @@ begin
|
|||||||
// The main process and the subprocess *MUST* have the same GlobalCEFApp
|
// The main process and the subprocess *MUST* have the same GlobalCEFApp
|
||||||
// properties and events, specially FrameworkDirPath, ResourcesDirPath,
|
// properties and events, specially FrameworkDirPath, ResourcesDirPath,
|
||||||
// LocalesDirPath, cache and UserDataPath paths.
|
// LocalesDirPath, cache and UserDataPath paths.
|
||||||
|
GlobalCEFApp.InitLibLocationFromArgs;
|
||||||
|
|
||||||
GlobalCEFApp.StartSubProcess;
|
GlobalCEFApp.StartSubProcess;
|
||||||
GlobalCEFApp.Free;
|
GlobalCEFApp.Free;
|
||||||
|
@ -90,6 +90,11 @@ const
|
|||||||
CHROMEELF_DLL = '';
|
CHROMEELF_DLL = '';
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
// for InitLibLocationFromArgs
|
||||||
|
LIBCEF_PAK = 'cef.pak';
|
||||||
|
LIBCEF_LOCALE_DIR = 'locales';
|
||||||
|
LIBCEF_LOCALE_ENUS = 'en-US.pak';
|
||||||
|
|
||||||
type
|
type
|
||||||
TCefApplicationCore = class
|
TCefApplicationCore = class
|
||||||
protected
|
protected
|
||||||
@ -359,6 +364,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure AfterConstruction; override;
|
procedure AfterConstruction; override;
|
||||||
procedure AddCustomCommandLine(const aCommandLine : string; const aValue : string = '');
|
procedure AddCustomCommandLine(const aCommandLine : string; const aValue : string = '');
|
||||||
|
procedure InitLibLocationFromArgs;
|
||||||
function StartMainProcess : boolean;
|
function StartMainProcess : boolean;
|
||||||
function StartSubProcess : boolean;
|
function StartSubProcess : boolean;
|
||||||
|
|
||||||
@ -859,6 +865,57 @@ begin
|
|||||||
if (FCustomCommandLineValues <> nil) then FCustomCommandLineValues.Add(aValue);
|
if (FCustomCommandLineValues <> nil) then FCustomCommandLineValues.Add(aValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// This function checks if argv contains
|
||||||
|
// --framework-dir-path=
|
||||||
|
// --main-bundle-path=
|
||||||
|
// It sets the corresponding fields in the config
|
||||||
|
// This params are passed on Mac.
|
||||||
|
// The values can also be calculated, instead of calling this procedure
|
||||||
|
var
|
||||||
|
PARAM_FRAME_PATH : string = '--framework-dir-path';
|
||||||
|
PARAM_BUNDLE_PATH : string = '--main-bundle-path';
|
||||||
|
procedure TCefApplicationCore.InitLibLocationFromArgs;
|
||||||
|
var
|
||||||
|
i, l : Integer;
|
||||||
|
p : PChar;
|
||||||
|
MBPath : ustring;
|
||||||
|
begin
|
||||||
|
for i := 0 to argc - 1 do
|
||||||
|
begin
|
||||||
|
p := strscan(argv[i], '=');
|
||||||
|
if p = nil then continue;
|
||||||
|
l := p - argv[i];
|
||||||
|
if (l = Length(PARAM_FRAME_PATH)) and
|
||||||
|
(strlcomp(argv[i], PChar(PARAM_FRAME_PATH), Length(PARAM_FRAME_PATH)) = 0) then
|
||||||
|
begin
|
||||||
|
FrameworkDirPath := PChar(argv[i] + Length(PARAM_FRAME_PATH) + 1);
|
||||||
|
end;
|
||||||
|
if (l = Length(PARAM_BUNDLE_PATH)) and
|
||||||
|
(strlcomp(argv[i], PChar(PARAM_BUNDLE_PATH), Length(PARAM_BUNDLE_PATH)) = 0) then
|
||||||
|
begin
|
||||||
|
MBPath := PChar(argv[i] + Length(PARAM_BUNDLE_PATH) + 1);
|
||||||
|
MainBundlePath := MBPath;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if (MBPath <> '') and (FrameworkDirPath = '') then
|
||||||
|
begin
|
||||||
|
MBPath := IncludeTrailingPathDelimiter(MBPath);
|
||||||
|
{$IFDEF MACOSX}
|
||||||
|
MBPath := MBPath + LIBCEF_PREFIX;
|
||||||
|
{$ENDIF}
|
||||||
|
if FileExists(MBPath + LIBCEF_DLL) then begin
|
||||||
|
FrameworkDirPath := MBPath;
|
||||||
|
if FileExists(MBPath + LIBCEF_PAK) then begin
|
||||||
|
ResourcesDirPath := MBPath;
|
||||||
|
{$IFNDEF MACOSX}
|
||||||
|
if FileExists(IncludeTrailingPathDelimiter(MBPath + LIBCEF_LOCALE_DIR) + LIBCEF_LOCALE_ENUS) then
|
||||||
|
LocalesDirPath := MBPath + LIBCEF_LOCALE_DIR;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// This function must only be called by the main executable when the application
|
// This function must only be called by the main executable when the application
|
||||||
// is configured to use a different executable for the subprocesses.
|
// is configured to use a different executable for the subprocesses.
|
||||||
// The process calling ths function must be the browser process.
|
// The process calling ths function must be the browser process.
|
||||||
@ -1583,7 +1640,8 @@ begin
|
|||||||
FOnScheduleMessagePumpWork(delayMs);
|
FOnScheduleMessagePumpWork(delayMs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCefApplicationCore.Internal_GetLocalizedString(stringid: Integer; var stringVal: ustring) : boolean;
|
function TCefApplicationCore.Internal_GetLocalizedString(stringId: Integer;
|
||||||
|
var stringVal: ustring): boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
@ -1744,7 +1802,8 @@ begin
|
|||||||
FOnGetPDFPaperSize(deviceUnitsPerInch, aResult);
|
FOnGetPDFPaperSize(deviceUnitsPerInch, aResult);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCefApplicationCore.AppendSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring);
|
procedure TCefApplicationCore.AppendSwitch(var aKeys, aValues: TStringList;
|
||||||
|
const aNewKey: ustring; const aNewValue: ustring);
|
||||||
var
|
var
|
||||||
TempKey, TempHyphenatedKey : ustring;
|
TempKey, TempHyphenatedKey : ustring;
|
||||||
i : integer;
|
i : integer;
|
||||||
@ -1848,7 +1907,8 @@ begin
|
|||||||
FreeAndNil(TempDisabledValues);
|
FreeAndNil(TempDisabledValues);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCefApplicationCore.ReplaceSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring);
|
procedure TCefApplicationCore.ReplaceSwitch(var aKeys, aValues: TStringList;
|
||||||
|
const aNewKey: ustring; const aNewValue: ustring);
|
||||||
var
|
var
|
||||||
TempKey, TempHyphenatedKey : ustring;
|
TempKey, TempHyphenatedKey : ustring;
|
||||||
i : integer;
|
i : integer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user