mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-15 07:45:56 +01:00
Enable Chrome runtime in MobileBrowser demo
This commit is contained in:
parent
16f76f39aa
commit
496db82294
@ -8,30 +8,20 @@ uses
|
||||
{$ELSE}
|
||||
Forms,
|
||||
{$ENDIF }
|
||||
uCEFApplication, uCEFConstants,
|
||||
uCEFApplication,
|
||||
uMobileBrowser in 'uMobileBrowser.pas' {Form1};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
{$IFDEF WIN32}
|
||||
const
|
||||
IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020;
|
||||
|
||||
// CEF needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$IFDEF WIN32}{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}{$ENDIF}
|
||||
// CEF needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
|
||||
// In case you want to use custom directories for the CEF3 binaries, cache and user data.
|
||||
// If you don't set a cache directory the browser will use in-memory cache.
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'c:\cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'c:\cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'c:\cef\locales';
|
||||
GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration
|
||||
GlobalCEFApp.cache := 'c:\cef\cache';
|
||||
GlobalCEFApp.UserDataPath := 'c:\cef\User Data';
|
||||
}
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
// You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause
|
||||
// with the Application initialization inside the begin..end.
|
||||
@ -46,6 +36,5 @@ begin
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
GlobalCEFApp.Free;
|
||||
GlobalCEFApp := nil;
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
||||
|
@ -97,6 +97,8 @@ type
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
@ -122,6 +124,19 @@ const
|
||||
DEVTOOLS_CLEARDEVICEMETRICSOVERRIDE_MSGID = 4;
|
||||
DEVTOOLS_SETDEVICEMETRICSOVERRIDE_MSGID = 5;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.cache := 'cache';
|
||||
GlobalCEFApp.EnablePrintPreview := True;
|
||||
GlobalCEFApp.EnableGPU := True;
|
||||
GlobalCEFApp.ChromeRuntime := True;
|
||||
{$IFDEF DEBUG}
|
||||
GlobalCEFApp.LogFile := 'debug.log';
|
||||
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
CanClose := FCanClose;
|
||||
@ -131,6 +146,10 @@ begin
|
||||
FClosing := True;
|
||||
Visible := False;
|
||||
Chromium1.CloseBrowser(True);
|
||||
|
||||
// Workaround for the missing TChormium.OnClose event when "Chrome runtime" is enabled.
|
||||
if GlobalCEFApp.ChromeRuntime then
|
||||
CEFWindowParent1.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user