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

Update to CEF 92.0.20

This commit is contained in:
Salvador Díaz Fau 2021-07-29 16:20:34 +02:00
parent 8bfcf813e2
commit 8d789edbdf
16 changed files with 428 additions and 27 deletions

View File

@ -3,15 +3,16 @@ CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chro
CEF4Delphi is based on DCEF3 and fpCEF3. The original license of those projects still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file.
CEF4Delphi uses CEF 91.1.23 which includes Chromium 91.0.4472.164.
The CEF binaries used by CEF4Delphi are available for download at spotify :
* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_windows32.tar.bz2)
* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_windows64.tar.bz2)
* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_linux32.tar.bz2)
* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_linux64.tar.bz2)
* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_linuxarm.tar.bz2)
* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_linuxarm64.tar.bz2)
* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_91.1.23%2Bg04c8d56%2Bchromium-91.0.4472.164_macosx64.tar.bz2)
CEF4Delphi uses CEF 92.0.20 which includes Chromium 92.0.4515.107.
The CEF binaries used by CEF4Delphi are available for download at Spotify :
* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_windows32.tar.bz2)
* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_windows64.tar.bz2)
* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_linux32.tar.bz2)
* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_linux64.tar.bz2)
* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_linuxarm.tar.bz2)
* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_linuxarm64.tar.bz2)
* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_92.0.20%2Bg7cfecf1%2Bchromium-92.0.4515.107_macosx64.tar.bz2)
CEF4Delphi was developed and tested on Delphi 10.4.2 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3 and Lazarus 2.0.12/FPC 3.2.0. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.

View File

@ -224,6 +224,7 @@ contains
uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas',
uCEFWorkSchedulerQueueThread in '..\source\uCEFWorkSchedulerQueueThread.pas',
uCEFLinkedWinControlBase in '..\source\uCEFLinkedWinControlBase.pas',
uCEFTimerWorkScheduler in '..\source\uCEFTimerWorkScheduler.pas';
uCEFTimerWorkScheduler in '..\source\uCEFTimerWorkScheduler.pas',
uCEFFrameHandler in '..\source\uCEFFrameHandler.pas';
end.

View File

@ -220,6 +220,8 @@ contains
uCEFPrintDialogCallback in '..\source\uCEFPrintDialogCallback.pas',
uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas',
uCEFWorkSchedulerQueueThread in '..\source\uCEFWorkSchedulerQueueThread.pas',
uCEFLinkedWinControlBase in '..\source\uCEFLinkedWinControlBase.pas';
uCEFLinkedWinControlBase in '..\source\uCEFLinkedWinControlBase.pas',
uCEFTimerWorkScheduler in '..\source\uCEFTimerWorkScheduler.pas',
uCEFFrameHandler in '..\source\uCEFFrameHandler.pas';
end.

View File

@ -236,7 +236,8 @@ contains
uCEFMacOSFunctions in '..\source\uCEFMacOSFunctions.pas',
uCEFTimerWorkScheduler in '..\source\uCEFTimerWorkScheduler.pas',
uCEFMacOSCustomCocoaTimer in '..\source\uCEFMacOSCustomCocoaTimer.pas',
uCEFMacOSInterfaces in '..\source\uCEFMacOSInterfaces.pas';
uCEFMacOSInterfaces in '..\source\uCEFMacOSInterfaces.pas',
uCEFFrameHandler in '..\source\uCEFFrameHandler.pas';
end.

View File

@ -352,6 +352,7 @@
<DCCReference Include="..\source\uCEFTimerWorkScheduler.pas"/>
<DCCReference Include="..\source\uCEFMacOSCustomCocoaTimer.pas"/>
<DCCReference Include="..\source\uCEFMacOSInterfaces.pas"/>
<DCCReference Include="..\source\uCEFFrameHandler.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>

View File

@ -21,8 +21,8 @@
</CompilerOptions>
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
<License Value="MPL 1.1"/>
<Version Major="91" Minor="1" Release="23"/>
<Files Count="202">
<Version Major="92" Release="20"/>
<Files Count="203">
<Item1>
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
<UnitName Value="uCEFAccessibilityHandler"/>
@ -849,6 +849,10 @@
<Filename Value="..\source\uCEFTimerWorkScheduler.pas"/>
<UnitName Value="uCEFTimerWorkScheduler"/>
</Item202>
<Item203>
<Filename Value="..\source\uCEFFrameHandler.pas"/>
<UnitName Value="uCEFFrameHandler"/>
</Item203>
</Files>
<RequiredPkgs Count="5">
<Item1>

