1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-05-13 21:46:53 +02:00

Update to CEF 3.3538.1852.gcb937fc

- Bug fix #139
- Added a LoadHandler in the render process.
- Added TCefApplication.OnLoadingStateChange
- Added TCefApplication.OnLoadStart
- Added TCefApplication.OnLoadEnd
- Added TCefApplication.OnLoadError
- Fixed a Delphi XE2 compilation issue.
This commit is contained in:
Salvador Díaz Fau 2018-11-15 19:08:16 +01:00
parent 428ae519b9
commit 10c9a99805
5 changed files with 189 additions and 11 deletions

View File

@ -52,16 +52,16 @@ interface
uses uses
{$IFDEF DELPHI16_UP} {$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.UITypes, {$IFDEF MSWINDOWS}WinApi.Windows, Vcl.Forms,{$ENDIF} System.Classes, System.UITypes,
{$ELSE} {$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, {$IFDEF FPC}dynlibs,{$ENDIF} {$IFDEF MSWINDOWS}Windows, Forms,{$ENDIF} Classes, {$IFDEF FPC}dynlibs,{$ENDIF}
{$ENDIF} {$ENDIF}
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar; uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar;
const const
CEF_SUPPORTED_VERSION_MAJOR = 3; CEF_SUPPORTED_VERSION_MAJOR = 3;
CEF_SUPPORTED_VERSION_MINOR = 3538; CEF_SUPPORTED_VERSION_MINOR = 3538;
CEF_SUPPORTED_VERSION_RELEASE = 1851; CEF_SUPPORTED_VERSION_RELEASE = 1852;
CEF_SUPPORTED_VERSION_BUILD = 0; CEF_SUPPORTED_VERSION_BUILD = 0;
CEF_CHROMEELF_VERSION_MAJOR = 70; CEF_CHROMEELF_VERSION_MAJOR = 70;
@ -129,6 +129,7 @@ type
FDisableWebSecurity : boolean; FDisableWebSecurity : boolean;
FDisablePDFExtension : boolean; FDisablePDFExtension : boolean;
FLogProcessInfo : boolean; FLogProcessInfo : boolean;
FDestroyAppWindows : boolean;
FChromeVersionInfo : TFileVersionInfo; FChromeVersionInfo : TFileVersionInfo;
{$IFDEF FPC} {$IFDEF FPC}
FLibHandle : TLibHandle; FLibHandle : TLibHandle;
@ -152,6 +153,7 @@ type
FMustCreateResourceBundleHandler : boolean; FMustCreateResourceBundleHandler : boolean;
FMustCreateBrowserProcessHandler : boolean; FMustCreateBrowserProcessHandler : boolean;
FMustCreateRenderProcessHandler : boolean; FMustCreateRenderProcessHandler : boolean;
FMustCreateLoadHandler : boolean;
// ICefBrowserProcessHandler // ICefBrowserProcessHandler
FOnContextInitialized : TOnContextInitializedEvent; FOnContextInitialized : TOnContextInitializedEvent;
@ -178,6 +180,12 @@ type
// ICefRegisterCDMCallback // ICefRegisterCDMCallback
FOnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent; FOnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent;
// ICefLoadHandler
FOnLoadingStateChange : TOnRenderLoadingStateChange;
FOnLoadStart : TOnRenderLoadStart;
FOnLoadEnd : TOnRenderLoadEnd;
FOnLoadError : TOnRenderLoadError;
procedure SetCache(const aValue : ustring); procedure SetCache(const aValue : ustring);
procedure SetCookies(const aValue : ustring); procedure SetCookies(const aValue : ustring);
procedure SetUserDataPath(const aValue : ustring); procedure SetUserDataPath(const aValue : ustring);
@ -194,6 +202,7 @@ type
function GetMustCreateResourceBundleHandler : boolean; function GetMustCreateResourceBundleHandler : boolean;
function GetMustCreateBrowserProcessHandler : boolean; function GetMustCreateBrowserProcessHandler : boolean;
function GetMustCreateRenderProcessHandler : boolean; function GetMustCreateRenderProcessHandler : boolean;
function GetMustCreateLoadHandler : boolean;
function GetGlobalContextInitialized : boolean; function GetGlobalContextInitialized : boolean;
function GetChildProcessesCount : integer; function GetChildProcessesCount : integer;
function GetUsedMemory : cardinal; function GetUsedMemory : cardinal;
@ -280,8 +289,8 @@ type
procedure UpdateDeviceScaleFactor; procedure UpdateDeviceScaleFactor;
// Internal procedures. Only TInternalApp, TCefCustomBrowserProcessHandler, // Internal procedures. Only TInternalApp, TCefCustomBrowserProcessHandler,
// ICefResourceBundleHandler, ICefRenderProcessHandler and ICefRegisterCDMCallback // ICefResourceBundleHandler, ICefRenderProcessHandler, ICefRegisterCDMCallback
// should use them. // and ICefLoadHandler 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_OnContextInitialized; procedure Internal_OnContextInitialized;
@ -301,6 +310,10 @@ type
procedure Internal_OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); procedure Internal_OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode);
procedure Internal_OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean); procedure Internal_OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean);
procedure Internal_OnCDMRegistrationComplete(result : TCefCDMRegistrationError; const error_message : ustring); procedure Internal_OnCDMRegistrationComplete(result : TCefCDMRegistrationError; const error_message : ustring);
procedure Internal_OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
procedure Internal_OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType);
procedure Internal_OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
procedure Internal_OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring);
property Cache : ustring read FCache write SetCache; property Cache : ustring read FCache write SetCache;
property Cookies : ustring read FCookies write SetCookies; property Cookies : ustring read FCookies write SetCookies;
@ -359,6 +372,7 @@ type
property DisableWebSecurity : boolean read FDisableWebSecurity write FDisableWebSecurity; property DisableWebSecurity : boolean read FDisableWebSecurity write FDisableWebSecurity;
property DisablePDFExtension : boolean read FDisablePDFExtension write FDisablePDFExtension; property DisablePDFExtension : boolean read FDisablePDFExtension write FDisablePDFExtension;
property LogProcessInfo : boolean read FLogProcessInfo write FLogProcessInfo; property LogProcessInfo : boolean read FLogProcessInfo write FLogProcessInfo;
property DestroyAppWindows : boolean read FDestroyAppWindows write FDestroyAppWindows;
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;
@ -369,6 +383,7 @@ type
property MustCreateResourceBundleHandler : boolean read GetMustCreateResourceBundleHandler write FMustCreateResourceBundleHandler; property MustCreateResourceBundleHandler : boolean read GetMustCreateResourceBundleHandler write FMustCreateResourceBundleHandler;
property MustCreateBrowserProcessHandler : boolean read GetMustCreateBrowserProcessHandler write FMustCreateBrowserProcessHandler; property MustCreateBrowserProcessHandler : boolean read GetMustCreateBrowserProcessHandler write FMustCreateBrowserProcessHandler;
property MustCreateRenderProcessHandler : boolean read GetMustCreateRenderProcessHandler write FMustCreateRenderProcessHandler; property MustCreateRenderProcessHandler : boolean read GetMustCreateRenderProcessHandler write FMustCreateRenderProcessHandler;
property MustCreateLoadHandler : boolean read GetMustCreateLoadHandler write FMustCreateLoadHandler;
property OsmodalLoop : boolean write SetOsmodalLoop; property OsmodalLoop : boolean write SetOsmodalLoop;
property Status : TCefAplicationStatus read FStatus; property Status : TCefAplicationStatus read FStatus;
property MissingLibFiles : string read FMissingLibFiles; property MissingLibFiles : string read FMissingLibFiles;
@ -408,6 +423,12 @@ type
// ICefRegisterCDMCallback // ICefRegisterCDMCallback
property OnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent read FOnCDMRegistrationComplete write FOnCDMRegistrationComplete; property OnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent read FOnCDMRegistrationComplete write FOnCDMRegistrationComplete;
// ICefLoadHandler
property OnLoadingStateChange : TOnRenderLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange;
property OnLoadStart : TOnRenderLoadStart read FOnLoadStart write FOnLoadStart;
property OnLoadEnd : TOnRenderLoadEnd read FOnLoadEnd write FOnLoadEnd;
property OnLoadError : TOnRenderLoadError read FOnLoadError write FOnLoadError;
end; end;
TCEFCookieInitializerThread = class(TThread) TCEFCookieInitializerThread = class(TThread)
@ -514,6 +535,7 @@ begin
FDisableWebSecurity := False; FDisableWebSecurity := False;
FDisablePDFExtension := False; FDisablePDFExtension := False;
FLogProcessInfo := False; FLogProcessInfo := False;
FDestroyAppWindows := True;
FReRaiseExceptions := False; FReRaiseExceptions := False;
FLibLoaded := False; FLibLoaded := False;
FShowMessageDlg := True; FShowMessageDlg := True;
@ -532,6 +554,7 @@ begin
FMustCreateResourceBundleHandler := False; FMustCreateResourceBundleHandler := False;
FMustCreateBrowserProcessHandler := True; FMustCreateBrowserProcessHandler := True;
FMustCreateRenderProcessHandler := False; FMustCreateRenderProcessHandler := False;
FMustCreateLoadHandler := False;
// ICefBrowserProcessHandler // ICefBrowserProcessHandler
FOnContextInitialized := nil; FOnContextInitialized := nil;
@ -558,6 +581,12 @@ begin
// ICefRegisterCDMCallback // ICefRegisterCDMCallback
FOnCDMRegistrationComplete := nil; FOnCDMRegistrationComplete := nil;
// ICefLoadHandler
FOnLoadingStateChange := nil;
FOnLoadStart := nil;
FOnLoadEnd := nil;
FOnLoadError := nil;
UpdateDeviceScaleFactor; UpdateDeviceScaleFactor;
FillChar(FAppSettings, SizeOf(TCefSettings), 0); FillChar(FAppSettings, SizeOf(TCefSettings), 0);
@ -648,6 +677,21 @@ begin
try try
if CheckCEFLibrary and LoadCEFlibrary then if CheckCEFLibrary and LoadCEFlibrary then
begin begin
{$IFNDEF FPC}
if FDestroyAppWindows and (ProcessType <> ptBrowser) and (Application <> nil) then
begin
// This is the fix for the issue #139
// https://github.com/salvadordf/CEF4Delphi/issues/139
// Subprocesses will never use these window handles but TApplication creates them
// before executing the code in the DPR file. Any other application trying to
// initiate a DDE conversation will use SendMessage or SendMessageTimeout to
// broadcast the WM_DDE_INITIATE to all top-level windows. The subprocesses never
// call Application.Run so the SendMessage freezes the other applications.
if (Application.Handle <> 0) then DestroyWindow(Application.Handle);
if (Application.PopupControlWnd <> 0) then DeallocateHWnd(Application.PopupControlWnd);
end;
{$ENDIF}
TempApp := TCustomCefApp.Create(self); TempApp := TCustomCefApp.Create(self);
Result := (ExecuteProcess(TempApp) < 0) and InitializeLibrary(TempApp); Result := (ExecuteProcess(TempApp) < 0) and InitializeLibrary(TempApp);
end; end;
@ -1360,6 +1404,26 @@ begin
if assigned(FOnCDMRegistrationComplete) then FOnCDMRegistrationComplete(result, error_message); if assigned(FOnCDMRegistrationComplete) then FOnCDMRegistrationComplete(result, error_message);
end; end;
procedure TCefApplication.Internal_OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
begin
if assigned(FOnLoadingStateChange) then FOnLoadingStateChange(browser, isLoading, canGoBack, canGoForward);
end;
procedure TCefApplication.Internal_OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType);
begin
if assigned(FOnLoadStart) then FOnLoadStart(browser, frame, transitionType);
end;
procedure TCefApplication.Internal_OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
begin
if assigned(FOnLoadEnd) then FOnLoadEnd(browser, frame, httpStatusCode);
end;
procedure TCefApplication.Internal_OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring);
begin
if assigned(FOnLoadError) then FOnLoadError(browser, frame, errorCode, errorText, failedUrl);
end;
procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processType : ustring; procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processType : ustring;
const commandLine : ICefCommandLine); const commandLine : ICefCommandLine);
var var
@ -1499,6 +1563,7 @@ begin
Result := FSingleProcess or Result := FSingleProcess or
((FProcessType = ptRenderer) and ((FProcessType = ptRenderer) and
(FMustCreateRenderProcessHandler or (FMustCreateRenderProcessHandler or
MustCreateLoadHandler or
assigned(FOnRenderThreadCreated) or assigned(FOnRenderThreadCreated) or
assigned(FOnWebKitInitialized) or assigned(FOnWebKitInitialized) or
assigned(FOnBrowserCreated) or assigned(FOnBrowserCreated) or
@ -1510,6 +1575,17 @@ begin
assigned(FOnProcessMessageReceived))); assigned(FOnProcessMessageReceived)));
end; end;
function TCefApplication.GetMustCreateLoadHandler : boolean;
begin
Result := FSingleProcess or
((FProcessType = ptRenderer) and
(FMustCreateLoadHandler or
assigned(FOnLoadingStateChange) or
assigned(FOnLoadStart) or
assigned(FOnLoadEnd) or
assigned(FOnLoadError)));
end;
function TCefApplication.GetGlobalContextInitialized : boolean; function TCefApplication.GetGlobalContextInitialized : boolean;
begin begin
Result := FGlobalContextInitialized or not(MustCreateBrowserProcessHandler); Result := FGlobalContextInitialized or not(MustCreateBrowserProcessHandler);

