2017-01-27 17:29:37 +01:00
|
|
|
|
// ************************************************************************
|
|
|
|
|
// ***************************** CEF4Delphi *******************************
|
|
|
|
|
// ************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
|
|
|
|
// 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
|
|
|
|
|
//
|
|
|
|
|
// Copyright <20> 2017 Salvador D<>az Fau. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// ************************************************************************
|
|
|
|
|
// ************ 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 uCEFClient;
|
|
|
|
|
|
|
|
|
|
{$IFNDEF CPUX64}
|
|
|
|
|
{$ALIGN ON}
|
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$I cef.inc}
|
|
|
|
|
|
2017-01-27 17:29:37 +01:00
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$IFDEF DELPHI16_UP}
|
2017-01-27 17:29:37 +01:00
|
|
|
|
WinApi.Windows,
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$ELSE}
|
|
|
|
|
Windows,
|
|
|
|
|
{$ENDIF}
|
2017-03-16 19:09:42 +01:00
|
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
|
|
|
|
|
type
|
2017-06-11 17:48:20 +02:00
|
|
|
|
TCefClientRef = class(TCefBaseRefCountedRef, ICefClient)
|
|
|
|
|
protected
|
|
|
|
|
function GetContextMenuHandler: ICefContextMenuHandler; virtual;
|
|
|
|
|
function GetDialogHandler: ICefDialogHandler; virtual;
|
|
|
|
|
function GetDisplayHandler: ICefDisplayHandler; virtual;
|
|
|
|
|
function GetDownloadHandler: ICefDownloadHandler; virtual;
|
|
|
|
|
function GetDragHandler: ICefDragHandler; virtual;
|
|
|
|
|
function GetFindHandler: ICefFindHandler; virtual;
|
|
|
|
|
function GetFocusHandler: ICefFocusHandler; virtual;
|
|
|
|
|
function GetGeolocationHandler: ICefGeolocationHandler; virtual;
|
|
|
|
|
function GetJsdialogHandler: ICefJsdialogHandler; virtual;
|
|
|
|
|
function GetKeyboardHandler: ICefKeyboardHandler; virtual;
|
|
|
|
|
function GetLifeSpanHandler: ICefLifeSpanHandler; virtual;
|
|
|
|
|
function GetRenderHandler: ICefRenderHandler; virtual;
|
|
|
|
|
function GetLoadHandler: ICefLoadHandler; virtual;
|
|
|
|
|
function GetRequestHandler: ICefRequestHandler; virtual;
|
|
|
|
|
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; virtual;
|
|
|
|
|
|
2017-12-27 14:05:33 +01:00
|
|
|
|
procedure InitializeVars; virtual;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
public
|
|
|
|
|
class function UnWrap(data: Pointer): ICefClient;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-03-16 19:09:42 +01:00
|
|
|
|
TCefClientOwn = class(TCefBaseRefCountedOwn, ICefClient)
|
2017-01-27 17:29:37 +01:00
|
|
|
|
protected
|
|
|
|
|
function GetContextMenuHandler: ICefContextMenuHandler; virtual;
|
|
|
|
|
function GetDialogHandler: ICefDialogHandler; virtual;
|
|
|
|
|
function GetDisplayHandler: ICefDisplayHandler; virtual;
|
|
|
|
|
function GetDownloadHandler: ICefDownloadHandler; virtual;
|
|
|
|
|
function GetDragHandler: ICefDragHandler; virtual;
|
|
|
|
|
function GetFindHandler: ICefFindHandler; virtual;
|
|
|
|
|
function GetFocusHandler: ICefFocusHandler; virtual;
|
|
|
|
|
function GetGeolocationHandler: ICefGeolocationHandler; virtual;
|
|
|
|
|
function GetJsdialogHandler: ICefJsdialogHandler; virtual;
|
|
|
|
|
function GetKeyboardHandler: ICefKeyboardHandler; virtual;
|
|
|
|
|
function GetLifeSpanHandler: ICefLifeSpanHandler; virtual;
|
|
|
|
|
function GetRenderHandler: ICefRenderHandler; virtual;
|
|
|
|
|
function GetLoadHandler: ICefLoadHandler; virtual;
|
|
|
|
|
function GetRequestHandler: ICefRequestHandler; virtual;
|
|
|
|
|
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; virtual;
|
|
|
|
|
|
2017-12-27 14:05:33 +01:00
|
|
|
|
procedure InitializeVars; virtual;
|
|
|
|
|
|
2017-01-27 17:29:37 +01:00
|
|
|
|
public
|
|
|
|
|
constructor Create; virtual;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
TCustomClientHandler = class(TCefClientOwn)
|
2017-01-27 17:29:37 +01:00
|
|
|
|
protected
|
|
|
|
|
FEvents : IChromiumEvents;
|
|
|
|
|
FLoadHandler : ICefLoadHandler;
|
|
|
|
|
FFocusHandler : ICefFocusHandler;
|
|
|
|
|
FContextMenuHandler : ICefContextMenuHandler;
|
|
|
|
|
FDialogHandler : ICefDialogHandler;
|
|
|
|
|
FKeyboardHandler : ICefKeyboardHandler;
|
|
|
|
|
FDisplayHandler : ICefDisplayHandler;
|
|
|
|
|
FDownloadHandler : ICefDownloadHandler;
|
|
|
|
|
FGeolocationHandler : ICefGeolocationHandler;
|
|
|
|
|
FJsDialogHandler : ICefJsDialogHandler;
|
|
|
|
|
FLifeSpanHandler : ICefLifeSpanHandler;
|
|
|
|
|
FRenderHandler : ICefRenderHandler;
|
|
|
|
|
FRequestHandler : ICefRequestHandler;
|
|
|
|
|
FDragHandler : ICefDragHandler;
|
|
|
|
|
FFindHandler : ICefFindHandler;
|
|
|
|
|
|
2017-12-18 19:38:56 +01:00
|
|
|
|
function GetContextMenuHandler: ICefContextMenuHandler; override;
|
|
|
|
|
function GetDialogHandler: ICefDialogHandler; override;
|
|
|
|
|
function GetDisplayHandler: ICefDisplayHandler; override;
|
|
|
|
|
function GetDownloadHandler: ICefDownloadHandler; override;
|
|
|
|
|
function GetDragHandler: ICefDragHandler; override;
|
|
|
|
|
function GetFindHandler: ICefFindHandler; override;
|
|
|
|
|
function GetFocusHandler: ICefFocusHandler; override;
|
|
|
|
|
function GetGeolocationHandler: ICefGeolocationHandler; override;
|
|
|
|
|
function GetJsdialogHandler: ICefJsdialogHandler; override;
|
|
|
|
|
function GetKeyboardHandler: ICefKeyboardHandler; override;
|
|
|
|
|
function GetLifeSpanHandler: ICefLifeSpanHandler; override;
|
|
|
|
|
function GetRenderHandler: ICefRenderHandler; override;
|
|
|
|
|
function GetLoadHandler: ICefLoadHandler; override;
|
|
|
|
|
function GetRequestHandler: ICefRequestHandler; override;
|
|
|
|
|
function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; override;
|
|
|
|
|
|
2017-01-27 17:29:37 +01:00
|
|
|
|
public
|
2017-12-18 19:38:56 +01:00
|
|
|
|
constructor Create(const events: IChromiumEvents;
|
|
|
|
|
aCreateLoadHandler, aCreateFocusHandler, aCreateContextMenuHandler, aCreateDialogHandler,
|
|
|
|
|
aCreateKeyboardHandler, aCreateDisplayHandler, aCreateDownloadHandler, aCreateGeolocationHandler,
|
|
|
|
|
aCreateJsDialogHandler, aCreateLifeSpanHandler, aCreateRenderHandler, aCreateRequestHandler,
|
|
|
|
|
aCreateDragHandler, aCreateFindHandler : boolean); reintroduce; virtual;
|
2017-06-11 17:48:20 +02:00
|
|
|
|
destructor Destroy; override;
|
2017-12-27 14:05:33 +01:00
|
|
|
|
procedure InitializeVars; override;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$IFDEF DELPHI16_UP}
|
2017-01-27 17:29:37 +01:00
|
|
|
|
System.SysUtils,
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$ELSE}
|
|
|
|
|
SysUtils,
|
|
|
|
|
{$ENDIF}
|
2017-01-27 17:29:37 +01:00
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFProcessMessage, uCEFBrowser, uCEFLoadHandler,
|
|
|
|
|
uCEFFocusHandler, uCEFContextMenuHandler, uCEFDialogHandler, uCEFKeyboardHandler,
|
|
|
|
|
uCEFDisplayHandler, uCEFDownloadHandler, uCEFGeolocationHandler, uCEFJsDialogHandler,
|
|
|
|
|
uCEFLifeSpanHandler, uCEFRequestHandler, uCEFRenderHandler, uCEFDragHandler,
|
|
|
|
|
uCEFFindHandler, uCEFConstants, uCEFApplication;
|
|
|
|
|
|
|
|
|
|
|
2017-12-18 19:38:56 +01:00
|
|
|
|
// ******************************************************
|
2017-06-11 17:48:20 +02:00
|
|
|
|
// ****************** TCefClientRef *********************
|
|
|
|
|
// ******************************************************
|
|
|
|
|
|
|
|
|
|
class function TCefClientRef.UnWrap(data: Pointer): ICefClient;
|
|
|
|
|
begin
|
|
|
|
|
if (data <> nil) then
|
|
|
|
|
Result := Create(data) as ICefClient
|
|
|
|
|
else
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetContextMenuHandler: ICefContextMenuHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetDialogHandler: ICefDialogHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetDisplayHandler: ICefDisplayHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetDownloadHandler: ICefDownloadHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetDragHandler: ICefDragHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetFindHandler: ICefFindHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetFocusHandler: ICefFocusHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetGeolocationHandler: ICefGeolocationHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetJsdialogHandler: ICefJsDialogHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetKeyboardHandler: ICefKeyboardHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetLifeSpanHandler: ICefLifeSpanHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetLoadHandler: ICefLoadHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetRenderHandler: ICefRenderHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.GetRequestHandler: ICefRequestHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientRef.OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean;
|
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-12-27 14:05:33 +01:00
|
|
|
|
procedure TCefClientRef.InitializeVars;
|
|
|
|
|
begin
|
|
|
|
|
//
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
|
|
|
|
|
// ******************************************************
|
|
|
|
|
// ****************** TCefClientOwn *********************
|
|
|
|
|
// ******************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function cef_client_own_get_context_menu_handler(self: PCefClient): PCefContextMenuHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetContextMenuHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_dialog_handler(self: PCefClient): PCefDialogHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetDialogHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_display_handler(self: PCefClient): PCefDisplayHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetDisplayHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_download_handler(self: PCefClient): PCefDownloadHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetDownloadHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_drag_handler(self: PCefClient): PCefDragHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetDragHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_find_handler(self: PCefClient): PCefFindHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetFindHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_focus_handler(self: PCefClient): PCefFocusHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetFocusHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_geolocation_handler(self: PCefClient): PCefGeolocationHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetGeolocationHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_jsdialog_handler(self: PCefClient): PCefJsDialogHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetJsdialogHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_keyboard_handler(self: PCefClient): PCefKeyboardHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetKeyboardHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_life_span_handler(self: PCefClient): PCefLifeSpanHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetLifeSpanHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_load_handler(self: PCefClient): PCefLoadHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetLoadHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_get_render_handler(self: PCefClient): PCefRenderHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetRenderHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_get_request_handler(self: PCefClient): PCefRequestHandler; stdcall;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := CefGetData(GetRequestHandler);
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function cef_client_own_on_process_message_received(self: PCefClient; browser: PCefBrowser;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
source_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall;
|
|
|
|
|
begin
|
|
|
|
|
with TCefClientOwn(CefGetObject(self)) do
|
|
|
|
|
Result := Ord(OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser), source_process, TCefProcessMessageRef.UnWrap(message)));
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
constructor TCefClientOwn.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited CreateData(SizeOf(TCefClient));
|
|
|
|
|
|
|
|
|
|
with PCefClient(FData)^ do
|
|
|
|
|
begin
|
2017-06-11 17:48:20 +02:00
|
|
|
|
get_context_menu_handler := cef_client_own_get_context_menu_handler;
|
|
|
|
|
get_dialog_handler := cef_client_own_get_dialog_handler;
|
|
|
|
|
get_display_handler := cef_client_own_get_display_handler;
|
|
|
|
|
get_download_handler := cef_client_own_get_download_handler;
|
|
|
|
|
get_drag_handler := cef_client_own_get_drag_handler;
|
|
|
|
|
get_find_handler := cef_client_own_get_find_handler;
|
|
|
|
|
get_focus_handler := cef_client_own_get_focus_handler;
|
|
|
|
|
get_geolocation_handler := cef_client_own_get_geolocation_handler;
|
|
|
|
|
get_jsdialog_handler := cef_client_own_get_jsdialog_handler;
|
|
|
|
|
get_keyboard_handler := cef_client_own_get_keyboard_handler;
|
|
|
|
|
get_life_span_handler := cef_client_own_get_life_span_handler;
|
|
|
|
|
get_load_handler := cef_client_own_get_load_handler;
|
|
|
|
|
get_render_handler := cef_client_own_get_get_render_handler;
|
|
|
|
|
get_request_handler := cef_client_own_get_request_handler;
|
|
|
|
|
on_process_message_received := cef_client_own_on_process_message_received;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetContextMenuHandler: ICefContextMenuHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetDialogHandler: ICefDialogHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetDisplayHandler: ICefDisplayHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetDownloadHandler: ICefDownloadHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetDragHandler: ICefDragHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetFindHandler: ICefFindHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetFocusHandler: ICefFocusHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetGeolocationHandler: ICefGeolocationHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetJsdialogHandler: ICefJsDialogHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetKeyboardHandler: ICefKeyboardHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetLifeSpanHandler: ICefLifeSpanHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetLoadHandler: ICefLoadHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetRenderHandler: ICefRenderHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.GetRequestHandler: ICefRequestHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefClientOwn.OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean;
|
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-12-27 14:05:33 +01:00
|
|
|
|
procedure TCefClientOwn.InitializeVars;
|
|
|
|
|
begin
|
|
|
|
|
//
|
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
|
|
|
|
|
// ******************************************************
|
|
|
|
|
// *************** TCustomClientHandler *****************
|
|
|
|
|
// ******************************************************
|
|
|
|
|
|
2017-01-27 17:29:37 +01:00
|
|
|
|
|
2017-12-18 19:38:56 +01:00
|
|
|
|
constructor TCustomClientHandler.Create(const events : IChromiumEvents;
|
|
|
|
|
aCreateLoadHandler : boolean;
|
|
|
|
|
aCreateFocusHandler : boolean;
|
|
|
|
|
aCreateContextMenuHandler : boolean;
|
|
|
|
|
aCreateDialogHandler : boolean;
|
|
|
|
|
aCreateKeyboardHandler : boolean;
|
|
|
|
|
aCreateDisplayHandler : boolean;
|
|
|
|
|
aCreateDownloadHandler : boolean;
|
|
|
|
|
aCreateGeolocationHandler : boolean;
|
|
|
|
|
aCreateJsDialogHandler : boolean;
|
|
|
|
|
aCreateLifeSpanHandler : boolean;
|
|
|
|
|
aCreateRenderHandler : boolean;
|
|
|
|
|
aCreateRequestHandler : boolean;
|
|
|
|
|
aCreateDragHandler : boolean;
|
|
|
|
|
aCreateFindHandler : boolean);
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
inherited Create;
|
|
|
|
|
|
2017-12-27 14:05:33 +01:00
|
|
|
|
InitializeVars;
|
2017-12-18 19:38:56 +01:00
|
|
|
|
|
|
|
|
|
FEvents := events;
|
|
|
|
|
|
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
|
begin
|
|
|
|
|
if aCreateLoadHandler then FLoadHandler := TCustomLoadHandler.Create(FEvents);
|
|
|
|
|
if aCreateFocusHandler then FFocusHandler := TCustomFocusHandler.Create(FEvents);
|
|
|
|
|
if aCreateContextMenuHandler then FContextMenuHandler := TCustomContextMenuHandler.Create(FEvents);
|
|
|
|
|
if aCreateDialogHandler then FDialogHandler := TCustomDialogHandler.Create(FEvents);
|
|
|
|
|
if aCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(FEvents);
|
|
|
|
|
if aCreateDisplayHandler then FDisplayHandler := TCustomDisplayHandler.Create(FEvents);
|
|
|
|
|
if aCreateDownloadHandler then FDownloadHandler := TCustomDownloadHandler.Create(FEvents);
|
|
|
|
|
if aCreateGeolocationHandler then FGeolocationHandler := TCustomGeolocationHandler.Create(FEvents);
|
|
|
|
|
if aCreateJsDialogHandler then FJsDialogHandler := TCustomJsDialogHandler.Create(FEvents);
|
|
|
|
|
if aCreateLifeSpanHandler then FLifeSpanHandler := TCustomLifeSpanHandler.Create(FEvents);
|
|
|
|
|
if aCreateRenderHandler then FRenderHandler := TCustomRenderHandler.Create(FEvents);
|
|
|
|
|
if aCreateRequestHandler then FRequestHandler := TCustomRequestHandler.Create(FEvents);
|
|
|
|
|
if aCreateDragHandler then FDragHandler := TCustomDragHandler.Create(FEvents);
|
|
|
|
|
if aCreateFindHandler then FFindHandler := TCustomFindHandler.Create(FEvents);
|
|
|
|
|
end;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
destructor TCustomClientHandler.Destroy;
|
2017-12-18 19:38:56 +01:00
|
|
|
|
begin
|
2017-12-27 14:05:33 +01:00
|
|
|
|
InitializeVars;
|
2017-12-18 19:38:56 +01:00
|
|
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
|
end;
|
|
|
|
|
|
2017-12-27 14:05:33 +01:00
|
|
|
|
procedure TCustomClientHandler.InitializeVars;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
begin
|
|
|
|
|
FLoadHandler := nil;
|
|
|
|
|
FFocusHandler := nil;
|
|
|
|
|
FContextMenuHandler := nil;
|
|
|
|
|
FDialogHandler := nil;
|
|
|
|
|
FKeyboardHandler := nil;
|
|
|
|
|
FDisplayHandler := nil;
|
|
|
|
|
FDownloadHandler := nil;
|
|
|
|
|
FGeolocationHandler := nil;
|
|
|
|
|
FJsDialogHandler := nil;
|
|
|
|
|
FLifeSpanHandler := nil;
|
|
|
|
|
FRequestHandler := nil;
|
|
|
|
|
FRenderHandler := nil;
|
|
|
|
|
FDragHandler := nil;
|
|
|
|
|
FFindHandler := nil;
|
2017-09-08 17:44:32 +02:00
|
|
|
|
FEvents := nil;
|
2017-01-27 17:29:37 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetContextMenuHandler: ICefContextMenuHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FContextMenuHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetDialogHandler: ICefDialogHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FDialogHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetDisplayHandler: ICefDisplayHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FDisplayHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetDownloadHandler: ICefDownloadHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FDownloadHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetDragHandler: ICefDragHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FDragHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetFindHandler: ICefFindHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FFindHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetFocusHandler: ICefFocusHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FFocusHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetGeolocationHandler: ICefGeolocationHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FGeolocationHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetJsdialogHandler: ICefJsDialogHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FJsDialogHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetKeyboardHandler: ICefKeyboardHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FKeyboardHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetLifeSpanHandler: ICefLifeSpanHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FLifeSpanHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetLoadHandler: ICefLoadHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FLoadHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetRenderHandler: ICefRenderHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FRenderHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.GetRequestHandler: ICefRequestHandler;
|
|
|
|
|
begin
|
|
|
|
|
Result := FRequestHandler;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCustomClientHandler.OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean;
|
|
|
|
|
begin
|
2017-12-18 19:38:56 +01:00
|
|
|
|
if (FEvents <> nil) then
|
2017-01-27 17:29:37 +01:00
|
|
|
|
Result := FEvents.doOnProcessMessageReceived(browser, sourceProcess, message)
|
|
|
|
|
else
|
|
|
|
|
Result := False;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|