View File

@ -67,7 +67,7 @@ uses
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants,
uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa,
uCEFBrowserWindow, uCEFOsrBrowserWindow, uCEFTimerWorkScheduler,
LazarusPackageIntf;
uCEFFrameHandler, LazarusPackageIntf;
implementation

View File

@ -64,15 +64,15 @@ uses
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar;
const
CEF_SUPPORTED_VERSION_MAJOR = 91;
CEF_SUPPORTED_VERSION_MINOR = 1;
CEF_SUPPORTED_VERSION_RELEASE = 23;
CEF_SUPPORTED_VERSION_MAJOR = 92;
CEF_SUPPORTED_VERSION_MINOR = 0;
CEF_SUPPORTED_VERSION_RELEASE = 20;
CEF_SUPPORTED_VERSION_BUILD = 0;
CEF_CHROMEELF_VERSION_MAJOR = 91;
CEF_CHROMEELF_VERSION_MAJOR = 92;
CEF_CHROMEELF_VERSION_MINOR = 0;
CEF_CHROMEELF_VERSION_RELEASE = 4472;
CEF_CHROMEELF_VERSION_BUILD = 164;
CEF_CHROMEELF_VERSION_RELEASE = 4515;
CEF_CHROMEELF_VERSION_BUILD = 107;
{$IFDEF MSWINDOWS}
LIBCEF_DLL = 'libcef.dll';

View File

@ -59,6 +59,7 @@ uses
type
TCefBrowserRef = class(TCefBaseRefCountedRef, ICefBrowser)
protected
function IsValid: boolean;
function GetHost: ICefBrowserHost;
function CanGoBack: Boolean;
procedure GoBack;
@ -164,6 +165,11 @@ uses
// TCefBrowserRef
function TCefBrowserRef.IsValid: boolean;
begin
Result := PCefBrowser(FData)^.is_valid(PCefBrowser(FData)) <> 0;
end;
function TCefBrowserRef.GetHost: ICefBrowserHost;
begin
Result := TCefBrowserHostRef.UnWrap(PCefBrowser(FData)^.get_host(PCefBrowser(FData)));

View File

