1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00
CEF4Delphi/source/uCEFClient.pas

969 lines
32 KiB
ObjectPascal
Raw Normal View History

2017-01-27 18:29:37 +02:00
unit uCEFClient;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
2017-02-05 21:56:46 +02:00
{$I cef.inc}
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
{$MINENUMSIZE 4}
2017-01-27 18:29:37 +02:00
interface
uses
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
2017-01-27 18:29:37 +02:00
type
TCefClientRef = class(TCefBaseRefCountedRef, ICefClient)
protected
2020-05-23 15:00:44 +02:00
procedure GetAudioHandler(var aHandler : ICefAudioHandler); virtual;
2022-05-03 12:43:16 +02:00
procedure GetCommandHandler(var aHandler : ICefCommandHandler); virtual;
2018-03-29 20:02:04 +02:00
procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); virtual;
procedure GetDialogHandler(var aHandler : ICefDialogHandler); virtual;
procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); virtual;
procedure GetDownloadHandler(var aHandler : ICefDownloadHandler); virtual;
procedure GetDragHandler(var aHandler : ICefDragHandler); virtual;
procedure GetFindHandler(var aHandler : ICefFindHandler); virtual;
procedure GetFocusHandler(var aHandler : ICefFocusHandler); virtual;
2021-07-29 16:20:34 +02:00
procedure GetFrameHandler(var aHandler : ICefFrameHandler); virtual;
2022-08-06 12:00:28 +02:00
procedure GetPermissionHandler(var aHandler: ICefPermissionHandler); virtual;
2018-03-29 20:02:04 +02:00
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler); virtual;
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler); virtual;
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler); virtual;
procedure GetLoadHandler(var aHandler : ICefLoadHandler); virtual;
2021-04-18 19:36:20 +02:00
procedure GetPrintHandler(var aHandler : ICefPrintHandler); virtual;
2018-03-29 20:02:04 +02:00
procedure GetRenderHandler(var aHandler : ICefRenderHandler); virtual;
procedure GetRequestHandler(var aHandler : ICefRequestHandler); virtual;
2019-06-16 10:31:13 +02:00
function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; virtual;
procedure RemoveReferences; virtual;
public
class function UnWrap(data: Pointer): ICefClient;
end;
TCefClientOwn = class(TCefBaseRefCountedOwn, ICefClient)
2017-01-27 18:29:37 +02:00
protected
2020-05-23 15:00:44 +02:00
procedure GetAudioHandler(var aHandler : ICefAudioHandler); virtual;
2022-05-03 12:43:16 +02:00
procedure GetCommandHandler(var aHandler : ICefCommandHandler); virtual;
2018-03-29 20:02:04 +02:00
procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); virtual;
procedure GetDialogHandler(var aHandler : ICefDialogHandler); virtual;
procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); virtual;
procedure GetDownloadHandler(var aHandler : ICefDownloadHandler); virtual;
procedure GetDragHandler(var aHandler : ICefDragHandler); virtual;
procedure GetFindHandler(var aHandler : ICefFindHandler); virtual;
procedure GetFocusHandler(var aHandler : ICefFocusHandler); virtual;
2021-07-29 16:20:34 +02:00
procedure GetFrameHandler(var aHandler : ICefFrameHandler); virtual;
2022-08-06 12:00:28 +02:00
procedure GetPermissionHandler(var aHandler: ICefPermissionHandler); virtual;
2018-03-29 20:02:04 +02:00
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler); virtual;
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler); virtual;
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler); virtual;
procedure GetLoadHandler(var aHandler : ICefLoadHandler); virtual;
2021-04-18 19:36:20 +02:00
procedure GetPrintHandler(var aHandler : ICefPrintHandler); virtual;
2018-03-29 20:02:04 +02:00
procedure GetRenderHandler(var aHandler : ICefRenderHandler); virtual;
procedure GetRequestHandler(var aHandler : ICefRequestHandler); virtual;
2019-06-16 10:31:13 +02:00
function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; virtual;
2017-01-27 18:29:37 +02:00
procedure RemoveReferences; virtual;
2017-01-27 18:29:37 +02:00
public
constructor Create; virtual;
end;
TCustomClientHandler = class(TCefClientOwn)
2017-01-27 18:29:37 +02:00
protected
FEvents : Pointer;
2020-05-23 15:00:44 +02:00
FAudioHandler : ICefAudioHandler;
2022-05-03 12:43:16 +02:00
FCommandHandler : ICefCommandHandler;
2017-01-27 18:29:37 +02:00
FLoadHandler : ICefLoadHandler;
FFocusHandler : ICefFocusHandler;
FContextMenuHandler : ICefContextMenuHandler;
FDialogHandler : ICefDialogHandler;
FKeyboardHandler : ICefKeyboardHandler;
FDisplayHandler : ICefDisplayHandler;
FDownloadHandler : ICefDownloadHandler;
FJsDialogHandler : ICefJsDialogHandler;
FLifeSpanHandler : ICefLifeSpanHandler;
FRenderHandler : ICefRenderHandler;
FRequestHandler : ICefRequestHandler;
FDragHandler : ICefDragHandler;
FFindHandler : ICefFindHandler;
2021-04-18 19:36:20 +02:00
FPrintHandler : ICefPrintHandler;
2021-07-29 16:20:34 +02:00
FFrameHandler : ICefFrameHandler;
2022-08-06 12:00:28 +02:00
FPermissionHandler : ICefPermissionHandler;
2017-01-27 18:29:37 +02:00
2020-05-23 15:00:44 +02:00
procedure GetAudioHandler(var aHandler : ICefAudioHandler); override;
2022-05-03 12:43:16 +02:00
procedure GetCommandHandler(var aHandler : ICefCommandHandler); override;
2018-03-29 20:02:04 +02:00
procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); override;
procedure GetDialogHandler(var aHandler : ICefDialogHandler); override;
procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); override;
procedure GetDownloadHandler(var aHandler : ICefDownloadHandler); override;
procedure GetDragHandler(var aHandler : ICefDragHandler); override;
procedure GetFindHandler(var aHandler : ICefFindHandler); override;
procedure GetFocusHandler(var aHandler : ICefFocusHandler); override;
2021-07-29 16:20:34 +02:00
procedure GetFrameHandler(var aHandler : ICefFrameHandler); override;
2022-08-06 12:00:28 +02:00
procedure GetPermissionHandler(var aHandler: ICefPermissionHandler); override;
2018-03-29 20:02:04 +02:00
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler); override;
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler); override;
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler); override;
procedure GetLoadHandler(var aHandler : ICefLoadHandler); override;
2021-04-18 19:36:20 +02:00
procedure GetPrintHandler(var aHandler : ICefPrintHandler); override;
2018-03-29 20:02:04 +02:00
procedure GetRenderHandler(var aHandler : ICefRenderHandler); override;
procedure GetRequestHandler(var aHandler : ICefRequestHandler); override;
2019-06-16 10:31:13 +02:00
function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; override;
procedure InitializeVars;
2017-01-27 18:29:37 +02:00
public
constructor Create(const events: IChromiumEvents; aDevToolsClient : boolean = False); reintroduce; virtual;
procedure BeforeDestruction; override;
procedure RemoveReferences; override;
2017-01-27 18:29:37 +02:00
end;
implementation
uses
2017-02-05 21:56:46 +02:00
{$IFDEF DELPHI16_UP}
2017-01-27 18:29:37 +02:00
System.SysUtils,
2017-02-05 21:56:46 +02:00
{$ELSE}
SysUtils,
{$ENDIF}
2017-01-27 18:29:37 +02:00
uCEFMiscFunctions, uCEFLibFunctions, uCEFProcessMessage, uCEFBrowser, uCEFLoadHandler,
uCEFFocusHandler, uCEFContextMenuHandler, uCEFDialogHandler, uCEFKeyboardHandler,
2018-03-08 12:47:04 +02:00
uCEFDisplayHandler, uCEFDownloadHandler, uCEFJsDialogHandler,
2017-01-27 18:29:37 +02:00
uCEFLifeSpanHandler, uCEFRequestHandler, uCEFRenderHandler, uCEFDragHandler,
2021-04-18 19:36:20 +02:00
uCEFFindHandler, uCEFConstants, uCEFApplicationCore, uCEFFrame, uCEFAudioHandler,
2022-08-06 12:00:28 +02:00
uCEFPrintHandler, uCEFFrameHandler, uCEFCommandHandler, uCEFPermissionHandler;
2017-01-27 18:29:37 +02:00
// ******************************************************
// ****************** TCefClientRef *********************
// ******************************************************
class function TCefClientRef.UnWrap(data: Pointer): ICefClient;
begin
if (data <> nil) then
Result := Create(data) as ICefClient
else
Result := nil;
end;
2020-05-23 15:00:44 +02:00
procedure TCefClientRef.GetAudioHandler(var aHandler : ICefAudioHandler);
begin
aHandler := nil;
end;
2022-05-03 12:43:16 +02:00
procedure TCefClientRef.GetCommandHandler(var aHandler : ICefCommandHandler);
begin
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetContextMenuHandler(var aHandler : ICefContextMenuHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetDialogHandler(var aHandler : ICefDialogHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetDisplayHandler(var aHandler : ICefDisplayHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetDownloadHandler(var aHandler : ICefDownloadHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetDragHandler(var aHandler : ICefDragHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetFindHandler(var aHandler : ICefFindHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetFocusHandler(var aHandler : ICefFocusHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2021-07-29 16:20:34 +02:00
procedure TCefClientRef.GetFrameHandler(var aHandler : ICefFrameHandler);
begin
aHandler := nil;
end;
2022-08-06 12:00:28 +02:00
procedure TCefClientRef.GetPermissionHandler(var aHandler: ICefPermissionHandler);
begin
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetJsdialogHandler(var aHandler : ICefJsDialogHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetKeyboardHandler(var aHandler : ICefKeyboardHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetLoadHandler(var aHandler : ICefLoadHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2021-04-18 19:36:20 +02:00
procedure TCefClientRef.GetPrintHandler(var aHandler : ICefPrintHandler);
begin
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetRenderHandler(var aHandler : ICefRenderHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientRef.GetRequestHandler(var aHandler : ICefRequestHandler);
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
end;
2019-06-16 10:31:13 +02:00
function TCefClientRef.OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean;
begin
Result := False;
end;
procedure TCefClientRef.RemoveReferences;
begin
//
end;
// ******************************************************
// ****************** TCefClientOwn *********************
// ******************************************************
2020-05-23 15:00:44 +02:00
function cef_client_own_get_audio_handler(self: PCefClient): PCefAudioHandler; stdcall;
var
TempObject : TObject;
TempHandler : ICefAudioHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetAudioHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
end;
2022-05-03 12:43:16 +02:00
function cef_client_own_get_command_handler(self: PCefClient): PCefCommandHandler; stdcall;
var
TempObject : TObject;
TempHandler : ICefCommandHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetCommandHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
end;
function cef_client_own_get_context_menu_handler(self: PCefClient): PCefContextMenuHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefContextMenuHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetContextMenuHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_dialog_handler(self: PCefClient): PCefDialogHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefDialogHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetDialogHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_display_handler(self: PCefClient): PCefDisplayHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefDisplayHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetDisplayHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_download_handler(self: PCefClient): PCefDownloadHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefDownloadHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetDownloadHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_drag_handler(self: PCefClient): PCefDragHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefDragHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetDragHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_find_handler(self: PCefClient): PCefFindHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefFindHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetFindHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_focus_handler(self: PCefClient): PCefFocusHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefFocusHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetFocusHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
2021-07-29 16:20:34 +02:00
function cef_client_own_get_frame_handler(self: PCefClient): PCefFrameHandler; stdcall;
var
TempObject : TObject;
TempHandler : ICefFrameHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetFrameHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
end;
function cef_client_own_get_jsdialog_handler(self: PCefClient): PCefJsDialogHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefJsDialogHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetJsdialogHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_keyboard_handler(self: PCefClient): PCefKeyboardHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefKeyboardHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetKeyboardHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_life_span_handler(self: PCefClient): PCefLifeSpanHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefLifeSpanHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetLifeSpanHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_load_handler(self: PCefClient): PCefLoadHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefLoadHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetLoadHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
2021-04-18 19:36:20 +02:00
function cef_client_own_get_render_handler(self: PCefClient): PCefRenderHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefRenderHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetRenderHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
function cef_client_own_get_request_handler(self: PCefClient): PCefRequestHandler; stdcall;
2018-03-29 20:02:04 +02:00
var
TempObject : TObject;
TempHandler : ICefRequestHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TCefClientOwn(TempObject).GetRequestHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
2017-01-27 18:29:37 +02:00
end;
2021-04-18 19:36:20 +02:00
function cef_client_own_get_print_handler(self: PCefClient): PCefPrintHandler; stdcall;
var
TempObject : TObject;
TempHandler : ICefPrintHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TempHandler := nil;
TCefClientOwn(TempObject).GetPrintHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
end;
2022-08-06 12:00:28 +02:00
function cef_client_own_get_permission_handler(self: PCefClient): PCefPermissionHandler; stdcall;
var
TempObject : TObject;
TempHandler : ICefPermissionHandler;
begin
Result := nil;
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
try
TempHandler := nil;
TCefClientOwn(TempObject).GetPermissionHandler(TempHandler);
if (TempHandler <> nil) then Result := TempHandler.Wrap;
finally
TempHandler := nil;
end;
end;
2018-03-29 20:02:04 +02:00
function cef_client_own_on_process_message_received(self : PCefClient;
browser : PCefBrowser;
2019-06-16 10:31:13 +02:00
frame : PCefFrame;
2018-03-29 20:02:04 +02:00
source_process : TCefProcessId;
message_ : PCefProcessMessage): Integer; stdcall;
var
TempObject : TObject;
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
Result := Ord(False);
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefClientOwn) then
Result := Ord(TCefClientOwn(TempObject).OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser),
2019-06-16 10:31:13 +02:00
TCefFrameRef.UnWrap(frame),
2018-03-29 20:02:04 +02:00
source_process,
TCefProcessMessageRef.UnWrap(message_)));
2017-01-27 18:29:37 +02:00
end;
constructor TCefClientOwn.Create;
begin
inherited CreateData(SizeOf(TCefClient));
with PCefClient(FData)^ do
begin
2020-05-23 15:00:44 +02:00
get_audio_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_audio_handler;
2022-05-03 12:43:16 +02:00
get_command_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_command_handler;
get_context_menu_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_context_menu_handler;
get_dialog_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_dialog_handler;
get_display_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_display_handler;
get_download_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_download_handler;
get_drag_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_drag_handler;
get_find_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_find_handler;
get_focus_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_focus_handler;
2021-07-29 16:20:34 +02:00
get_frame_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_frame_handler;
2022-08-06 12:00:28 +02:00
get_permission_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_permission_handler;
get_jsdialog_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_jsdialog_handler;
get_keyboard_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_keyboard_handler;
get_life_span_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_life_span_handler;
get_load_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_load_handler;
2021-04-18 19:36:20 +02:00
get_print_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_print_handler;
get_render_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_render_handler;
get_request_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_request_handler;
on_process_message_received := {$IFDEF FPC}@{$ENDIF}cef_client_own_on_process_message_received;
2017-01-27 18:29:37 +02:00
end;
end;
2020-05-23 15:00:44 +02:00
procedure TCefClientOwn.GetAudioHandler(var aHandler : ICefAudioHandler);
begin
aHandler := nil;
end;
2022-05-03 12:43:16 +02:00
procedure TCefClientOwn.GetCommandHandler(var aHandler : ICefCommandHandler);
begin
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetContextMenuHandler(var aHandler : ICefContextMenuHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetDialogHandler(var aHandler : ICefDialogHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetDisplayHandler(var aHandler : ICefDisplayHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetDownloadHandler(var aHandler : ICefDownloadHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetDragHandler(var aHandler : ICefDragHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetFindHandler(var aHandler : ICefFindHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetFocusHandler(var aHandler : ICefFocusHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2021-07-29 16:20:34 +02:00
procedure TCefClientOwn.GetFrameHandler(var aHandler : ICefFrameHandler);
begin
aHandler := nil;
end;
2022-08-06 12:00:28 +02:00
procedure TCefClientOwn.GetPermissionHandler(var aHandler: ICefPermissionHandler);
begin
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetJsdialogHandler(var aHandler : ICefJsDialogHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetKeyboardHandler(var aHandler : ICefKeyboardHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetLoadHandler(var aHandler : ICefLoadHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2021-04-18 19:36:20 +02:00
procedure TCefClientOwn.GetPrintHandler(var aHandler : ICefPrintHandler);
begin
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetRenderHandler(var aHandler : ICefRenderHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefClientOwn.GetRequestHandler(var aHandler : ICefRequestHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
function TCefClientOwn.OnProcessMessageReceived(const browser : ICefBrowser;
2019-06-16 10:31:13 +02:00
const frame : ICefFrame;
2018-03-29 20:02:04 +02:00
sourceProcess : TCefProcessId;
const message_ : ICefProcessMessage): Boolean;
2017-01-27 18:29:37 +02:00
begin
Result := False;
end;
procedure TCefClientOwn.RemoveReferences;
begin
//
end;
// ******************************************************
// *************** TCustomClientHandler *****************
// ******************************************************
2017-01-27 18:29:37 +02:00
constructor TCustomClientHandler.Create(const events : IChromiumEvents; aDevToolsClient : boolean);
2017-01-27 18:29:37 +02:00
begin
inherited Create;
InitializeVars;
FEvents := Pointer(events);
if (events <> nil) then
begin
if aDevToolsClient then
begin
if events.MustCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(events);
end
else
begin
2020-05-23 15:00:44 +02:00
if events.MustCreateAudioHandler then FAudioHandler := TCustomAudioHandler.Create(events);
2022-05-03 12:43:16 +02:00
if events.MustCreateCommandHandler then FCommandHandler := TCustomCommandHandler.Create(events);
if events.MustCreateLoadHandler then FLoadHandler := TCustomLoadHandler.Create(events);
if events.MustCreateFocusHandler then FFocusHandler := TCustomFocusHandler.Create(events);
if events.MustCreateContextMenuHandler then FContextMenuHandler := TCustomContextMenuHandler.Create(events);
if events.MustCreateDialogHandler then FDialogHandler := TCustomDialogHandler.Create(events);
if events.MustCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(events);
if events.MustCreateDisplayHandler then FDisplayHandler := TCustomDisplayHandler.Create(events);
if events.MustCreateDownloadHandler then FDownloadHandler := TCustomDownloadHandler.Create(events);
if events.MustCreateJsDialogHandler then FJsDialogHandler := TCustomJsDialogHandler.Create(events);
if events.MustCreateLifeSpanHandler then FLifeSpanHandler := TCustomLifeSpanHandler.Create(events);
if events.MustCreateRenderHandler then FRenderHandler := TCustomRenderHandler.Create(events);
if events.MustCreateRequestHandler then FRequestHandler := TCustomRequestHandler.Create(events);
if events.MustCreateDragHandler then FDragHandler := TCustomDragHandler.Create(events);
if events.MustCreateFindHandler then FFindHandler := TCustomFindHandler.Create(events);
2021-04-18 19:36:20 +02:00
if events.MustCreatePrintHandler then FPrintHandler := TCustomPrintHandler.Create(events);
2021-07-29 16:20:34 +02:00
if events.MustCreateFrameHandler then FFrameHandler := TCustomFrameHandler.Create(events);
2022-08-06 12:00:28 +02:00
if events.MustCreatePermissionHandler then FPermissionHandler := TCustomPermissionHandler.Create(events);
end;
end;
2017-01-27 18:29:37 +02:00
end;
procedure TCustomClientHandler.BeforeDestruction;
begin
InitializeVars;
inherited BeforeDestruction;
end;
procedure TCustomClientHandler.RemoveReferences;
begin
FEvents := nil;
2020-05-23 15:00:44 +02:00
if (FAudioHandler <> nil) then FAudioHandler.RemoveReferences;
2022-05-03 12:43:16 +02:00
if (FCommandHandler <> nil) then FCommandHandler.RemoveReferences;
if (FLoadHandler <> nil) then FLoadHandler.RemoveReferences;
if (FFocusHandler <> nil) then FFocusHandler.RemoveReferences;
if (FContextMenuHandler <> nil) then FContextMenuHandler.RemoveReferences;
if (FDialogHandler <> nil) then FDialogHandler.RemoveReferences;
if (FKeyboardHandler <> nil) then FKeyboardHandler.RemoveReferences;
if (FDisplayHandler <> nil) then FDisplayHandler.RemoveReferences;
if (FDownloadHandler <> nil) then FDownloadHandler.RemoveReferences;
if (FJsDialogHandler <> nil) then FJsDialogHandler.RemoveReferences;
if (FLifeSpanHandler <> nil) then FLifeSpanHandler.RemoveReferences;
if (FRequestHandler <> nil) then FRequestHandler.RemoveReferences;
if (FRenderHandler <> nil) then FRenderHandler.RemoveReferences;
if (FDragHandler <> nil) then FDragHandler.RemoveReferences;
if (FFindHandler <> nil) then FFindHandler.RemoveReferences;
2021-04-18 19:36:20 +02:00
if (FPrintHandler <> nil) then FPrintHandler.RemoveReferences;
2021-07-29 16:20:34 +02:00
if (FFrameHandler <> nil) then FFrameHandler.RemoveReferences;
2022-08-06 12:00:28 +02:00
if (FPermissionHandler <> nil) then FPermissionHandler.RemoveReferences;
end;
procedure TCustomClientHandler.InitializeVars;
2017-01-27 18:29:37 +02:00
begin
2020-05-23 15:00:44 +02:00
FAudioHandler := nil;
2022-05-03 12:43:16 +02:00
FCommandHandler := nil;
2017-01-27 18:29:37 +02:00
FLoadHandler := nil;
FFocusHandler := nil;
FContextMenuHandler := nil;
FDialogHandler := nil;
FKeyboardHandler := nil;
FDisplayHandler := nil;
FDownloadHandler := nil;
FJsDialogHandler := nil;
FLifeSpanHandler := nil;
FRequestHandler := nil;
FRenderHandler := nil;
FDragHandler := nil;
FFindHandler := nil;
2021-04-18 19:36:20 +02:00
FPrintHandler := nil;
2021-07-29 16:20:34 +02:00
FFrameHandler := nil;
2022-08-06 12:00:28 +02:00
FPermissionHandler := nil;
FEvents := nil;
2017-01-27 18:29:37 +02:00
end;
2020-05-23 15:00:44 +02:00
procedure TCustomClientHandler.GetAudioHandler(var aHandler : ICefAudioHandler);
begin
if (FAudioHandler <> nil) then
aHandler := FAudioHandler
else
aHandler := nil;
end;
2022-05-03 12:43:16 +02:00
procedure TCustomClientHandler.GetCommandHandler(var aHandler : ICefCommandHandler);
begin
if (FCommandHandler <> nil) then
aHandler := FCommandHandler
else
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetContextMenuHandler(var aHandler : ICefContextMenuHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FContextMenuHandler <> nil) then
aHandler := FContextMenuHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetDialogHandler(var aHandler : ICefDialogHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FDialogHandler <> nil) then
aHandler := FDialogHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetDisplayHandler(var aHandler : ICefDisplayHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FDisplayHandler <> nil) then
aHandler := FDisplayHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetDownloadHandler(var aHandler : ICefDownloadHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FDownloadHandler <> nil) then
aHandler := FDownloadHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetDragHandler(var aHandler : ICefDragHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FDragHandler <> nil) then
aHandler := FDragHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetFindHandler(var aHandler : ICefFindHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FFindHandler <> nil) then
aHandler := FFindHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetFocusHandler(var aHandler : ICefFocusHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FFocusHandler <> nil) then
aHandler := FFocusHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2021-07-29 16:20:34 +02:00
procedure TCustomClientHandler.GetFrameHandler(var aHandler : ICefFrameHandler);
begin
if (FFrameHandler <> nil) then
aHandler := FFrameHandler
else
aHandler := nil;
end;
2022-08-06 12:00:28 +02:00
procedure TCustomClientHandler.GetPermissionHandler(var aHandler: ICefPermissionHandler);
begin
if (FPermissionHandler <> nil) then
aHandler := FPermissionHandler
else
aHandler := nil;
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetJsdialogHandler(var aHandler : ICefJsDialogHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FJsDialogHandler <> nil) then
aHandler := FJsDialogHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetKeyboardHandler(var aHandler : ICefKeyboardHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FKeyboardHandler <> nil) then
aHandler := FKeyboardHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FLifeSpanHandler <> nil) then
aHandler := FLifeSpanHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetLoadHandler(var aHandler : ICefLoadHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FLoadHandler <> nil) then
aHandler := FLoadHandler
else
aHandler := nil;
2021-04-18 19:36:20 +02:00
end;
procedure TCustomClientHandler.GetPrintHandler(var aHandler : ICefPrintHandler);
begin
if (FPrintHandler <> nil) then
aHandler := FPrintHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetRenderHandler(var aHandler : ICefRenderHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FRenderHandler <> nil) then
aHandler := FRenderHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
2018-03-29 20:02:04 +02:00
procedure TCustomClientHandler.GetRequestHandler(var aHandler : ICefRequestHandler);
2017-01-27 18:29:37 +02:00
begin
2018-03-29 20:02:04 +02:00
if (FRequestHandler <> nil) then
aHandler := FRequestHandler
else
aHandler := nil;
2017-01-27 18:29:37 +02:00
end;
function TCustomClientHandler.OnProcessMessageReceived(const browser : ICefBrowser;
2019-06-16 10:31:13 +02:00
const frame : ICefFrame;
sourceProcess : TCefProcessId;
2018-03-29 20:02:04 +02:00
const message_ : ICefProcessMessage): Boolean;
2017-01-27 18:29:37 +02:00
begin
if (FEvents <> nil) then
2019-06-16 10:31:13 +02:00
Result := IChromiumEvents(FEvents).doOnProcessMessageReceived(browser, frame, sourceProcess, message_)
2017-01-27 18:29:37 +02:00
else
2019-06-16 10:31:13 +02:00
Result := inherited OnProcessMessageReceived(browser, frame, sourceProcess, message_);
2017-01-27 18:29:37 +02:00
end;
end.