View File

@ -170,7 +170,10 @@ type
TOnGetLocalizedStringEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(stringId: Integer; out stringVal: ustring; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; TOnGetLocalizedStringEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(stringId: Integer; out stringVal: ustring; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
TOnGetDataResourceForScaleEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; out dataSize: NativeUInt; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; TOnGetDataResourceForScaleEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; out dataSize: NativeUInt; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
TOnCDMRegistrationCompleteEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(result : TCefCDMRegistrationError; const error_message : ustring) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; TOnCDMRegistrationCompleteEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(result : TCefCDMRegistrationError; const error_message : ustring) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
TOnRenderLoadStart = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
TOnRenderLoadEnd = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
TOnRenderLoadError = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; errorCode: TCefErrorCode; const errorText, failedUrl: ustring) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
TOnRenderLoadingStateChange = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF};
// ******************************************* // *******************************************
// **** Callback procedures and functions **** // **** Callback procedures and functions ****

View File

@ -51,7 +51,7 @@ unit uCEFLoadHandler;
interface interface
uses uses
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplication;
type type
TCefLoadHandlerOwn = class(TCefBaseRefCountedOwn, ICefLoadHandler) TCefLoadHandlerOwn = class(TCefBaseRefCountedOwn, ICefLoadHandler)
@ -83,6 +83,20 @@ type
destructor Destroy; override; destructor Destroy; override;
end; end;
TCustomRenderLoadHandler = class(TCefLoadHandlerOwn)
protected
FCefApp : TCefApplication;
procedure OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); override;
procedure OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); override;
procedure OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); override;
procedure OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: TCefErrorCode; const errorText, failedUrl: ustring); override;
public
constructor Create(const aCefApp : TCefApplication); reintroduce; virtual;
destructor Destroy; override;
end;
implementation implementation
uses uses
@ -249,4 +263,73 @@ begin
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnLoadStart(browser, frame, transitionType); if (FEvents <> nil) then IChromiumEvents(FEvents).doOnLoadStart(browser, frame, transitionType);
end; end;
// TCustomRenderLoadHandler
constructor TCustomRenderLoadHandler.Create(const aCefApp : TCefApplication);
begin
inherited Create;
FCefApp := aCefApp;
end;
destructor TCustomRenderLoadHandler.Destroy;
begin
FCefApp := nil;
inherited Destroy;
end;
procedure TCustomRenderLoadHandler.OnLoadEnd(const browser : ICefBrowser;
const frame : ICefFrame;
httpStatusCode : Integer);
begin
try
if (FCefApp <> nil) then FCefApp.Internal_OnLoadEnd(browser, frame, httpStatusCode);
except
on e : exception do
if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadEnd', e) then raise;
end;
end;
procedure TCustomRenderLoadHandler.OnLoadError(const browser : ICefBrowser;
const frame : ICefFrame;
errorCode : TCefErrorCode;
const errorText : ustring;
const failedUrl : ustring);
begin
try
if (FCefApp <> nil) then FCefApp.Internal_OnLoadError(browser, frame, errorCode, errorText, failedUrl);
except
on e : exception do
if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadError', e) then raise;
end;
end;
procedure TCustomRenderLoadHandler.OnLoadingStateChange(const browser : ICefBrowser;
isLoading : Boolean;
canGoBack : Boolean;
canGoForward : Boolean);
begin
try
if (FCefApp <> nil) then FCefApp.Internal_OnLoadingStateChange(browser, isLoading, canGoBack, canGoForward);
except
on e : exception do
if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadingStateChange', e) then raise;
end;
end;
procedure TCustomRenderLoadHandler.OnLoadStart(const browser : ICefBrowser;
const frame : ICefFrame;
transitionType : TCefTransitionType);
begin
try
if (FCefApp <> nil) then FCefApp.Internal_OnLoadStart(browser, frame, transitionType);
except
on e : exception do
if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadStart', e) then raise;
end;
end;
end. end.