@ -312,6 +312,12 @@ type
FOnPrintReset : TOnPrintResetEvent;
FOnGetPDFPaperSize : TOnGetPDFPaperSizeEvent;
// ICefFrameHandler
FOnFrameCreated : TOnFrameCreated;
FOnFrameAttached : TOnFrameAttached;
FOnFrameDetached : TOnFrameDetached;
FOnMainFrameChanged : TOnMainFrameChanged;
// Custom
FOnTextResultAvailable : TOnTextResultAvailableEvent;
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
@ -632,6 +638,12 @@ type
procedure doOnPrintReset(const browser: ICefBrowser);
procedure doOnGetPDFPaperSize(const browser: ICefBrowser; deviceUnitsPerInch: Integer; var aResult : TCefSize);
// ICefFrameHandler
procedure doOnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame);
procedure doOnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame);
procedure doOnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame);
procedure doOnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame);
// Custom
procedure GetSettings(var aSettings : TCefBrowserSettings);
procedure doCookiesDeleted(numDeleted : integer); virtual;
@ -680,6 +692,7 @@ type
function MustCreateMediaObserver : boolean; virtual;
function MustCreateExtensionHandler : boolean; virtual;
function MustCreatePrintHandler : boolean; virtual;
function MustCreateFrameHandler : boolean; virtual;
property ParentFormHandle : TCefWindowHandle read GetParentFormHandle;
@ -1114,6 +1127,12 @@ type
property OnPrintReset : TOnPrintResetEvent read FOnPrintReset write FOnPrintReset;
property OnGetPDFPaperSize : TOnGetPDFPaperSizeEvent read FOnGetPDFPaperSize write FOnGetPDFPaperSize;
{$ENDIF}
// ICefFrameHandler
property OnFrameCreated : TOnFrameCreated read FOnFrameCreated write FOnFrameCreated;
property OnFrameAttached : TOnFrameAttached read FOnFrameAttached write FOnFrameAttached;
property OnFrameDetached : TOnFrameDetached read FOnFrameDetached write FOnFrameDetached;
property OnMainFrameChanged : TOnMainFrameChanged read FOnMainFrameChanged write FOnMainFrameChanged;
end;
TBrowserInfo = class
@ -1122,6 +1141,8 @@ type
FIsClosing : boolean;
FID : integer;
function GetIsValid : boolean;
public
constructor Create(const aBrowser : ICefBrowser); reintroduce;
destructor Destroy; override;
@ -1129,6 +1150,7 @@ type
property Browser : ICefBrowser read FBrowser;
property ID : integer read FID;
property IsClosing : boolean read FIsClosing write FIsClosing;
property IsValid : boolean read GetIsValid;
end;
TBrowserInfoList = class(TList)
@ -1136,6 +1158,7 @@ type
procedure SetBrowserIsClosing(aID : integer; aValue : boolean);
function GetBrowserIsClosing(aID : integer) : boolean;
function GetBrowserIsValid(aID : integer) : boolean;
function GetBrowser(aID : integer) : ICefBrowser;
function GetFirstBrowser : ICefBrowser;
function GetFirstID : integer;
@ -1148,7 +1171,8 @@ type
procedure FreeAndClearAllItems;
procedure CloseAllBrowsers;
property BrowserIsClosing[aID : integer] : boolean read GetBrowserIsClosing write SetBrowserIsClosing;
property BrowserIsClosing[aID : integer] : boolean read GetBrowserIsClosing write SetBrowserIsClosing;
property BrowserIsValid[aID : integer] : boolean read GetBrowserIsValid;
property Browser[aID : integer] : ICefBrowser read GetBrowser;
property FirstBrowser : ICefBrowser read GetFirstBrowser;
property FirstID : integer read GetFirstID;
@ -1793,6 +1817,12 @@ begin
FOnPrintReset := nil;
FOnGetPDFPaperSize := nil;
// ICefFrameHandler
FOnFrameCreated := nil;
FOnFrameAttached := nil;
FOnFrameDetached := nil;
FOnMainFrameChanged := nil;
// Custom
FOnTextResultAvailable := nil;
FOnPdfPrintFinished := nil;
@ -2820,7 +2850,7 @@ begin
if (FBrowsersCS <> nil) then
try
FBrowsersCS.Acquire;
Result := (FBrowserId <> 0) and (FBrowsers <> nil) and not(FBrowsers.BrowserIsClosing[FBrowserId]);
Result := (FBrowserId <> 0) and (FBrowsers <> nil) and FBrowsers.BrowserIsValid[FBrowserId];
finally
FBrowsersCS.Release;
end;
@ -4758,6 +4788,14 @@ begin
assigned(FOnGetPDFPaperSize);
end;
function TChromiumCore.MustCreateFrameHandler : boolean;
begin
Result := assigned(FOnFrameCreated) or
assigned(FOnFrameAttached) or
assigned(FOnFrameDetached) or
assigned(FOnMainFrameChanged);
end;
{$IFDEF MSWINDOWS}
procedure TChromiumCore.PrefsAvailableMsg(aResultOK : boolean);
begin
@ -5707,6 +5745,30 @@ begin
FOnGetPDFPaperSize(self, browser, deviceUnitsPerInch, aResult);
end;
procedure TChromiumCore.doOnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame);
begin
if assigned(FOnFrameCreated) then
FOnFrameCreated(self, browser, frame);
end;
procedure TChromiumCore.doOnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame);
begin
if assigned(FOnFrameAttached) then
FOnFrameAttached(self, browser, frame);
end;
procedure TChromiumCore.doOnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame);
begin
if assigned(FOnFrameDetached) then
FOnFrameDetached(self, browser, frame);
end;
procedure TChromiumCore.doOnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame);
begin
if assigned(FOnMainFrameChanged) then
FOnMainFrameChanged(self, browser, old_frame, new_frame);
end;
procedure TChromiumCore.doOnFullScreenModeChange(const browser : ICefBrowser;
fullscreen : Boolean);
begin
@ -6821,6 +6883,11 @@ begin
inherited Destroy;
end;
function TBrowserInfo.GetIsValid : boolean;
begin
Result := not(FIsClosing) and (FBrowser <> nil) and FBrowser.IsValid;
end;
// ******************************************
// *********** TBrowserInfoList *************
@ -6909,6 +6976,14 @@ begin
Result := (i >= 0) and TBrowserInfo(Items[i]).IsClosing;
end;
function TBrowserInfoList.GetBrowserIsValid(aID : integer) : boolean;
var
i : integer;
begin
i := SearchBrowser(aID);
Result := (i >= 0) and TBrowserInfo(Items[i]).IsValid;
end;
function TBrowserInfoList.GetBrowser(aID : integer) : ICefBrowser;
var
i : integer;

