2017-01-27 16:37:51 +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
|
|
|
|
|
//
|
2018-05-12 14:50:54 +02:00
|
|
|
|
// Copyright <20> 2018 Salvador Diaz Fau. All rights reserved.
|
2017-01-27 16:37:51 +01: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 uCEFDisplayHandler;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
{$IFDEF FPC}
|
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
{$IFNDEF CPUX64}
|
|
|
|
|
{$ALIGN ON}
|
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$I cef.inc}
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$IFDEF DELPHI16_UP}
|
2017-01-27 16:37:51 +01:00
|
|
|
|
System.Classes,
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$ELSE}
|
|
|
|
|
Classes,
|
|
|
|
|
{$ENDIF}
|
2017-03-16 19:09:42 +01:00
|
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
|
|
type
|
2017-03-16 19:09:42 +01:00
|
|
|
|
TCefDisplayHandlerOwn = class(TCefBaseRefCountedOwn, ICefDisplayHandler)
|
2017-01-27 16:37:51 +01:00
|
|
|
|
protected
|
|
|
|
|
procedure OnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual;
|
|
|
|
|
procedure OnTitleChange(const browser: ICefBrowser; const title: ustring); virtual;
|
2018-03-29 20:02:04 +02:00
|
|
|
|
procedure OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); virtual;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
procedure OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual;
|
|
|
|
|
function OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual;
|
|
|
|
|
procedure OnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual;
|
2018-03-29 20:02:04 +02:00
|
|
|
|
function OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean; virtual;
|
2017-10-26 13:23:13 +02:00
|
|
|
|
function OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; virtual;
|
2018-04-20 12:45:06 +02:00
|
|
|
|
procedure OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); virtual;
|
2017-10-26 13:23:13 +02:00
|
|
|
|
|
2018-02-03 17:52:48 +01:00
|
|
|
|
procedure RemoveReferences; virtual;
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
public
|
|
|
|
|
constructor Create; virtual;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TCustomDisplayHandler = class(TCefDisplayHandlerOwn)
|
|
|
|
|
protected
|
2018-02-03 17:52:48 +01:00
|
|
|
|
FEvents : Pointer;
|
2017-01-27 16:37:51 +01: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 16:37:51 +01: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;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
2018-02-03 17:52:48 +01:00
|
|
|
|
procedure RemoveReferences; override;
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
public
|
2018-02-03 17:52:48 +01:00
|
|
|
|
constructor Create(const events: Pointer); reintroduce; virtual;
|
2017-06-11 17:48:20 +02:00
|
|
|
|
destructor Destroy; override;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
2018-02-03 17:52:48 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2018-02-26 18:40:51 +01:00
|
|
|
|
procedure cef_display_handler_on_favicon_urlchange(self : PCefDisplayHandler;
|
|
|
|
|
browser : PCefBrowser;
|
|
|
|
|
icon_urls : TCefStringList); stdcall;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
var
|
2018-03-29 20:02:04 +02:00
|
|
|
|
TempSL : TStringList;
|
|
|
|
|
TempCefSL : ICefStringList;
|
|
|
|
|
TempObject : TObject;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-26 18:40:51 +01:00
|
|
|
|
TempSL := nil;
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
try
|
2018-02-26 18:40:51 +01:00
|
|
|
|
try
|
2018-03-29 20:02:04 +02:00
|
|
|
|
TempObject := CefGetObject(self);
|
2018-02-26 18:40:51 +01:00
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
|
if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then
|
2018-02-26 18:40:51 +01:00
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
|
TempSL := TStringList.Create;
|
|
|
|
|
TempCefSL := TCefStringListRef.Create(icon_urls);
|
|
|
|
|
TempCefSL.CopyToStrings(TempSL);
|
2018-02-26 18:40:51 +01:00
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
|
TCefDisplayHandlerOwn(TempObject).OnFaviconUrlChange(TCefBrowserRef.UnWrap(browser),
|
|
|
|
|
TempSL);
|
|
|
|
|
end;
|
2018-02-26 18:40:51 +01:00
|
|
|
|
except
|
|
|
|
|
on e : exception do
|
|
|
|
|
if CustomExceptionHandler('cef_display_handler_on_favicon_urlchange', e) then raise;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
finally
|
2018-02-26 18:40:51 +01:00
|
|
|
|
if (TempSL <> nil) then FreeAndNil(TempSL);
|
2017-01-27 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01:00
|
|
|
|
var
|
2018-03-29 20:02:04 +02:00
|
|
|
|
TempText : ustring;
|
|
|
|
|
TempObject : TObject;
|
2017-01-27 16:37:51 +01: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
|
|
|
|
|
TempText := CefStringClearAndGet(text^);
|
|
|
|
|
Result := Ord(TCefDisplayHandlerOwn(TempObject).OnTooltip(TCefBrowserRef.UnWrap(browser),
|
|
|
|
|
TempText));
|
|
|
|
|
text^ := CefStringAlloc(TempText);
|
|
|
|
|
end;
|
2017-01-27 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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 16:37:51 +01: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;
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
constructor TCefDisplayHandlerOwn.Create;
|
|
|
|
|
begin
|
|
|
|
|
inherited CreateData(SizeOf(TCefDisplayHandler));
|
2017-10-26 13:23:13 +02:00
|
|
|
|
|
2017-01-27 16:37:51 +01: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;
|
2017-10-26 13:23:13 +02:00
|
|
|
|
end;
|
2017-01-27 16:37:51 +01: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 16:37:51 +01:00
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
|
//
|
2017-01-27 16:37:51 +01: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 16:37:51 +01:00
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
end;
|
|
|
|
|
|
2018-04-20 12:45:06 +02:00
|
|
|
|
procedure TCefDisplayHandlerOwn.OnLoadingProgressChange(const browser: ICefBrowser; const progress: double);
|
|
|
|
|
begin
|
|
|
|
|
//
|
|
|
|
|
end;
|
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
|
procedure TCefDisplayHandlerOwn.OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
|
//
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
|
procedure TCefDisplayHandlerOwn.OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
|
//
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
|
procedure TCefDisplayHandlerOwn.OnStatusMessage(const browser: ICefBrowser; const value: ustring);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
|
//
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
|
procedure TCefDisplayHandlerOwn.OnTitleChange(const browser: ICefBrowser; const title: ustring);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
|
//
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-10-26 13:23:13 +02:00
|
|
|
|
function TCefDisplayHandlerOwn.OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
|
|
|
|
Result := False;
|
|
|
|
|
end;
|
|
|
|
|
|
2018-02-03 17:52:48 +01:00
|
|
|
|
procedure TCefDisplayHandlerOwn.RemoveReferences;
|
|
|
|
|
begin
|
|
|
|
|
//
|
|
|
|
|
end;
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
// TCustomDisplayHandler
|
|
|
|
|
|
2018-02-03 17:52:48 +01:00
|
|
|
|
constructor TCustomDisplayHandler.Create(const events: Pointer);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
|
|
|
|
inherited Create;
|
2017-06-11 17:48:20 +02:00
|
|
|
|
|
2018-02-03 17:52:48 +01:00
|
|
|
|
FEvents := events;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
destructor TCustomDisplayHandler.Destroy;
|
|
|
|
|
begin
|
2018-02-03 17:52:48 +01:00
|
|
|
|
RemoveReferences;
|
2017-06-11 17:48:20 +02:00
|
|
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
|
end;
|
|
|
|
|
|
2018-02-03 17:52:48 +01: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 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01:00
|
|
|
|
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnAddressChange(browser, frame, url);
|
2017-01-27 16:37:51 +01: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 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01: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 16:37:51 +01: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 17:52:48 +01: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
|
|
|
|
|
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnLoadingProgressChange(browser, progress);
|
|
|
|
|
end;
|
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
|
procedure TCustomDisplayHandler.OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01:00
|
|
|
|
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnFaviconUrlChange(browser, iconUrls);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
procedure TCustomDisplayHandler.OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01:00
|
|
|
|
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnFullScreenModeChange(browser, fullscreen);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
procedure TCustomDisplayHandler.OnStatusMessage(const browser: ICefBrowser; const value: ustring);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01:00
|
|
|
|
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnStatusMessage(browser, value);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
procedure TCustomDisplayHandler.OnTitleChange(const browser: ICefBrowser; const title: ustring);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01:00
|
|
|
|
if (FEvents <> nil) then IChromiumEvents(FEvents).doOnTitleChange(browser, title);
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-06-11 17:48:20 +02:00
|
|
|
|
function TCustomDisplayHandler.OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
begin
|
2018-02-03 17:52:48 +01: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 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|