You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-11-23 21:34:53 +02:00
GlobalCEFApp initialization changes
Added a custom BrowserProcessHandler to GlobalCEFApp to know when the global context is initialized and it's allowed to set the custom cookies directory and to create browsers.
This commit is contained in:
@@ -52,7 +52,7 @@ uses
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows, Classes,
|
Windows, Classes,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar;
|
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar, uCEFBrowserProcessHandler;
|
||||||
|
|
||||||
const
|
const
|
||||||
CEF_SUPPORTED_VERSION_MAJOR = 3;
|
CEF_SUPPORTED_VERSION_MAJOR = 3;
|
||||||
@@ -125,6 +125,7 @@ type
|
|||||||
FUpdateChromeVer : boolean;
|
FUpdateChromeVer : boolean;
|
||||||
FShowMessageDlg : boolean;
|
FShowMessageDlg : boolean;
|
||||||
FSetCurrentDir : boolean;
|
FSetCurrentDir : boolean;
|
||||||
|
FGlobalContextInitialized : boolean;
|
||||||
FChromeVersionInfo : TFileVersionInfo;
|
FChromeVersionInfo : TFileVersionInfo;
|
||||||
FLibHandle : THandle;
|
FLibHandle : THandle;
|
||||||
FOnRegisterCustomSchemes : TOnRegisterCustomSchemes;
|
FOnRegisterCustomSchemes : TOnRegisterCustomSchemes;
|
||||||
@@ -135,6 +136,12 @@ type
|
|||||||
FDeviceScaleFactor : single;
|
FDeviceScaleFactor : single;
|
||||||
FCheckDevToolsResources : boolean;
|
FCheckDevToolsResources : boolean;
|
||||||
|
|
||||||
|
// ICefBrowserProcessHandler
|
||||||
|
FOnContextInitializedEvent : TOnContextInitializedEvent;
|
||||||
|
FOnBeforeChildProcessLaunchEvent : TOnBeforeChildProcessLaunchEvent;
|
||||||
|
FOnRenderProcessThreadCreatedEvent : TOnRenderProcessThreadCreatedEvent;
|
||||||
|
FOnScheduleMessagePumpWorkEvent : TOnScheduleMessagePumpWorkEvent;
|
||||||
|
|
||||||
procedure SetFrameworkDirPath(const aValue : ustring);
|
procedure SetFrameworkDirPath(const aValue : ustring);
|
||||||
procedure SetResourcesDirPath(const aValue : ustring);
|
procedure SetResourcesDirPath(const aValue : ustring);
|
||||||
procedure SetLocalesDirPath(const aValue : ustring);
|
procedure SetLocalesDirPath(const aValue : ustring);
|
||||||
@@ -206,74 +213,82 @@ type
|
|||||||
function StartSubProcess : boolean;
|
function StartSubProcess : boolean;
|
||||||
procedure UpdateDeviceScaleFactor;
|
procedure UpdateDeviceScaleFactor;
|
||||||
|
|
||||||
// Internal procedures. Only TInternalApp should use them.
|
// Internal procedures. Only TInternalApp and TCefCustomBrowserProcessHandler should use them.
|
||||||
procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine);
|
||||||
procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef);
|
||||||
procedure Internal_OnGetResourceBundleHandler(var aCefResourceBundleHandler : ICefResourceBundleHandler);
|
procedure Internal_OnGetResourceBundleHandler(var aCefResourceBundleHandler : ICefResourceBundleHandler);
|
||||||
procedure Internal_OnGetBrowserProcessHandler(var aCefBrowserProcessHandler : ICefBrowserProcessHandler);
|
procedure Internal_OnGetBrowserProcessHandler(var aCefBrowserProcessHandler : ICefBrowserProcessHandler);
|
||||||
procedure Internal_OnGetRenderProcessHandler(var aCefRenderProcessHandler : ICefRenderProcessHandler);
|
procedure Internal_OnGetRenderProcessHandler(var aCefRenderProcessHandler : ICefRenderProcessHandler);
|
||||||
|
procedure Internal_OnContextInitialized;
|
||||||
|
procedure Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||||
|
procedure Internal_OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||||
|
procedure Internal_OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||||
|
|
||||||
property Cache : ustring read FCache write FCache;
|
property Cache : ustring read FCache write FCache;
|
||||||
property Cookies : ustring read FCookies write FCookies;
|
property Cookies : ustring read FCookies write FCookies;
|
||||||
property UserDataPath : ustring read FUserDataPath write FUserDataPath;
|
property UserDataPath : ustring read FUserDataPath write FUserDataPath;
|
||||||
property UserAgent : ustring read FUserAgent write FUserAgent;
|
property UserAgent : ustring read FUserAgent write FUserAgent;
|
||||||
property ProductVersion : ustring read FProductVersion write FProductVersion;
|
property ProductVersion : ustring read FProductVersion write FProductVersion;
|
||||||
property Locale : ustring read FLocale write FLocale;
|
property Locale : ustring read FLocale write FLocale;
|
||||||
property LogFile : ustring read FLogFile write FLogFile;
|
property LogFile : ustring read FLogFile write FLogFile;
|
||||||
property BrowserSubprocessPath : ustring read FBrowserSubprocessPath write FBrowserSubprocessPath;
|
property BrowserSubprocessPath : ustring read FBrowserSubprocessPath write FBrowserSubprocessPath;
|
||||||
property FrameworkDirPath : ustring read FFrameworkDirPath write SetFrameworkDirPath;
|
property FrameworkDirPath : ustring read FFrameworkDirPath write SetFrameworkDirPath;
|
||||||
property LogSeverity : TCefLogSeverity read FLogSeverity write FLogSeverity;
|
property LogSeverity : TCefLogSeverity read FLogSeverity write FLogSeverity;
|
||||||
property JavaScriptFlags : ustring read FJavaScriptFlags write FJavaScriptFlags;
|
property JavaScriptFlags : ustring read FJavaScriptFlags write FJavaScriptFlags;
|
||||||
property ResourcesDirPath : ustring read FResourcesDirPath write SetResourcesDirPath;
|
property ResourcesDirPath : ustring read FResourcesDirPath write SetResourcesDirPath;
|
||||||
property LocalesDirPath : ustring read FLocalesDirPath write SetLocalesDirPath;
|
property LocalesDirPath : ustring read FLocalesDirPath write SetLocalesDirPath;
|
||||||
property SingleProcess : Boolean read FSingleProcess write FSingleProcess;
|
property SingleProcess : Boolean read FSingleProcess write FSingleProcess;
|
||||||
property NoSandbox : Boolean read FNoSandbox write FNoSandbox;
|
property NoSandbox : Boolean read FNoSandbox write FNoSandbox;
|
||||||
property CommandLineArgsDisabled : Boolean read FCommandLineArgsDisabled write FCommandLineArgsDisabled;
|
property CommandLineArgsDisabled : Boolean read FCommandLineArgsDisabled write FCommandLineArgsDisabled;
|
||||||
property PackLoadingDisabled : Boolean read FPackLoadingDisabled write FPackLoadingDisabled;
|
property PackLoadingDisabled : Boolean read FPackLoadingDisabled write FPackLoadingDisabled;
|
||||||
property RemoteDebuggingPort : Integer read FRemoteDebuggingPort write FRemoteDebuggingPort;
|
property RemoteDebuggingPort : Integer read FRemoteDebuggingPort write FRemoteDebuggingPort;
|
||||||
property UncaughtExceptionStackSize : Integer read FUncaughtExceptionStackSize write FUncaughtExceptionStackSize;
|
property UncaughtExceptionStackSize : Integer read FUncaughtExceptionStackSize write FUncaughtExceptionStackSize;
|
||||||
property PersistSessionCookies : Boolean read FPersistSessionCookies write FPersistSessionCookies;
|
property PersistSessionCookies : Boolean read FPersistSessionCookies write FPersistSessionCookies;
|
||||||
property PersistUserPreferences : Boolean read FPersistUserPreferences write FPersistUserPreferences;
|
property PersistUserPreferences : Boolean read FPersistUserPreferences write FPersistUserPreferences;
|
||||||
property IgnoreCertificateErrors : Boolean read FIgnoreCertificateErrors write FIgnoreCertificateErrors;
|
property IgnoreCertificateErrors : Boolean read FIgnoreCertificateErrors write FIgnoreCertificateErrors;
|
||||||
property EnableNetSecurityExpiration : boolean read FEnableNetSecurityExpiration write FEnableNetSecurityExpiration;
|
property EnableNetSecurityExpiration : boolean read FEnableNetSecurityExpiration write FEnableNetSecurityExpiration;
|
||||||
property BackgroundColor : TCefColor read FBackgroundColor write FBackgroundColor;
|
property BackgroundColor : TCefColor read FBackgroundColor write FBackgroundColor;
|
||||||
property AcceptLanguageList : ustring read FAcceptLanguageList write FAcceptLanguageList;
|
property AcceptLanguageList : ustring read FAcceptLanguageList write FAcceptLanguageList;
|
||||||
property WindowsSandboxInfo : Pointer read FWindowsSandboxInfo write FWindowsSandboxInfo;
|
property WindowsSandboxInfo : Pointer read FWindowsSandboxInfo write FWindowsSandboxInfo;
|
||||||
property WindowlessRenderingEnabled : Boolean read FWindowlessRenderingEnabled write FWindowlessRenderingEnabled;
|
property WindowlessRenderingEnabled : Boolean read FWindowlessRenderingEnabled write FWindowlessRenderingEnabled;
|
||||||
property MultiThreadedMessageLoop : boolean read FMultiThreadedMessageLoop write FMultiThreadedMessageLoop;
|
property MultiThreadedMessageLoop : boolean read FMultiThreadedMessageLoop write FMultiThreadedMessageLoop;
|
||||||
property ExternalMessagePump : boolean read FExternalMessagePump write FExternalMessagePump;
|
property ExternalMessagePump : boolean read FExternalMessagePump write FExternalMessagePump;
|
||||||
property DeleteCache : boolean read FDeleteCache write FDeleteCache;
|
property DeleteCache : boolean read FDeleteCache write FDeleteCache;
|
||||||
property DeleteCookies : boolean read FDeleteCookies write FDeleteCookies;
|
property DeleteCookies : boolean read FDeleteCookies write FDeleteCookies;
|
||||||
property FlashEnabled : boolean read FFlashEnabled write FFlashEnabled;
|
property FlashEnabled : boolean read FFlashEnabled write FFlashEnabled;
|
||||||
property EnableSpellingService : boolean read FEnableSpellingService write FEnableSpellingService;
|
property EnableSpellingService : boolean read FEnableSpellingService write FEnableSpellingService;
|
||||||
property EnableMediaStream : boolean read FEnableMediaStream write FEnableMediaStream;
|
property EnableMediaStream : boolean read FEnableMediaStream write FEnableMediaStream;
|
||||||
property EnableSpeechInput : boolean read FEnableSpeechInput write FEnableSpeechInput;
|
property EnableSpeechInput : boolean read FEnableSpeechInput write FEnableSpeechInput;
|
||||||
property EnableGPU : boolean read FEnableGPU write FEnableGPU;
|
property EnableGPU : boolean read FEnableGPU write FEnableGPU;
|
||||||
property CheckCEFFiles : boolean read FCheckCEFFiles write FCheckCEFFiles;
|
property CheckCEFFiles : boolean read FCheckCEFFiles write FCheckCEFFiles;
|
||||||
property ShowMessageDlg : boolean read FShowMessageDlg write FShowMessageDlg;
|
property ShowMessageDlg : boolean read FShowMessageDlg write FShowMessageDlg;
|
||||||
property SetCurrentDir : boolean read FSetCurrentDir write FSetCurrentDir;
|
property SetCurrentDir : boolean read FSetCurrentDir write FSetCurrentDir;
|
||||||
property ChromeMajorVer : uint16 read FChromeVersionInfo.MajorVer;
|
property GlobalContextInitialized : boolean read FGlobalContextInitialized;
|
||||||
property ChromeMinorVer : uint16 read FChromeVersionInfo.MinorVer;
|
property ChromeMajorVer : uint16 read FChromeVersionInfo.MajorVer;
|
||||||
property ChromeRelease : uint16 read FChromeVersionInfo.Release;
|
property ChromeMinorVer : uint16 read FChromeVersionInfo.MinorVer;
|
||||||
property ChromeBuild : uint16 read FChromeVersionInfo.Build;
|
property ChromeRelease : uint16 read FChromeVersionInfo.Release;
|
||||||
property ChromeVersion : string read GetChromeVersion;
|
property ChromeBuild : uint16 read FChromeVersionInfo.Build;
|
||||||
property LibCefPath : string read GetLibCefPath;
|
property ChromeVersion : string read GetChromeVersion;
|
||||||
property ChromeElfPath : string read GetChromeElfPath;
|
property LibCefPath : string read GetLibCefPath;
|
||||||
property OnRegCustomSchemes : TOnRegisterCustomSchemes read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes;
|
property ChromeElfPath : string read GetChromeElfPath;
|
||||||
property ResourceBundleHandler : ICefResourceBundleHandler read FResourceBundleHandler write FResourceBundleHandler;
|
property OnRegCustomSchemes : TOnRegisterCustomSchemes read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes;
|
||||||
property BrowserProcessHandler : ICefBrowserProcessHandler read FBrowserProcessHandler write FBrowserProcessHandler;
|
property ResourceBundleHandler : ICefResourceBundleHandler read FResourceBundleHandler write FResourceBundleHandler;
|
||||||
property RenderProcessHandler : ICefRenderProcessHandler read FRenderProcessHandler write FRenderProcessHandler;
|
property RenderProcessHandler : ICefRenderProcessHandler read FRenderProcessHandler write FRenderProcessHandler;
|
||||||
property SmoothScrolling : boolean read FSmoothScrolling write FSmoothScrolling;
|
property SmoothScrolling : boolean read FSmoothScrolling write FSmoothScrolling;
|
||||||
property FastUnload : boolean read FFastUnload write FFastUnload;
|
property FastUnload : boolean read FFastUnload write FFastUnload;
|
||||||
property DisableSafeBrowsing : boolean read FDisableSafeBrowsing write FDisableSafeBrowsing;
|
property DisableSafeBrowsing : boolean read FDisableSafeBrowsing write FDisableSafeBrowsing;
|
||||||
property LibLoaded : boolean read FLibLoaded;
|
property LibLoaded : boolean read FLibLoaded;
|
||||||
property EnableHighDPISupport : boolean read FEnableHighDPISupport write FEnableHighDPISupport;
|
property EnableHighDPISupport : boolean read FEnableHighDPISupport write FEnableHighDPISupport;
|
||||||
property MuteAudio : boolean read FMuteAudio write FMuteAudio;
|
property MuteAudio : boolean read FMuteAudio write FMuteAudio;
|
||||||
property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions;
|
property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions;
|
||||||
property DeviceScaleFactor : single read FDeviceScaleFactor;
|
property DeviceScaleFactor : single read FDeviceScaleFactor;
|
||||||
property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources;
|
property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources;
|
||||||
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
|
property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired;
|
||||||
property CustomFlashPath : ustring read FCustomFlashPath write FCustomFlashPath;
|
property CustomFlashPath : ustring read FCustomFlashPath write FCustomFlashPath;
|
||||||
|
property OnContextInitialized : TOnContextInitializedEvent read FOnContextInitializedEvent write FOnContextInitializedEvent;
|
||||||
|
property OnBeforeChildProcessLaunch : TOnBeforeChildProcessLaunchEvent read FOnBeforeChildProcessLaunchEvent write FOnBeforeChildProcessLaunchEvent;
|
||||||
|
property OnRenderProcessThreadCreated : TOnRenderProcessThreadCreatedEvent read FOnRenderProcessThreadCreatedEvent write FOnRenderProcessThreadCreatedEvent;
|
||||||
|
property OnScheduleMessagePumpWork : TOnScheduleMessagePumpWorkEvent read FOnScheduleMessagePumpWorkEvent write FOnScheduleMessagePumpWorkEvent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp)
|
||||||
@@ -303,6 +318,20 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TCefCustomBrowserProcessHandler = class(TCefBrowserProcessHandlerOwn)
|
||||||
|
protected
|
||||||
|
FCefApp : TCefApplication;
|
||||||
|
|
||||||
|
procedure OnContextInitialized; override;
|
||||||
|
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); override;
|
||||||
|
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); override;
|
||||||
|
procedure OnScheduleMessagePumpWork(const delayMs: Int64); override;
|
||||||
|
|
||||||
|
public
|
||||||
|
constructor Create(const aCefApp : TCefApplication); reintroduce;
|
||||||
|
destructor Destroy; override;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
GlobalCEFApp : TCefApplication = nil;
|
GlobalCEFApp : TCefApplication = nil;
|
||||||
|
|
||||||
@@ -376,10 +405,17 @@ begin
|
|||||||
FLibLoaded := False;
|
FLibLoaded := False;
|
||||||
FShowMessageDlg := True;
|
FShowMessageDlg := True;
|
||||||
FSetCurrentDir := False;
|
FSetCurrentDir := False;
|
||||||
|
FGlobalContextInitialized := False;
|
||||||
FUpdateChromeVer := aUpdateChromeVer;
|
FUpdateChromeVer := aUpdateChromeVer;
|
||||||
FCheckDevToolsResources := True;
|
FCheckDevToolsResources := True;
|
||||||
FLocalesRequired := '';
|
FLocalesRequired := '';
|
||||||
|
|
||||||
|
// ICefBrowserProcessHandler
|
||||||
|
FOnContextInitializedEvent := nil;
|
||||||
|
FOnBeforeChildProcessLaunchEvent := nil;
|
||||||
|
FOnRenderProcessThreadCreatedEvent := nil;
|
||||||
|
FOnScheduleMessagePumpWorkEvent := nil;
|
||||||
|
|
||||||
UpdateDeviceScaleFactor;
|
UpdateDeviceScaleFactor;
|
||||||
|
|
||||||
FAppSettings.size := SizeOf(TCefSettings);
|
FAppSettings.size := SizeOf(TCefSettings);
|
||||||
@@ -413,6 +449,7 @@ begin
|
|||||||
|
|
||||||
FCustomCommandLines := TStringList.Create;
|
FCustomCommandLines := TStringList.Create;
|
||||||
FCustomCommandLineValues := TStringList.Create;
|
FCustomCommandLineValues := TStringList.Create;
|
||||||
|
FBrowserProcessHandler := TCefCustomBrowserProcessHandler.Create(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCefApplication.AddCustomCommandLine(const aCommandLine, aValue : string);
|
procedure TCefApplication.AddCustomCommandLine(const aCommandLine, aValue : string);
|
||||||
@@ -705,8 +742,7 @@ begin
|
|||||||
|
|
||||||
InitializeSettings(FAppSettings);
|
InitializeSettings(FAppSettings);
|
||||||
|
|
||||||
Result := (cef_initialize(@HInstance, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0) and
|
Result := (cef_initialize(@HInstance, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0);
|
||||||
InitializeCookies;
|
|
||||||
except
|
except
|
||||||
on e : exception do
|
on e : exception do
|
||||||
if CustomExceptionHandler('TCefApplication.InitializeLibrary', e) then raise;
|
if CustomExceptionHandler('TCefApplication.InitializeLibrary', e) then raise;
|
||||||
@@ -815,6 +851,29 @@ begin
|
|||||||
if FShowMessageDlg then MessageDlg(aError, mtError, [mbOk], 0);
|
if FShowMessageDlg then MessageDlg(aError, mtError, [mbOk], 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCefApplication.Internal_OnContextInitialized;
|
||||||
|
begin
|
||||||
|
InitializeCookies;
|
||||||
|
FGlobalContextInitialized := True;
|
||||||
|
|
||||||
|
if assigned(FOnContextInitializedEvent) then FOnContextInitializedEvent;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefApplication.Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||||
|
begin
|
||||||
|
if assigned(FOnBeforeChildProcessLaunchEvent) then FOnBeforeChildProcessLaunchEvent(commandLine);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefApplication.Internal_OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||||
|
begin
|
||||||
|
if assigned(FOnRenderProcessThreadCreatedEvent) then FOnRenderProcessThreadCreatedEvent(extraInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefApplication.Internal_OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||||
|
begin
|
||||||
|
if assigned(FOnScheduleMessagePumpWorkEvent) then FOnScheduleMessagePumpWorkEvent(delayMs);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processType : ustring;
|
procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processType : ustring;
|
||||||
const commandLine : ICefCommandLine);
|
const commandLine : ICefCommandLine);
|
||||||
var
|
var
|
||||||
@@ -1650,4 +1709,40 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// TCefCustomBrowserProcessHandler
|
||||||
|
|
||||||
|
constructor TCefCustomBrowserProcessHandler.Create(const aCefApp : TCefApplication);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
|
||||||
|
FCefApp := aCefApp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCefCustomBrowserProcessHandler.Destroy;
|
||||||
|
begin
|
||||||
|
FCefApp := nil;
|
||||||
|
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefCustomBrowserProcessHandler.OnContextInitialized;
|
||||||
|
begin
|
||||||
|
if (FCefApp <> nil) then FCefApp.Internal_OnContextInitialized;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefCustomBrowserProcessHandler.OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||||
|
begin
|
||||||
|
if (FCefApp <> nil) then FCefApp.Internal_OnBeforeChildProcessLaunch(commandLine);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefCustomBrowserProcessHandler.OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||||
|
begin
|
||||||
|
if (FCefApp <> nil) then FCefApp.Internal_OnRenderProcessThreadCreated(extraInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCefCustomBrowserProcessHandler.OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||||
|
begin
|
||||||
|
if (FCefApp <> nil) then FCefApp.Internal_OnScheduleMessagePumpWork(delayMs);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@@ -51,13 +51,14 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
TCefBrowserProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefBrowserProcessHandler)
|
TCefBrowserProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefBrowserProcessHandler)
|
||||||
protected
|
protected
|
||||||
procedure OnContextInitialized; virtual;
|
procedure OnContextInitialized; virtual;
|
||||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); virtual;
|
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); virtual;
|
||||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); virtual;
|
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); virtual;
|
||||||
procedure OnScheduleMessagePumpWork(delayMs: Int64); virtual;
|
procedure OnScheduleMessagePumpWork(const delayMs: Int64); virtual;
|
||||||
public
|
|
||||||
constructor Create; virtual;
|
public
|
||||||
|
constructor Create; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@@ -96,11 +97,11 @@ begin
|
|||||||
|
|
||||||
with PCefBrowserProcessHandler(FData)^ do
|
with PCefBrowserProcessHandler(FData)^ do
|
||||||
begin
|
begin
|
||||||
on_context_initialized := cef_browser_process_handler_on_context_initialized;
|
on_context_initialized := cef_browser_process_handler_on_context_initialized;
|
||||||
on_before_child_process_launch := cef_browser_process_handler_on_before_child_process_launch;
|
on_before_child_process_launch := cef_browser_process_handler_on_before_child_process_launch;
|
||||||
on_render_process_thread_created := cef_browser_process_handler_on_render_process_thread_created;
|
on_render_process_thread_created := cef_browser_process_handler_on_render_process_thread_created;
|
||||||
get_print_handler := nil; // linux
|
get_print_handler := nil; // linux
|
||||||
on_schedule_message_pump_work := cef_browser_process_handler_on_schedule_message_pump_work;
|
on_schedule_message_pump_work := cef_browser_process_handler_on_schedule_message_pump_work;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCefBrowserProcessHandlerOwn.OnScheduleMessagePumpWork(delayMs: Int64);
|
procedure TCefBrowserProcessHandlerOwn.OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -924,11 +924,19 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||||
|
// even if you use a custom request context.
|
||||||
|
// If you create a browser in the initialization of your app, make sure you call this
|
||||||
|
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||||
|
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||||
|
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||||
|
|
||||||
if not(csDesigning in ComponentState) and
|
if not(csDesigning in ComponentState) and
|
||||||
not(FClosing) and
|
not(FClosing) and
|
||||||
(FBrowser = nil) and
|
(FBrowser = nil) and
|
||||||
(FBrowserId = 0) and
|
(FBrowserId = 0) and
|
||||||
(GlobalCEFApp <> nil) and
|
(GlobalCEFApp <> nil) and
|
||||||
|
GlobalCEFApp.GlobalContextInitialized and
|
||||||
CreateClientHandler(aParentHandle = 0) then
|
CreateClientHandler(aParentHandle = 0) then
|
||||||
begin
|
begin
|
||||||
GetSettings(FBrowserSettings);
|
GetSettings(FBrowserSettings);
|
||||||
|
|||||||
@@ -107,21 +107,25 @@ type
|
|||||||
TCefBinaryValueArray = array of ICefBinaryValue;
|
TCefBinaryValueArray = array of ICefBinaryValue;
|
||||||
TCefFrameIdentifierArray = array of int64;
|
TCefFrameIdentifierArray = array of int64;
|
||||||
|
|
||||||
TOnPdfPrintFinishedProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const path: ustring; ok: Boolean);
|
TOnPdfPrintFinishedProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const path: ustring; ok: Boolean);
|
||||||
TCefDomVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const document: ICefDomDocument);
|
TCefDomVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const document: ICefDomDocument);
|
||||||
TCefDomVisitorProc2 = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser : ICefBrowser; const document: ICefDomDocument);
|
TCefDomVisitorProc2 = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser : ICefBrowser; const document: ICefDomDocument);
|
||||||
TCefStringVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const str: ustring);
|
TCefStringVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const str: ustring);
|
||||||
TOnRegisterCustomSchemes = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const registrar: TCefSchemeRegistrarRef) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnRegisterCustomSchemes = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const registrar: TCefSchemeRegistrarRef) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnRenderThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnRenderThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnWebKitInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnWebKitInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnBrowserCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnBrowserCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnBrowserDestroyedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnBrowserDestroyedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnBeforeNavigationEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean; var aStopNavigation : boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnBeforeNavigationEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean; var aStopNavigation : boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnContextCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnContextCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnContextReleasedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnContextReleasedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnUncaughtExceptionEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnUncaughtExceptionEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnFocusedNodeChangedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnFocusedNodeChangedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
TOnProcessMessageReceivedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
TOnProcessMessageReceivedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
|
TOnContextInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
|
TOnBeforeChildProcessLaunchEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const commandLine: ICefCommandLine) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
|
TOnRenderProcessThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
|
TOnScheduleMessagePumpWorkEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const delayMs: Int64) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
|
||||||
|
|
||||||
TCefCompletionCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure;
|
TCefCompletionCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure;
|
||||||
TCefSetCookieCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(success: Boolean);
|
TCefSetCookieCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(success: Boolean);
|
||||||
@@ -857,7 +861,7 @@ type
|
|||||||
procedure OnContextInitialized;
|
procedure OnContextInitialized;
|
||||||
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine);
|
||||||
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue);
|
||||||
procedure OnScheduleMessagePumpWork(delayMs: Int64);
|
procedure OnScheduleMessagePumpWork(const delayMs: Int64);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ICefRenderProcessHandler = interface(ICefBaseRefCounted)
|
ICefRenderProcessHandler = interface(ICefBaseRefCounted)
|
||||||
|
|||||||
Reference in New Issue
Block a user