View File

@ -208,6 +208,12 @@ type
TOnPrintResetEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object;
TOnGetPDFPaperSizeEvent = procedure(Sender: TObject; const browser: ICefBrowser; deviceUnitsPerInch: Integer; var aResult : TCefSize) of object;
// ICefFrameHandler
TOnFrameCreated = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame) of object;
TOnFrameAttached = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame) of object;
TOnFrameDetached = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame) of object;
TOnMainFrameChanged = procedure(Sender: TObject; const browser: ICefBrowser; const old_frame, new_frame: ICefFrame) of object;
// Custom
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object;

View File

@ -62,6 +62,7 @@ type
procedure GetDragHandler(var aHandler : ICefDragHandler); virtual;
procedure GetFindHandler(var aHandler : ICefFindHandler); virtual;
procedure GetFocusHandler(var aHandler : ICefFocusHandler); virtual;
procedure GetFrameHandler(var aHandler : ICefFrameHandler); virtual;
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler); virtual;
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler); virtual;
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler); virtual;
@ -87,6 +88,7 @@ type
procedure GetDragHandler(var aHandler : ICefDragHandler); virtual;
procedure GetFindHandler(var aHandler : ICefFindHandler); virtual;
procedure GetFocusHandler(var aHandler : ICefFocusHandler); virtual;
procedure GetFrameHandler(var aHandler : ICefFrameHandler); virtual;
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler); virtual;
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler); virtual;
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler); virtual;
@ -120,6 +122,7 @@ type
FDragHandler : ICefDragHandler;
FFindHandler : ICefFindHandler;
FPrintHandler : ICefPrintHandler;
FFrameHandler : ICefFrameHandler;
procedure GetAudioHandler(var aHandler : ICefAudioHandler); override;
procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); override;
@ -129,6 +132,7 @@ type
procedure GetDragHandler(var aHandler : ICefDragHandler); override;
procedure GetFindHandler(var aHandler : ICefFindHandler); override;
procedure GetFocusHandler(var aHandler : ICefFocusHandler); override;
procedure GetFrameHandler(var aHandler : ICefFrameHandler); override;
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler); override;
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler); override;
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler); override;
@ -159,7 +163,7 @@ uses
uCEFDisplayHandler, uCEFDownloadHandler, uCEFJsDialogHandler,
uCEFLifeSpanHandler, uCEFRequestHandler, uCEFRenderHandler, uCEFDragHandler,
uCEFFindHandler, uCEFConstants, uCEFApplicationCore, uCEFFrame, uCEFAudioHandler,
uCEFPrintHandler;
uCEFPrintHandler, uCEFFrameHandler;
// ******************************************************
@ -214,6 +218,11 @@ begin
aHandler := nil;
end;
procedure TCefClientRef.GetFrameHandler(var aHandler : ICefFrameHandler);
begin
aHandler := nil;
end;
procedure TCefClientRef.GetJsdialogHandler(var aHandler : ICefJsDialogHandler);
begin
aHandler := nil;
@ -401,6 +410,23 @@ begin
end;
end;
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;
var
TempObject : TObject;
@ -553,6 +579,7 @@ begin
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;
get_frame_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_frame_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;
@ -604,6 +631,11 @@ begin
aHandler := nil;
end;
procedure TCefClientOwn.GetFrameHandler(var aHandler : ICefFrameHandler);
begin
aHandler := nil;
end;
procedure TCefClientOwn.GetJsdialogHandler(var aHandler : ICefJsDialogHandler);
begin
aHandler := nil;
@ -689,6 +721,7 @@ begin
if events.MustCreateDragHandler then FDragHandler := TCustomDragHandler.Create(events);
if events.MustCreateFindHandler then FFindHandler := TCustomFindHandler.Create(events);
if events.MustCreatePrintHandler then FPrintHandler := TCustomPrintHandler.Create(events);
if events.MustCreateFrameHandler then FFrameHandler := TCustomFrameHandler.Create(events);
end;
end;
end;
@ -719,6 +752,7 @@ begin
if (FDragHandler <> nil) then FDragHandler.RemoveReferences;
if (FFindHandler <> nil) then FFindHandler.RemoveReferences;
if (FPrintHandler <> nil) then FPrintHandler.RemoveReferences;
if (FFrameHandler <> nil) then FFrameHandler.RemoveReferences;
end;
procedure TCustomClientHandler.InitializeVars;
@ -738,6 +772,7 @@ begin
FDragHandler := nil;
FFindHandler := nil;
FPrintHandler := nil;
FFrameHandler := nil;
FEvents := nil;
end;
@ -805,6 +840,14 @@ begin
aHandler := nil;
end;
procedure TCustomClientHandler.GetFrameHandler(var aHandler : ICefFrameHandler);
begin
if (FFrameHandler <> nil) then
aHandler := FFrameHandler
else
aHandler := nil;
end;
procedure TCustomClientHandler.GetJsdialogHandler(var aHandler : ICefJsDialogHandler);
begin
if (FJsDialogHandler <> nil) then

