2017-01-27 17:37:51 +02:00
|
|
|
// ************************************************************************
|
|
|
|
// ***************************** CEF4Delphi *******************************
|
|
|
|
// ************************************************************************
|
|
|
|
//
|
2019-10-19 10:58:34 +02:00
|
|
|
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
2017-01-27 17:37:51 +02:00
|
|
|
// browser in Delphi applications.
|
|
|
|
//
|
|
|
|
// The original license of DCEF3 still applies to CEF4Delphi.
|
|
|
|
//
|
|
|
|
// For more information about CEF4Delphi visit :
|
|
|
|
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
|
|
|
//
|
2022-01-01 11:41:21 +02:00
|
|
|
// Copyright � 2022 Salvador Diaz Fau. All rights reserved.
|
2017-01-27 17:37:51 +02:00
|
|
|
//
|
|
|
|
// ************************************************************************
|
|
|
|
// ************ vvvv Original license and comments below vvvv *************
|
|
|
|
// ************************************************************************
|
|
|
|
(*
|
|
|
|
* Delphi Chromium Embedded 3
|
|
|
|
*
|
|
|
|
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
|
|
|
* or alternatively the restrictions of the Mozilla Public License 1.1
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
|
|
|
* the specific language governing rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
|
|
|
* Web site : http://www.progdigy.com
|
|
|
|
* Repository : http://code.google.com/p/delphichromiumembedded/
|
|
|
|
* Group : http://groups.google.com/group/delphichromiumembedded
|
|
|
|
*
|
|
|
|
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
|
|
|
* this source code without explicit permission.
|
|
|
|
*
|
|
|
|
*)
|
|
|
|
|
|
|
|
unit uCEFRenderProcessHandler;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 21:56:46 +02:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 19:56:41 +02:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-22 16:22:11 +02:00
|
|
|
{$IFDEF DELPHI16_UP}
|
|
|
|
System.Classes,
|
|
|
|
{$ELSE}
|
|
|
|
Classes,
|
|
|
|
{$ENDIF}
|
2017-03-16 20:09:42 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFListValue, uCEFBrowser, uCEFFrame, uCEFRequest,
|
2019-11-09 00:15:53 +02:00
|
|
|
uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage, uCEFApplicationCore;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
type
|
2017-03-16 20:09:42 +02:00
|
|
|
TCefRenderProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefRenderProcessHandler)
|
2017-03-22 16:22:11 +02:00
|
|
|
protected
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure OnWebKitInitialized; virtual; abstract;
|
2019-06-16 10:31:13 +02:00
|
|
|
procedure OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); virtual; abstract;
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual; abstract;
|
|
|
|
function GetLoadHandler: ICefLoadHandler; virtual;
|
|
|
|
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; abstract;
|
|
|
|
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; abstract;
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual; abstract;
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual; abstract;
|
2019-06-16 10:31:13 +02:00
|
|
|
function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual;
|
2017-12-27 15:05:33 +02:00
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
procedure RemoveReferences; virtual; abstract;
|
|
|
|
|
2017-03-22 16:22:11 +02:00
|
|
|
public
|
|
|
|
constructor Create; virtual;
|
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn)
|
|
|
|
protected
|
2019-11-09 00:15:53 +02:00
|
|
|
FCefApp : TCefApplicationCore;
|
2018-11-15 20:08:16 +02:00
|
|
|
FLoadHandler : ICefLoadHandler;
|
2017-11-25 20:04:15 +02:00
|
|
|
|
|
|
|
procedure OnWebKitInitialized; override;
|
2019-06-16 10:31:13 +02:00
|
|
|
procedure OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); override;
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure OnBrowserDestroyed(const browser: ICefBrowser); override;
|
2018-11-15 20:08:16 +02:00
|
|
|
function GetLoadHandler: ICefLoadHandler; override;
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
|
|
|
|
procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); override;
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); override;
|
2019-06-16 10:31:13 +02:00
|
|
|
function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage : ICefProcessMessage): Boolean; override;
|
2017-11-25 20:04:15 +02:00
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
procedure RemoveReferences; override;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
public
|
2019-11-09 00:15:53 +02:00
|
|
|
constructor Create(const aCefApp : TCefApplicationCore); reintroduce;
|
2017-11-25 20:04:15 +02:00
|
|
|
destructor Destroy; override;
|
|
|
|
end;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2018-03-29 20:02:04 +02:00
|
|
|
{$IFDEF DELPHI16_UP}
|
|
|
|
System.SysUtils,
|
|
|
|
{$ELSE}
|
|
|
|
SysUtils,
|
|
|
|
{$ENDIF}
|
2019-06-16 10:31:13 +02:00
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants, uCEFLoadHandler, uCEFDictionaryValue;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
procedure cef_render_process_handler_on_web_kit_initialized(self: PCefRenderProcessHandler); stdcall;
|
2017-11-25 20:04:15 +02:00
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnWebKitInitialized;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2019-06-16 10:31:13 +02:00
|
|
|
procedure cef_render_process_handler_on_browser_created(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
extra_info : PCefDictionaryValue); stdcall;
|
2017-11-25 20:04:15 +02:00
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2019-06-16 10:31:13 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnBrowserCreated(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TCefDictionaryValueRef.UnWrap(extra_info));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure cef_render_process_handler_on_browser_destroyed(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnBrowserDestroyed(TCefBrowserRef.UnWrap(browser));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function cef_render_process_handler_get_load_handler(self: PCefRenderProcessHandler): PCefLoadHandler; stdcall;
|
2017-11-25 20:04:15 +02:00
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := nil;
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := CefGetData(TCefRenderProcessHandlerOwn(TempObject).GetLoadHandler);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure cef_render_process_handler_on_context_created(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
frame : PCefFrame;
|
|
|
|
context : PCefv8Context); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnContextCreated(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TCefFrameRef.UnWrap(frame),
|
|
|
|
TCefv8ContextRef.UnWrap(context));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure cef_render_process_handler_on_context_released(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
frame : PCefFrame;
|
|
|
|
context : PCefv8Context); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnContextReleased(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TCefFrameRef.UnWrap(frame),
|
|
|
|
TCefv8ContextRef.UnWrap(context));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure cef_render_process_handler_on_uncaught_exception(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
frame : PCefFrame;
|
|
|
|
context : PCefv8Context;
|
|
|
|
exception : PCefV8Exception;
|
|
|
|
stackTrace : PCefV8StackTrace); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnUncaughtException(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TCefFrameRef.UnWrap(frame),
|
|
|
|
TCefv8ContextRef.UnWrap(context),
|
|
|
|
TCefV8ExceptionRef.UnWrap(exception),
|
|
|
|
TCefV8StackTraceRef.UnWrap(stackTrace));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure cef_render_process_handler_on_focused_node_changed(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
frame : PCefFrame;
|
|
|
|
node : PCefDomNode); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
TCefRenderProcessHandlerOwn(TempObject).OnFocusedNodeChanged(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TCefFrameRef.UnWrap(frame),
|
|
|
|
TCefDomNodeRef.UnWrap(node));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
function cef_render_process_handler_on_process_message_received(self : PCefRenderProcessHandler;
|
|
|
|
browser : PCefBrowser;
|
2019-06-16 10:31:13 +02:00
|
|
|
frame : PCefFrame;
|
2017-11-25 20:04:15 +02:00
|
|
|
source_process : TCefProcessId;
|
|
|
|
message_ : PCefProcessMessage): Integer; stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := Ord(False);
|
2017-11-25 20:04:15 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
if (TempObject <> nil) and
|
|
|
|
(TempObject is TCefRenderProcessHandlerOwn) then
|
2017-11-25 20:04:15 +02:00
|
|
|
Result := Ord(TCefRenderProcessHandlerOwn(TempObject).OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser),
|
2019-06-16 10:31:13 +02:00
|
|
|
TCefFrameRef.UnWrap(frame),
|
2017-11-25 20:04:15 +02:00
|
|
|
source_process,
|
2018-03-29 20:02:04 +02:00
|
|
|
TCefProcessMessageRef.UnWrap(message_)));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2017-03-22 16:22:11 +02:00
|
|
|
// TCefRenderProcessHandlerOwn
|
|
|
|
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
constructor TCefRenderProcessHandlerOwn.Create;
|
|
|
|
begin
|
|
|
|
inherited CreateData(SizeOf(TCefRenderProcessHandler));
|
2017-03-22 16:22:11 +02:00
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
with PCefRenderProcessHandler(FData)^ do
|
2017-03-22 16:22:11 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
on_web_kit_initialized := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_web_kit_initialized;
|
|
|
|
on_browser_created := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_browser_created;
|
|
|
|
on_browser_destroyed := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_browser_destroyed;
|
|
|
|
get_load_handler := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_get_load_handler;
|
|
|
|
on_context_created := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_context_created;
|
|
|
|
on_context_released := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_context_released;
|
|
|
|
on_uncaught_exception := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_uncaught_exception;
|
|
|
|
on_focused_node_changed := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_focused_node_changed;
|
|
|
|
on_process_message_received := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_process_message_received;
|
2017-03-22 16:22:11 +02:00
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
function TCefRenderProcessHandlerOwn.GetLoadHandler: ICefLoadHandler;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
function TCefRenderProcessHandlerOwn.OnProcessMessageReceived(const browser : ICefBrowser;
|
2019-06-16 10:31:13 +02:00
|
|
|
const frame : ICefFrame;
|
2017-11-25 20:04:15 +02:00
|
|
|
sourceProcess : TCefProcessId;
|
|
|
|
const aMessage : ICefProcessMessage): Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
Result := False;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
|
|
|
|
// TCefCustomRenderProcessHandler
|
|
|
|
|
|
|
|
|
2019-11-09 00:15:53 +02:00
|
|
|
constructor TCefCustomRenderProcessHandler.Create(const aCefApp : TCefApplicationCore);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2017-11-25 20:04:15 +02:00
|
|
|
inherited Create;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
FCefApp := aCefApp;
|
2018-11-15 20:08:16 +02:00
|
|
|
|
|
|
|
if (FCefApp <> nil) and FCefApp.MustCreateLoadHandler then
|
2020-11-10 16:34:48 +02:00
|
|
|
FLoadHandler := TCustomRenderLoadHandler.Create(FCefApp)
|
|
|
|
else
|
|
|
|
FLoadHandler := nil;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
destructor TCefCustomRenderProcessHandler.Destroy;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2020-11-10 16:02:49 +02:00
|
|
|
RemoveReferences;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
inherited Destroy;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.RemoveReferences;
|
|
|
|
begin
|
|
|
|
if (FLoadHandler <> nil) then
|
|
|
|
FLoadHandler.RemoveReferences;
|
|
|
|
|
|
|
|
FCefApp := nil;
|
|
|
|
FLoadHandler := nil;
|
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnWebKitInitialized;
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnWebKitInitialized;
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnWebKitInitialized', e) then raise;
|
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2019-06-16 10:31:13 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
2019-06-16 10:31:13 +02:00
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnBrowserCreated(browser, extra_info);
|
2018-03-29 20:02:04 +02:00
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnBrowserCreated', e) then raise;
|
|
|
|
end;
|
2017-11-25 20:04:15 +02:00
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnBrowserDestroyed(const browser: ICefBrowser);
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnBrowserDestroyed(browser);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnBrowserDestroyed', e) then raise;
|
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-11-15 20:08:16 +02:00
|
|
|
function TCefCustomRenderProcessHandler.GetLoadHandler: ICefLoadHandler;
|
|
|
|
begin
|
|
|
|
if (FLoadHandler <> nil) then
|
|
|
|
Result := FLoadHandler
|
|
|
|
else
|
|
|
|
Result := inherited GetLoadHandler;
|
|
|
|
end;
|
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser;
|
|
|
|
const frame : ICefFrame;
|
|
|
|
const context : ICefv8Context);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnContextCreated(browser, frame, context);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnContextCreated', e) then raise;
|
|
|
|
end;
|
2017-11-25 20:04:15 +02:00
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnContextReleased(const browser : ICefBrowser;
|
|
|
|
const frame : ICefFrame;
|
|
|
|
const context : ICefv8Context);
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnContextReleased(browser, frame, context);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnContextReleased', e) then raise;
|
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnUncaughtException(const browser : ICefBrowser;
|
|
|
|
const frame : ICefFrame;
|
|
|
|
const context : ICefv8Context;
|
|
|
|
const V8Exception : ICefV8Exception;
|
|
|
|
const stackTrace : ICefV8StackTrace);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnUncaughtException(browser, frame, context, V8Exception, stackTrace);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnUncaughtException', e) then raise;
|
|
|
|
end;
|
2017-11-25 20:04:15 +02:00
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2017-11-25 20:04:15 +02:00
|
|
|
procedure TCefCustomRenderProcessHandler.OnFocusedNodeChanged(const browser : ICefBrowser;
|
|
|
|
const frame : ICefFrame;
|
|
|
|
const node : ICefDomNode);
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnFocusedNodeChanged(browser, frame, node);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnFocusedNodeChanged', e) then raise;
|
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2020-11-10 16:02:49 +02:00
|
|
|
function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser : ICefBrowser;
|
|
|
|
const frame : ICefFrame;
|
|
|
|
sourceProcess : TCefProcessId;
|
|
|
|
const aMessage : ICefProcessMessage): Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2019-06-16 10:31:13 +02:00
|
|
|
Result := inherited OnProcessMessageReceived(browser, frame, sourceProcess, aMessage);
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
try
|
2019-06-16 10:31:13 +02:00
|
|
|
if (FCefApp <> nil) then FCefApp.Internal_OnProcessMessageReceived(browser, frame, sourceProcess, aMessage, Result);
|
2018-03-29 20:02:04 +02:00
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnProcessMessageReceived', e) then raise;
|
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|