View File

@ -1320,7 +1320,7 @@ begin
exit; exit;
{$ENDIF} {$ENDIF}
{$IFDEF DELPHI16_UP} {$IFDEF DELPHI17_UP}
Result := TOSVersion.Architecture in [arIntelX86, arARM32]; Result := TOSVersion.Architecture in [arIntelX86, arARM32];
{$ELSE} {$ELSE}
Result := False; Result := False;

View File

@ -80,11 +80,13 @@ type
TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn) TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn)
protected protected
FCefApp : TCefApplication; FCefApp : TCefApplication;
FLoadHandler : ICefLoadHandler;
procedure OnRenderThreadCreated(const extraInfo: ICefListValue); override; procedure OnRenderThreadCreated(const extraInfo: ICefListValue); override;
procedure OnWebKitInitialized; override; procedure OnWebKitInitialized; override;
procedure OnBrowserCreated(const browser: ICefBrowser); override; procedure OnBrowserCreated(const browser: ICefBrowser); override;
procedure OnBrowserDestroyed(const browser: ICefBrowser); override; procedure OnBrowserDestroyed(const browser: ICefBrowser); override;
function GetLoadHandler: ICefLoadHandler; override;
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override; procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override; procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); override; procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); override;
@ -104,7 +106,7 @@ uses
{$ELSE} {$ELSE}
SysUtils, SysUtils,
{$ENDIF} {$ENDIF}
uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants; uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants, uCEFLoadHandler;
procedure cef_render_process_handler_on_render_thread_created(self : PCefRenderProcessHandler; procedure cef_render_process_handler_on_render_thread_created(self : PCefRenderProcessHandler;
extra_info : PCefListValue); stdcall; extra_info : PCefListValue); stdcall;
@ -284,11 +286,17 @@ begin
inherited Create; inherited Create;
FCefApp := aCefApp; FCefApp := aCefApp;
if (FCefApp <> nil) and FCefApp.MustCreateLoadHandler then
FLoadHandler := TCustomRenderLoadHandler.Create(FCefApp)
else
FLoadHandler := nil;
end; end;
destructor TCefCustomRenderProcessHandler.Destroy; destructor TCefCustomRenderProcessHandler.Destroy;
begin begin
FCefApp := nil; FCefApp := nil;
FLoadHandler := nil;
inherited Destroy; inherited Destroy;
end; end;
@ -333,6 +341,14 @@ begin
end; end;
end; end;
function TCefCustomRenderProcessHandler.GetLoadHandler: ICefLoadHandler;
begin
if (FLoadHandler <> nil) then
Result := FLoadHandler
else
Result := inherited GetLoadHandler;
end;
procedure TCefCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser; procedure TCefCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser;
const frame : ICefFrame; const frame : ICefFrame;
const context : ICefv8Context); const context : ICefv8Context);