226
source/uCEFFrameHandler.pas Normal file
View File

@ -0,0 +1,226 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF 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 © 2021 Salvador Diaz 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 uCEFFrameHandler;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
{$MINENUMSIZE 4}
{$I cef.inc}
interface
uses
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
type
TCefFrameHandlerOwn = class(TCefBaseRefCountedOwn, ICefFrameHandler)
protected
procedure OnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame); virtual;
procedure OnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame); virtual;
procedure OnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame); virtual;
procedure OnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame); virtual;
procedure RemoveReferences; virtual;
public
constructor Create; virtual;
end;
TCustomFrameHandler = class(TCefFrameHandlerOwn)
protected
FEvents : Pointer;
procedure OnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame); override;
procedure OnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame); override;
procedure OnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame); override;
procedure OnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame); override;
procedure RemoveReferences; override;
public
constructor Create(const events : IChromiumEvents); reintroduce; virtual;
destructor Destroy; override;
end;
implementation
uses
{$IFDEF DELPHI16_UP}
System.SysUtils,
{$ELSE}
SysUtils,
{$ENDIF}
uCEFMiscFunctions, uCEFLibFunctions, uCEFClient, uCEFBrowser, uCEFFrame;
// TCefFrameHandlerOwn
procedure cef_frame_handler_on_frame_created(self: PCefFrameHandler; browser: PCefBrowser; frame: PCefFrame); stdcall;
var
TempObject : TObject;
begin
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefFrameHandlerOwn) then
TCefFrameHandlerOwn(TempObject).OnFrameCreated(TCefBrowserRef.UnWrap(browser),
TCefFrameRef.UnWrap(frame));
end;
procedure cef_frame_handler_on_frame_attached(self: PCefFrameHandler; browser: PCefBrowser; frame: PCefFrame); stdcall;
var
TempObject : TObject;
begin
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefFrameHandlerOwn) then
TCefFrameHandlerOwn(TempObject).OnFrameAttached(TCefBrowserRef.UnWrap(browser),
TCefFrameRef.UnWrap(frame));
end;
procedure cef_frame_handler_on_frame_detached(self: PCefFrameHandler; browser: PCefBrowser; frame: PCefFrame); stdcall;
var
TempObject : TObject;
begin
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefFrameHandlerOwn) then
TCefFrameHandlerOwn(TempObject).OnFrameDetached(TCefBrowserRef.UnWrap(browser),
TCefFrameRef.UnWrap(frame));
end;
procedure cef_frame_handler_on_main_frame_changed(self: PCefFrameHandler; browser: PCefBrowser; old_frame, new_frame: PCefFrame); stdcall;
var
TempObject : TObject;
begin
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefFrameHandlerOwn) then
TCefFrameHandlerOwn(TempObject).OnMainFrameChanged(TCefBrowserRef.UnWrap(browser),
TCefFrameRef.UnWrap(old_frame),
TCefFrameRef.UnWrap(new_frame));
end;
constructor TCefFrameHandlerOwn.Create;
begin
inherited CreateData(SizeOf(TCefFrameHandler));
with PCefFrameHandler(FData)^ do
begin
on_frame_created := {$IFDEF FPC}@{$ENDIF}cef_frame_handler_on_frame_created;
on_frame_attached := {$IFDEF FPC}@{$ENDIF}cef_frame_handler_on_frame_attached;
on_frame_detached := {$IFDEF FPC}@{$ENDIF}cef_frame_handler_on_frame_detached;
on_main_frame_changed := {$IFDEF FPC}@{$ENDIF}cef_frame_handler_on_main_frame_changed;
end;
end;
procedure TCefFrameHandlerOwn.OnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame);
begin
//
end;
procedure TCefFrameHandlerOwn.OnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame);
begin
//
end;
procedure TCefFrameHandlerOwn.OnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame);
begin
//
end;
procedure TCefFrameHandlerOwn.OnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame);
begin
//
end;
procedure TCefFrameHandlerOwn.RemoveReferences;
begin
//
end;
// TCustomFrameHandler
constructor TCustomFrameHandler.Create(const events : IChromiumEvents);
begin
inherited Create;
FEvents := Pointer(events);
end;
destructor TCustomFrameHandler.Destroy;
begin
RemoveReferences;
inherited Destroy;
end;
procedure TCustomFrameHandler.RemoveReferences;
begin
FEvents := nil;
end;
procedure TCustomFrameHandler.OnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnFrameCreated(browser, frame);
end;
procedure TCustomFrameHandler.OnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnFrameAttached(browser, frame);
end;
procedure TCustomFrameHandler.OnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnFrameDetached(browser, frame);
end;
procedure TCustomFrameHandler.OnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame);
begin
if (FEvents <> nil) then
IChromiumEvents(FEvents).doOnMainFrameChanged(browser, old_frame, new_frame);
end;
end.

