mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-16 00:05:55 +01:00
Merge pull request #341 from User4martin/fpc-mac-2
Thank you so much Martin! :-D
This commit is contained in:
commit
a1f3e133ed
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
@ -10,7 +10,7 @@
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="cef_subprocess"/>
|
||||
<Title Value="AppHelper"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
@ -40,7 +40,7 @@
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="cef_subprocess.lpr"/>
|
||||
<Filename Value="AppHelper.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
@ -49,7 +49,7 @@
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="cef_subprocess"/>
|
||||
<Filename Value="..\..\..\bin\AppHelper"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
@ -1,4 +1,4 @@
|
||||
program cef_subprocess;
|
||||
program AppHelper;
|
||||
|
||||
(*
|
||||
* The compiled exe should be copied into
|
||||
@ -21,9 +21,8 @@ begin
|
||||
// The main process and the subprocess *MUST* have the same GlobalCEFApp
|
||||
// properties and events, specially FrameworkDirPath, ResourcesDirPath,
|
||||
// LocalesDirPath, cache and UserDataPath paths.
|
||||
GlobalCEFApp.InitLibLocationFromArgs;
|
||||
|
||||
|
||||
GlobalCEFApp.MultiThreadedMessageLoop:=false;
|
||||
GlobalCEFApp.StartSubProcess;
|
||||
GlobalCEFApp.Free;
|
||||
GlobalCEFApp := nil;
|
57
demos/Lazarus_Mac/AppHelper/create_mac_helper_apps.sh
Executable file
57
demos/Lazarus_Mac/AppHelper/create_mac_helper_apps.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
DEST=$1
|
||||
SRC=$2
|
||||
|
||||
if [ "$SRC" = "" ];
|
||||
then
|
||||
SRC=$BASEDIR/../../../bin/AppHelper.app
|
||||
fi
|
||||
|
||||
if [ "$1" = "" ] || [ ! -e "$DEST" ] || [ ! -e "$SRC" ];
|
||||
then
|
||||
echo "Usage"
|
||||
echo " $0 destpath/project.app"
|
||||
echo " $0 destpath/project.app sourcedir/AppHelper.app"
|
||||
echo
|
||||
if [ ! -e "$DEST" ];
|
||||
then
|
||||
echo "Error: Target app bundle not found. (Did you compile AND create the bundle?)"
|
||||
fi
|
||||
if [ ! -e "$SRC" ];
|
||||
then
|
||||
echo "Error: Source (AppHelper) app bundle not found. (Did you compile AND create the bundle?)"
|
||||
fi
|
||||
exit;
|
||||
fi
|
||||
|
||||
SRCAPP=$(basename "$SRC")
|
||||
SRCAPP="${SRCAPP%\.app}"
|
||||
DESTAPP=$(basename "$DEST")
|
||||
DESTAPP="${DESTAPP%\.app}"
|
||||
|
||||
SUB=""
|
||||
rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
|
||||
sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
|
||||
|
||||
SUB=" (GPU)"
|
||||
rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
|
||||
sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
|
||||
|
||||
SUB=" (Renderer)"
|
||||
rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
|
||||
sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
|
||||
|
||||
SUB=" (Plugin)"
|
||||
rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
|
||||
mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
|
||||
sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
|
||||
|
8
demos/Lazarus_Mac/SimpleBrowser2/create_mac_helper.sh
Executable file
8
demos/Lazarus_Mac/SimpleBrowser2/create_mac_helper.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
CDIR=$(pwd)
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
../AppHelper/create_mac_helper_apps.sh ../../../bin/SimpleBrowser2.app
|
||||
|
||||
cd "$CDIR"
|
@ -90,6 +90,11 @@ const
|
||||
CHROMEELF_DLL = '';
|
||||
{$ENDIF}
|
||||
|
||||
// for InitLibLocationFromArgs
|
||||
LIBCEF_PAK = 'cef.pak';
|
||||
LIBCEF_LOCALE_DIR = 'locales';
|
||||
LIBCEF_LOCALE_ENUS = 'en-US.pak';
|
||||
|
||||
type
|
||||
TCefApplicationCore = class
|
||||
protected
|
||||
@ -265,6 +270,8 @@ type
|
||||
function GetLibCefVersion : ustring;
|
||||
function GetLibCefPath : ustring;
|
||||
function GetChromeElfPath : ustring;
|
||||
function GetLocalesDirPath: ustring;
|
||||
function GetResourcesDirPath: ustring;
|
||||
function GetMustCreateResourceBundleHandler : boolean; virtual;
|
||||
function GetMustCreateBrowserProcessHandler : boolean; virtual;
|
||||
function GetMustCreateRenderProcessHandler : boolean; virtual;
|
||||
@ -359,6 +366,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure AfterConstruction; override;
|
||||
procedure AddCustomCommandLine(const aCommandLine : string; const aValue : string = '');
|
||||
procedure InitLibLocationFromArgs;
|
||||
function StartMainProcess : boolean;
|
||||
function StartSubProcess : boolean;
|
||||
|
||||
@ -421,8 +429,8 @@ type
|
||||
property LogFile : ustring read FLogFile write FLogFile;
|
||||
property LogSeverity : TCefLogSeverity read FLogSeverity write FLogSeverity;
|
||||
property JavaScriptFlags : ustring read FJavaScriptFlags write FJavaScriptFlags;
|
||||
property ResourcesDirPath : ustring read FResourcesDirPath write SetResourcesDirPath;
|
||||
property LocalesDirPath : ustring read FLocalesDirPath write SetLocalesDirPath;
|
||||
property ResourcesDirPath : ustring read GetResourcesDirPath write SetResourcesDirPath;
|
||||
property LocalesDirPath : ustring read GetLocalesDirPath write SetLocalesDirPath;
|
||||
property PackLoadingDisabled : Boolean read FPackLoadingDisabled write FPackLoadingDisabled;
|
||||
property RemoteDebuggingPort : Integer read FRemoteDebuggingPort write FRemoteDebuggingPort;
|
||||
property UncaughtExceptionStackSize : Integer read FUncaughtExceptionStackSize write FUncaughtExceptionStackSize;
|
||||
@ -859,6 +867,50 @@ begin
|
||||
if (FCustomCommandLineValues <> nil) then FCustomCommandLineValues.Add(aValue);
|
||||
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;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// This function must only be called by the main executable when the application
|
||||
// is configured to use a different executable for the subprocesses.
|
||||
// The process calling ths function must be the browser process.
|
||||
@ -968,6 +1020,28 @@ begin
|
||||
Result := CHROMEELF_DLL;
|
||||
end;
|
||||
|
||||
function TCefApplicationCore.GetLocalesDirPath: ustring;
|
||||
begin
|
||||
Result := FLocalesDirPath;
|
||||
{$IFNDEF MACOSX}
|
||||
if (Result = '') and (FrameworkDirPath <> '') then
|
||||
begin
|
||||
if FileExists(IncludeTrailingPathDelimiter(FrameworkDirPath + LIBCEF_LOCALE_DIR) + LIBCEF_LOCALE_ENUS) then
|
||||
Result := FrameworkDirPath + LIBCEF_LOCALE_DIR;
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TCefApplicationCore.GetResourcesDirPath: ustring;
|
||||
begin
|
||||
Result := FResourcesDirPath;
|
||||
if (Result = '') and (FrameworkDirPath <> '') then
|
||||
begin
|
||||
if FileExists(IncludeTrailingPathDelimiter(FrameworkDirPath) + LIBCEF_PAK) then
|
||||
Result := FrameworkDirPath;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefApplicationCore.SetCache(const aValue : ustring);
|
||||
begin
|
||||
FCache := CustomAbsolutePath(aValue);
|
||||
@ -1583,7 +1657,8 @@ begin
|
||||
FOnScheduleMessagePumpWork(delayMs);
|
||||
end;
|
||||
|
||||
function TCefApplicationCore.Internal_GetLocalizedString(stringid: Integer; var stringVal: ustring) : boolean;
|
||||
function TCefApplicationCore.Internal_GetLocalizedString(stringId: Integer;
|
||||
var stringVal: ustring): boolean;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
@ -1744,7 +1819,8 @@ begin
|
||||
FOnGetPDFPaperSize(deviceUnitsPerInch, aResult);
|
||||
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
|
||||
TempKey, TempHyphenatedKey : ustring;
|
||||
i : integer;
|
||||
@ -1848,7 +1924,8 @@ begin
|
||||
FreeAndNil(TempDisabledValues);
|
||||
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
|
||||
TempKey, TempHyphenatedKey : ustring;
|
||||
i : integer;
|
||||
|
@ -871,14 +871,15 @@ begin
|
||||
end;
|
||||
|
||||
function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean;
|
||||
var
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempHandle : TCefWindowHandle;
|
||||
TempDC : HDC;
|
||||
TempDPI : UINT;
|
||||
{$ELSE}
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF FPC}
|
||||
var
|
||||
TempForm : TCustomForm;
|
||||
TempMonitor : TMonitor;
|
||||
{$ENDIF}
|
||||
|
@ -2334,7 +2334,7 @@ end;
|
||||
|
||||
function ValidCefWindowHandle(aHandle : TCefWindowHandle) : boolean;
|
||||
begin
|
||||
{$IFDEF MACOSX}
|
||||
{$IFDEF MACOS}
|
||||
Result := (aHandle <> nil);
|
||||
{$ELSE}
|
||||
Result := (aHandle <> 0);
|
||||
@ -2343,7 +2343,7 @@ end;
|
||||
|
||||
procedure InitializeWindowHandle(var aHandle : TCefWindowHandle);
|
||||
begin
|
||||
{$IFDEF MACOSX}
|
||||
{$IFDEF MACOS}
|
||||
aHandle := nil;
|
||||
{$ELSE}
|
||||
aHandle := 0;
|
||||
|
Loading…
Reference in New Issue
Block a user