2017-01-27 17:37:51 +02:00
|
|
|
unit uCEFDisplayHandler;
|
|
|
|
|
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-02-05 21:56:46 +02:00
|
|
|
{$IFDEF DELPHI16_UP}
|
2017-01-27 17:37:51 +02:00
|
|
|
System.Classes,
|
2017-02-05 21:56:46 +02:00
|
|
|
{$ELSE}
|
|
|
|
Classes,
|
|
|
|
{$ENDIF}
|
2017-03-16 20:09:42 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
type
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Event handler related to browser display state.
|
|
|
|
/// The functions of this interface will be called on the UI thread.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_display_handler_capi.h">CEF source file: /include/capi/cef_display_handler_capi.h (cef_display_handler_t)</see></para>
|
|
|
|
/// </remarks>
|
2017-03-16 20:09:42 +02:00
|
|
|
TCefDisplayHandlerOwn = class(TCefBaseRefCountedOwn, ICefDisplayHandler)
|
2017-01-27 17:37:51 +02:00
|
|
|
protected
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when a frame's address has changed.
|
|
|
|
/// </summary>
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the page title changes.
|
|
|
|
/// </summary>
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure OnTitleChange(const browser: ICefBrowser; const title: ustring); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the page icon changes.
|
|
|
|
/// </summary>
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when web content in the page has toggled fullscreen mode. If
|
|
|
|
/// |fullscreen| is true (1) the content will automatically be sized to fill
|
|
|
|
/// the browser content area. If |fullscreen| is false (0) the content will
|
2024-09-03 17:26:03 +02:00
|
|
|
/// automatically return to its original size and position. With Alloy style
|
|
|
|
/// the client is responsible for triggering the fullscreen transition (for
|
|
|
|
/// example, by calling ICefWindow.SetFullscreen when using Views). With
|
|
|
|
/// Chrome style the fullscreen transition will be triggered automatically.
|
|
|
|
/// The ICefWindowDelegate.OnWindowFullscreenTransition function will be
|
|
|
|
/// called during the fullscreen transition for notification purposes.
|
2023-09-30 20:04:38 +02:00
|
|
|
/// </summary>
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the browser is about to display a tooltip. |text| contains the
|
|
|
|
/// text that will be displayed in the tooltip. To handle the display of the
|
|
|
|
/// tooltip yourself return true (1). Otherwise, you can optionally modify
|
|
|
|
/// |text| and then return false (0) to allow the browser to display the
|
|
|
|
/// tooltip. When window rendering is disabled the application is responsible
|
|
|
|
/// for drawing tooltips and the return value is ignored.
|
|
|
|
/// </summary>
|
2017-01-27 17:37:51 +02:00
|
|
|
function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the browser receives a status message. |value| contains the
|
|
|
|
/// text that will be displayed in the status message.
|
|
|
|
/// </summary>
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called to display a console message. Return true (1) to stop the message
|
|
|
|
/// from being output to the console.
|
|
|
|
/// </summary>
|
2018-03-29 20:02:04 +02:00
|
|
|
function OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean; virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when auto-resize is enabled via
|
|
|
|
/// ICefBrowserHost.SetAutoResizeEnabled and the contents have auto-
|
|
|
|
/// resized. |new_size| will be the desired size in view coordinates. Return
|
|
|
|
/// true (1) if the resize was handled or false (0) for default handling.
|
|
|
|
/// </summary>
|
2017-10-26 13:23:13 +02:00
|
|
|
function OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the overall page loading progress has changed. |progress|
|
|
|
|
/// ranges from 0.0 to 1.0.
|
|
|
|
/// </summary>
|
2018-04-20 12:45:06 +02:00
|
|
|
procedure OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
|
|
|
/// |custom_cursor_info| will be populated with the custom cursor information.
|
|
|
|
/// Return true (1) if the cursor change was handled or false (0) for default
|
|
|
|
/// handling.
|
|
|
|
/// </summary>
|
2021-01-26 19:26:24 +02:00
|
|
|
procedure OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the browser's access to an audio and/or video source has
|
|
|
|
/// changed.
|
|
|
|
/// </summary>
|
2022-08-06 12:00:28 +02:00
|
|
|
procedure OnMediaAccessChange(const browser: ICefBrowser; has_video_access, has_audio_access: boolean); virtual;
|
2023-09-30 20:04:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Custom procedure to clear all references.
|
|
|
|
/// </summary>
|
2018-02-03 18:52:48 +02:00
|
|
|
procedure RemoveReferences; virtual;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
public
|
|
|
|
constructor Create; virtual;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TCustomDisplayHandler = class(TCefDisplayHandlerOwn)
|
|
|
|
protected
|
2018-02-03 18:52:48 +02:00
|
|
|
FEvents : Pointer;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); override;
|
|
|
|
procedure OnTitleChange(const browser: ICefBrowser; const title: ustring); override;
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); override;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); override;
|
|
|
|
function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; override;
|
|
|
|
procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring); override;
|
2018-03-29 20:02:04 +02:00
|
|
|
function OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean; override;
|
2017-10-26 13:23:13 +02:00
|
|
|
function OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; override;
|
2018-04-20 12:45:06 +02:00
|
|
|
procedure OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); override;
|
2021-01-26 19:26:24 +02:00
|
|
|
procedure OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); override;
|
2022-08-06 12:00:28 +02:00
|
|
|
procedure OnMediaAccessChange(const browser: ICefBrowser; has_video_access, has_audio_access: boolean); override;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2018-02-03 18:52:48 +02:00
|
|
|
procedure RemoveReferences; override;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
public
|
2019-06-19 16:53:26 +02:00
|
|
|
constructor Create(const events : IChromiumEvents); reintroduce; virtual;
|
2017-06-11 17:48:20 +02:00
|
|
|
destructor Destroy; override;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2018-02-03 18:52:48 +02:00
|
|
|
{$IFDEF DELPHI16_UP}
|
|
|
|
System.SysUtils,
|
|
|
|
{$ELSE}
|
|
|
|
SysUtils,
|
|
|
|
{$ENDIF}
|
2018-03-29 20:02:04 +02:00
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFStringList;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure cef_display_handler_on_address_change( self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
frame : PCefFrame;
|
|
|
|
const url : PCefString); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnAddressChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TCefFrameRef.UnWrap(frame),
|
|
|
|
CefString(url));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure cef_display_handler_on_title_change( self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
const title : PCefString); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnTitleChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
CefString(title));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-02-26 19:40:51 +02:00
|
|
|
procedure cef_display_handler_on_favicon_urlchange(self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
icon_urls : TCefStringList); stdcall;
|
2017-01-27 17:37:51 +02:00
|
|
|
var
|
2018-03-29 20:02:04 +02:00
|
|
|
TempSL : TStringList;
|
|
|
|
TempCefSL : ICefStringList;
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-02-26 19:40:51 +02:00
|
|
|
TempSL := nil;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
try
|
2018-02-26 19:40:51 +02:00
|
|
|
try
|
2018-03-29 20:02:04 +02:00
|
|
|
TempObject := CefGetObject(self);
|
2018-02-26 19:40:51 +02:00
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
2018-02-26 19:40:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempSL := TStringList.Create;
|
|
|
|
TempCefSL := TCefStringListRef.Create(icon_urls);
|
|
|
|
TempCefSL.CopyToStrings(TempSL);
|
2018-02-26 19:40:51 +02:00
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
TCefDisplayHandlerOwn(TempObject).OnFaviconUrlChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TempSL);
|
|
|
|
end;
|
2018-02-26 19:40:51 +02:00
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('cef_display_handler_on_favicon_urlchange', e) then raise;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
finally
|
2018-02-26 19:40:51 +02:00
|
|
|
if (TempSL <> nil) then FreeAndNil(TempSL);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure cef_display_handler_on_fullscreen_mode_change(self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
fullscreen : Integer); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnFullScreenModeChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
fullscreen <> 0);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
function cef_display_handler_on_tooltip(self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
text : PCefString): Integer; stdcall;
|
2017-01-27 17:37:51 +02:00
|
|
|
var
|
2018-03-29 20:02:04 +02:00
|
|
|
TempText : ustring;
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := Ord(False);
|
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
begin
|
2019-11-24 19:19:49 +02:00
|
|
|
TempText := CefStringClearAndGet(text);
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := Ord(TCefDisplayHandlerOwn(TempObject).OnTooltip(TCefBrowserRef.UnWrap(browser),
|
|
|
|
TempText));
|
2019-11-24 19:19:49 +02:00
|
|
|
if (text <> nil) then text^ := CefStringAlloc(TempText);
|
2018-03-29 20:02:04 +02:00
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure cef_display_handler_on_status_message( self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
const value : PCefString); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnStatusMessage(TCefBrowserRef.UnWrap(browser),
|
|
|
|
CefString(value));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
function cef_display_handler_on_console_message( self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
level : TCefLogSeverity;
|
|
|
|
const message_ : PCefString;
|
|
|
|
const source : PCefString;
|
|
|
|
line : Integer): 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);
|
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
Result := Ord(TCefDisplayHandlerOwn(TempObject).OnConsoleMessage(TCefBrowserRef.UnWrap(browser),
|
|
|
|
level,
|
|
|
|
CefString(message_),
|
|
|
|
CefString(source),
|
|
|
|
line));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
function cef_display_handler_on_auto_resize( self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
const new_size : PCefSize): Integer; stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
2017-10-26 13:23:13 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := Ord(False);
|
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
Result := Ord(TCefDisplayHandlerOwn(TempObject).OnAutoResize(TCefBrowserRef.UnWrap(browser),
|
|
|
|
new_size));
|
2017-10-26 13:23:13 +02:00
|
|
|
end;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2018-04-20 12:45:06 +02:00
|
|
|
procedure cef_display_handler_on_loading_progress_change(self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
progress : double); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
|
|
|
begin
|
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnLoadingProgressChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
progress);
|
|
|
|
end;
|
|
|
|
|
2020-11-19 19:55:17 +02:00
|
|
|
function cef_display_handler_on_cursor_change( self : PCefDisplayHandler;
|
|
|
|
browser : PCefBrowser;
|
|
|
|
cursor : TCefCursorHandle;
|
|
|
|
type_ : TCefCursorType;
|
|
|
|
const custom_cursor_info : PCefCursorInfo): Integer; stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
|
|
|
TempResult : boolean;
|
|
|
|
begin
|
|
|
|
TempResult := False;
|
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnCursorChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
cursor,
|
|
|
|
type_,
|
|
|
|
custom_cursor_info,
|
|
|
|
TempResult);
|
|
|
|
|
|
|
|
Result := Ord(TempResult);
|
|
|
|
end;
|
|
|
|
|
2022-08-06 12:00:28 +02:00
|
|
|
procedure cef_display_handler_on_media_access_change(self: PCefDisplayHandler; browser: PCefBrowser; has_video_access, has_audio_access: integer); stdcall;
|
|
|
|
var
|
|
|
|
TempObject : TObject;
|
|
|
|
begin
|
|
|
|
TempObject := CefGetObject(self);
|
|
|
|
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnMediaAccessChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
has_video_access <> 0,
|
|
|
|
has_audio_access <> 0);
|
|
|
|
end;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
constructor TCefDisplayHandlerOwn.Create;
|
|
|
|
begin
|
|
|
|
inherited CreateData(SizeOf(TCefDisplayHandler));
|
2017-10-26 13:23:13 +02:00
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
with PCefDisplayHandler(FData)^ do
|
2017-10-26 13:23:13 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
on_address_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_address_change;
|
|
|
|
on_title_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_title_change;
|
|
|
|
on_favicon_urlchange := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_favicon_urlchange;
|
|
|
|
on_fullscreen_mode_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_fullscreen_mode_change;
|
|
|
|
on_tooltip := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_tooltip;
|
|
|
|
on_status_message := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_status_message;
|
|
|
|
on_console_message := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_console_message;
|
|
|
|
on_auto_resize := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_auto_resize;
|
|
|
|
on_loading_progress_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_loading_progress_change;
|
2020-11-19 19:55:17 +02:00
|
|
|
on_cursor_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_cursor_change;
|
2022-08-06 12:00:28 +02:00
|
|
|
on_media_access_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_media_access_change;
|
2017-10-26 13:23:13 +02:00
|
|
|
end;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
//
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
function TCefDisplayHandlerOwn.OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean;
|
2017-10-26 13:23:13 +02:00
|
|
|
begin
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefDisplayHandlerOwn.OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
|
2018-04-20 12:45:06 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnLoadingProgressChange(const browser: ICefBrowser; const progress: double);
|
|
|
|
begin
|
|
|
|
//
|
|
|
|
end;
|
|
|
|
|
2021-01-26 19:26:24 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean);
|
2020-11-19 19:55:17 +02:00
|
|
|
begin
|
|
|
|
aResult := False;
|
|
|
|
end;
|
|
|
|
|
2022-08-06 12:00:28 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnMediaAccessChange(const browser: ICefBrowser; has_video_access, has_audio_access: boolean);
|
|
|
|
begin
|
|
|
|
//
|
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
//
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
//
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnStatusMessage(const browser: ICefBrowser; const value: ustring);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
//
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.OnTitleChange(const browser: ICefBrowser; const title: ustring);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
//
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
function TCefDisplayHandlerOwn.OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
|
2018-02-03 18:52:48 +02:00
|
|
|
procedure TCefDisplayHandlerOwn.RemoveReferences;
|
|
|
|
begin
|
|
|
|
//
|
|
|
|
end;
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
// TCustomDisplayHandler
|
|
|
|
|
2019-06-19 16:53:26 +02:00
|
|
|
constructor TCustomDisplayHandler.Create(const events : IChromiumEvents);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
|
|
|
inherited Create;
|
2017-06-11 17:48:20 +02:00
|
|
|
|
2019-06-19 16:53:26 +02:00
|
|
|
FEvents := Pointer(events);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
destructor TCustomDisplayHandler.Destroy;
|
|
|
|
begin
|
2018-02-03 18:52:48 +02:00
|
|
|
RemoveReferences;
|
2017-06-11 17:48:20 +02:00
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2018-02-03 18:52:48 +02:00
|
|
|
procedure TCustomDisplayHandler.RemoveReferences;
|
|
|
|
begin
|
|
|
|
FEvents := nil;
|
|
|
|
end;
|
|
|
|
|
2017-06-11 20:36:14 +02:00
|
|
|
procedure TCustomDisplayHandler.OnAddressChange(const browser : ICefBrowser;
|
|
|
|
const frame : ICefFrame;
|
|
|
|
const url : ustring);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2020-11-19 19:55:17 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnAddressChange(browser, frame, url);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
function TCustomDisplayHandler.OnConsoleMessage(const browser : ICefBrowser;
|
|
|
|
level : TCefLogSeverity;
|
|
|
|
const message_ : ustring;
|
|
|
|
const source : ustring;
|
|
|
|
line : Integer): Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-02-03 18:52:48 +02:00
|
|
|
if (FEvents <> nil) then
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := IChromiumEvents(FEvents).doOnConsoleMessage(browser, level, message_, source, line)
|
2017-06-11 17:48:20 +02:00
|
|
|
else
|
2018-03-29 20:02:04 +02:00
|
|
|
Result := inherited OnConsoleMessage(browser, level, message_, source, line);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
function TCustomDisplayHandler.OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean;
|
|
|
|
begin
|
2018-02-03 18:52:48 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
Result := IChromiumEvents(FEvents).doOnAutoResize(browser, new_size)
|
2017-10-26 13:23:13 +02:00
|
|
|
else
|
|
|
|
Result := inherited OnAutoResize(browser, new_size);
|
|
|
|
end;
|
|
|
|
|
2018-04-20 12:45:06 +02:00
|
|
|
procedure TCustomDisplayHandler.OnLoadingProgressChange(const browser: ICefBrowser; const progress: double);
|
|
|
|
begin
|
2020-11-19 19:55:17 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnLoadingProgressChange(browser, progress);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomDisplayHandler.OnCursorChange(const browser : ICefBrowser;
|
2021-01-26 19:26:24 +02:00
|
|
|
cursor_ : TCefCursorHandle;
|
2020-11-19 19:55:17 +02:00
|
|
|
cursorType : TCefCursorType;
|
|
|
|
const customCursorInfo : PCefCursorInfo;
|
|
|
|
var aResult : boolean);
|
|
|
|
begin
|
|
|
|
if (FEvents <> nil) then
|
2021-01-26 19:26:24 +02:00
|
|
|
IChromiumEvents(FEvents).doOnCursorChange(browser, cursor_, cursorType, customCursorInfo, aResult);
|
2018-04-20 12:45:06 +02:00
|
|
|
end;
|
|
|
|
|
2022-08-06 12:00:28 +02:00
|
|
|
procedure TCustomDisplayHandler.OnMediaAccessChange(const browser: ICefBrowser; has_video_access, has_audio_access: boolean);
|
|
|
|
begin
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnMediaAccessChange(browser, has_video_access, has_audio_access);
|
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
procedure TCustomDisplayHandler.OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2020-11-19 19:55:17 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnFaviconUrlChange(browser, iconUrls);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
procedure TCustomDisplayHandler.OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2020-11-19 19:55:17 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnFullScreenModeChange(browser, fullscreen);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
procedure TCustomDisplayHandler.OnStatusMessage(const browser: ICefBrowser; const value: ustring);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2020-11-19 19:55:17 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnStatusMessage(browser, value);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
procedure TCustomDisplayHandler.OnTitleChange(const browser: ICefBrowser; const title: ustring);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2020-11-19 19:55:17 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
IChromiumEvents(FEvents).doOnTitleChange(browser, title);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
function TCustomDisplayHandler.OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-02-03 18:52:48 +02:00
|
|
|
if (FEvents <> nil) then
|
|
|
|
Result := IChromiumEvents(FEvents).doOnTooltip(browser, text)
|
2017-06-11 17:48:20 +02:00
|
|
|
else
|
2017-06-11 20:36:14 +02:00
|
|
|
Result := inherited OnTooltip(browser, text);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|