View File

@ -59,6 +59,7 @@ uses
type
ICefBrowser = interface;
ICefFrame = interface;
ICefFrameHandler = interface;
ICefRequest = interface;
ICefv8Value = interface;
ICefV8Exception = interface;
@ -461,6 +462,12 @@ type
procedure doOnPrintReset(const browser: ICefBrowser);
procedure doOnGetPDFPaperSize(const browser: ICefBrowser; deviceUnitsPerInch: Integer; var aResult : TCefSize);
// ICefFrameHandler
procedure doOnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame);
procedure doOnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame);
procedure doOnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame);
procedure doOnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame);
// Custom
procedure doCookiesDeleted(numDeleted : integer);
procedure doPdfPrintFinished(aResultOK : boolean);
@ -506,6 +513,7 @@ type
function MustCreateCookieAccessFilter : boolean;
function MustCreateMediaObserver : boolean;
function MustCreatePrintHandler : boolean;
function MustCreateFrameHandler : boolean;
end;
IServerEvents = interface
@ -671,6 +679,7 @@ type
// /include/capi/cef_browser_capi.h (cef_browser_t)
ICefBrowser = interface(ICefBaseRefCounted)
['{BA003C2E-CF15-458F-9D4A-FE3CEFCF3EEF}']
function IsValid: boolean;
function GetHost: ICefBrowserHost;
function CanGoBack: Boolean;
procedure GoBack;
@ -812,6 +821,18 @@ type
property Identifier : int64 read GetIdentifier;
end;
// TCefFrameHandler
// /include/capi/cef_frame_handler_capi.h (cef_frame_handler_t)
ICefFrameHandler = interface(ICefBaseRefCounted)
['{B437128C-F7CB-4F75-83CF-A257B98C0B6E}']
procedure OnFrameCreated(const browser: ICefBrowser; const frame: ICefFrame);
procedure OnFrameAttached(const browser: ICefBrowser; const frame: ICefFrame);
procedure OnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame);
procedure OnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame);
procedure RemoveReferences; // custom procedure to clear all references
end;
// TCefStreamReader
// /include/capi/cef_stream_capi.h (cef_stream_reader_t)
ICefCustomStreamReader = interface(ICefBaseRefCounted)
@ -2085,6 +2106,7 @@ type
procedure GetDragHandler(var aHandler : ICefDragHandler);
procedure GetFindHandler(var aHandler : ICefFindHandler);
procedure GetFocusHandler(var aHandler : ICefFocusHandler);
procedure GetFrameHandler(var aHandler : ICefFrameHandler);
procedure GetJsdialogHandler(var aHandler : ICefJsdialogHandler);
procedure GetKeyboardHandler(var aHandler : ICefKeyboardHandler);
procedure GetLifeSpanHandler(var aHandler : ICefLifeSpanHandler);

View File

@ -89,6 +89,7 @@ type
PCefContextMenuHandler = ^TCefContextMenuHandler;
PCefAccessibilityHandler = ^TCefAccessibilityHandler;
PCefFrame = ^TCefFrame;
PCefFrameHandler = ^TCefFrameHandler;
PCefApp = ^TCefApp;
PCefServer = ^TCefServer;
PCefServerHandler = ^TCefServerHandler;
@ -902,7 +903,7 @@ type
// /include/internal/cef_types.h (cef_thread_id_t)
TCefThreadId = (
TID_UI,
TID_FILE_BACKGROUND, // TID_FILE = TID_FILE_BACKGROUND
TID_FILE_BACKGROUND,
TID_FILE_USER_VISIBLE,
TID_FILE_USER_BLOCKING,
TID_PROCESS_LAUNCHER,
@ -2862,6 +2863,16 @@ type
send_process_message : procedure(self: PCefFrame; target_process: TCefProcessId; message_: PCefProcessMessage); stdcall;
end;
// /include/capi/cef_frame_handler_capi.h (cef_frame_handler_t)
TCefFrameHandler = record
base : TCefBaseRefCounted;
on_frame_created : procedure(self: PCefFrameHandler; browser: PCefBrowser; frame: PCefFrame); stdcall;
on_frame_attached : procedure(self: PCefFrameHandler; browser: PCefBrowser; frame: PCefFrame); stdcall;
on_frame_detached : procedure(self: PCefFrameHandler; browser: PCefBrowser; frame: PCefFrame); stdcall;
on_main_frame_changed : procedure(self: PCefFrameHandler; browser: PCefBrowser; old_frame, new_frame: PCefFrame); stdcall;
end;
// /include/capi/cef_accessibility_handler_capi.h (cef_accessibility_handler_t)
TCefAccessibilityHandler = record
base : TCefBaseRefCounted;
@ -2889,6 +2900,7 @@ type
get_drag_handler : function(self: PCefClient): PCefDragHandler; stdcall;
get_find_handler : function(self: PCefClient): PCefFindHandler; stdcall;
get_focus_handler : function(self: PCefClient): PCefFocusHandler; stdcall;
get_frame_handler : function(self: PCefClient): PCefFrameHandler; stdcall;
get_jsdialog_handler : function(self: PCefClient): PCefJsDialogHandler; stdcall;
get_keyboard_handler : function(self: PCefClient): PCefKeyboardHandler; stdcall;
get_life_span_handler : function(self: PCefClient): PCefLifeSpanHandler; stdcall;
@ -2967,6 +2979,7 @@ type
// /include/capi/cef_browser_capi.h (cef_browser_t)
TCefBrowser = record
base : TCefBaseRefCounted;
is_valid : function(self: PCefBrowser): Integer; stdcall;
get_host : function(self: PCefBrowser): PCefBrowserHost; stdcall;
can_go_back : function(self: PCefBrowser): Integer; stdcall;
go_back : procedure(self: PCefBrowser); stdcall;

View File

@ -2,9 +2,9 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 309,
"InternalVersion" : 310,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "91.1.23.0"
"Version" : "92.0.20.0"
}
],
"UpdatePackageData" : {