From edbfe8775b4c182718c854fb77738ff0509e0336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Fri, 23 Apr 2021 14:52:53 +0200 Subject: [PATCH] Update to CEF 90.5.7 Modified the VCL version of the TinyBrowser2 demo to use the experimental "ChromeRuntime" mode. --- README.md | 16 ++--- demos/Delphi_VCL/TinyBrowser/uTinyBrowser.pas | 24 +++++++- .../Delphi_VCL/TinyBrowser2/uTinyBrowser2.pas | 38 +++++++++--- .../TinyBrowser2/uTinyBrowser2.pas | 58 +++++++++++++++---- packages/cef4delphi_lazarus.lpk | 2 +- source/uCEFApplicationCore.pas | 4 +- update_CEF4Delphi.json | 4 +- 7 files changed, 111 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 6a26380d..578d16a4 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ 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 90.5.5 which includes Chromium 90.0.4430.72. +CEF4Delphi uses CEF 90.5.7 which includes Chromium 90.0.4430.85. The CEF binaries used by CEF4Delphi are available for download at spotify : -* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_windows32.tar.bz2) -* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_windows64.tar.bz2) -* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_linux32.tar.bz2) -* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_linux64.tar.bz2) -* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_linuxarm.tar.bz2) -* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_linuxarm64.tar.bz2) -* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.5%2Bgf718c89%2Bchromium-90.0.4430.72_macosx64.tar.bz2) +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_linuxarm64.tar.bz2) +* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.5.7%2Bgcd9342c%2Bchromium-90.0.4430.85_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. diff --git a/demos/Delphi_VCL/TinyBrowser/uTinyBrowser.pas b/demos/Delphi_VCL/TinyBrowser/uTinyBrowser.pas index 56b2ef59..6b6838f5 100644 --- a/demos/Delphi_VCL/TinyBrowser/uTinyBrowser.pas +++ b/demos/Delphi_VCL/TinyBrowser/uTinyBrowser.pas @@ -43,9 +43,9 @@ interface uses {$IFDEF DELPHI16_UP} - System.Classes, + System.Classes, System.Types, System.SysUtils, {$ELSE} - Classes, + Classes, Types, SysUtils, {$ENDIF} uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFApplication, uCEFChromium, uCEFWindowComponent, uCEFBrowserViewComponent; @@ -67,6 +67,8 @@ type FCEFBrowserViewComponent : TCEFBrowserViewComponent; FHomepage : string; + function GetClient : ICefClient; + procedure Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); procedure Chromium_OnBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean); procedure Chromium_OnTitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring); @@ -81,6 +83,7 @@ type procedure CreateTopLevelWindow; property Homepage : string read FHomepage write FHomepage; + property Client : ICefClient read GetClient; end; var @@ -246,6 +249,14 @@ begin aResult.height := DEFAULT_WINDOW_VIEW_HEIGHT; end; +function TTinyBrowser.GetClient : ICefClient; +begin + if (FChromium <> nil) then + Result := FChromium.CefClient + else + Result := nil; +end; + procedure GlobalCEFApp_OnContextInitialized; begin TinyBrowser := TTinyBrowser.Create(nil); @@ -253,18 +264,25 @@ begin TinyBrowser.CreateTopLevelWindow; end; +procedure GlobalCEFApp_OnGetDefaultClient(var aClient : ICefClient); +begin + aClient := TinyBrowser.Client; +end; + procedure CreateGlobalCEFApp; begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.MultiThreadedMessageLoop := False; GlobalCEFApp.ExternalMessagePump := False; + //GlobalCEFApp.ChromeRuntime := True; // Enable this line to test the new "ChromeRuntime" mode. It's in experimental state. GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; + GlobalCEFApp.OnGetDefaultClient := GlobalCEFApp_OnGetDefaultClient; // This event is only used in "ChromeRuntime" mode end; procedure DestroyTinyBrowser; begin if (TinyBrowser <> nil) then - TinyBrowser.Free; + FreeAndNil(TinyBrowser); end; end. diff --git a/demos/Delphi_VCL/TinyBrowser2/uTinyBrowser2.pas b/demos/Delphi_VCL/TinyBrowser2/uTinyBrowser2.pas index 1dc87eea..a034236c 100644 --- a/demos/Delphi_VCL/TinyBrowser2/uTinyBrowser2.pas +++ b/demos/Delphi_VCL/TinyBrowser2/uTinyBrowser2.pas @@ -37,10 +37,16 @@ unit uTinyBrowser2; +{$I cef.inc} + interface uses - Types, + {$IFDEF DELPHI16_UP} + System.Types, System.SysUtils, + {$ELSE} + Types, SysUtils, + {$ENDIF} uCEFInterfaces, uCEFTypes, uCEFChromiumCore; type @@ -48,6 +54,8 @@ type private FChromium : TChromiumCore; + function GetClient : ICefClient; + procedure Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); procedure Chromium_OnBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean); procedure Chromium_OnOpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean); @@ -56,6 +64,8 @@ type constructor Create; destructor Destroy; override; procedure AfterConstruction; override; + + property Client : ICefClient read GetClient; end; procedure CreateGlobalCEFApp; @@ -89,12 +99,20 @@ begin TinyBrowser := TTinyBrowser2.Create; end; +procedure GlobalCEFApp_OnGetDefaultClient(var aClient : ICefClient); +begin + aClient := TinyBrowser.Client; +end; + procedure CreateGlobalCEFApp; begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.MultiThreadedMessageLoop := False; GlobalCEFApp.ExternalMessagePump := False; + GlobalCEFApp.ChromeRuntime := True; // Enable this line to enable the "ChromeRuntime" mode. It's in experimental state. + GlobalCEFApp.cache := 'cache'; GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; + GlobalCEFApp.OnGetDefaultClient := GlobalCEFApp_OnGetDefaultClient; // This event is only used in "ChromeRuntime" mode // This is a workaround for the CEF4Delphi issue #324 : // https://github.com/salvadordf/CEF4Delphi/issues/324 @@ -104,10 +122,7 @@ end; procedure DestroyTinyBrowser; begin if (TinyBrowser <> nil) then - begin - TinyBrowser.Free; - TinyBrowser := nil; - end; + FreeAndNil(TinyBrowser); end; constructor TTinyBrowser2.Create; @@ -120,10 +135,7 @@ end; destructor TTinyBrowser2.Destroy; begin if (FChromium <> nil) then - begin - FChromium.Free; - FChromium := nil; - end; + FreeAndNil(FChromium); inherited Destroy; end; @@ -145,6 +157,14 @@ begin FChromium.CreateBrowser(TempHandle, TempRect, 'Tiny Browser 2', nil, nil, True); end; +function TTinyBrowser2.GetClient : ICefClient; +begin + if (FChromium <> nil) then + Result := FChromium.CefClient + else + Result := nil; +end; + procedure TTinyBrowser2.Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); begin GlobalCEFApp.QuitMessageLoop; diff --git a/demos/Lazarus_Linux/TinyBrowser2/uTinyBrowser2.pas b/demos/Lazarus_Linux/TinyBrowser2/uTinyBrowser2.pas index 488cd938..e464db79 100644 --- a/demos/Lazarus_Linux/TinyBrowser2/uTinyBrowser2.pas +++ b/demos/Lazarus_Linux/TinyBrowser2/uTinyBrowser2.pas @@ -48,7 +48,9 @@ uses type TTinyBrowser2 = class private - FChromium : TChromiumCore; + FChromium : TChromiumCore; + + function GetClient : ICefClient; procedure Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); procedure Chromium_OnBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean); @@ -57,7 +59,9 @@ type public constructor Create; destructor Destroy; override; - procedure AfterConstruction; override; + procedure AfterConstruction; override; + + property Client : ICefClient read GetClient; end; procedure CreateGlobalCEFApp; @@ -83,35 +87,61 @@ implementation // message loop. uses + xlib, uCEFApplication, uCEFConstants, uCEFMiscFunctions; var TinyBrowser : TTinyBrowser2 = nil; +function CustomX11ErrorHandler(Display:PDisplay; ErrorEv:PXErrorEvent):longint;cdecl; +begin + {$IFDEF DEBUG} + XError := ErrorEv^.error_code; + WriteLn('Error: ' + IntToStr(XError)); + {$ENDIF} + Result := 0; +end; + +function CustomXIOErrorHandler(Display:PDisplay):longint;cdecl; +begin + Result := 0; +end; + procedure GlobalCEFApp_OnContextInitialized; begin TinyBrowser := TTinyBrowser2.Create; +end; + +procedure GlobalCEFApp_OnGetDefaultClient(var aClient : ICefClient); +begin + aClient := TinyBrowser.Client; end; procedure CreateGlobalCEFApp; begin + // Install xlib error handlers so that the application won't be terminated + // on non-fatal errors. Must be done after initializing GTK. + XSetErrorHandler(@CustomX11ErrorHandler); + XSetIOErrorHandler(@CustomXIOErrorHandler); + GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.MultiThreadedMessageLoop := False; - GlobalCEFApp.ExternalMessagePump := False; - GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; + GlobalCEFApp.ExternalMessagePump := False; + //GlobalCEFApp.ChromeRuntime := True; // Enable this line to enable the "ChromeRuntime" mode. It's in experimental state. + GlobalCEFApp.cache := 'cache'; + GlobalCEFApp.DisableZygote := True; + GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; + GlobalCEFApp.OnGetDefaultClient := GlobalCEFApp_OnGetDefaultClient; // This event is only used in "ChromeRuntime" mode // Add a debug log in the BIN directory - GlobalCEFApp.LogFile := 'cef.log'; - GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE; + //GlobalCEFApp.LogFile := 'cef.log'; + //GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE; end; procedure DestroyTinyBrowser; begin if (TinyBrowser <> nil) then - begin - TinyBrowser.Free; - TinyBrowser := nil; - end; + FreeAndNil(TinyBrowser); end; constructor TTinyBrowser2.Create; @@ -144,6 +174,14 @@ begin InitializeWindowHandle(TempHandle); FChromium.CreateBrowser(TempHandle, TempRect, 'Tiny Browser 2', nil, nil, True); +end; + +function TTinyBrowser2.GetClient : ICefClient; +begin + if (FChromium <> nil) then + Result := FChromium.CefClient + else + Result := nil; end; procedure TTinyBrowser2.Chromium_OnBeforeClose(Sender: TObject; diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk index 7817f957..8cf460af 100644 --- a/packages/cef4delphi_lazarus.lpk +++ b/packages/cef4delphi_lazarus.lpk @@ -21,7 +21,7 @@ - + diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas index 1e22fa8b..c297fd08 100644 --- a/source/uCEFApplicationCore.pas +++ b/source/uCEFApplicationCore.pas @@ -66,13 +66,13 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 90; CEF_SUPPORTED_VERSION_MINOR = 5; - CEF_SUPPORTED_VERSION_RELEASE = 5; + CEF_SUPPORTED_VERSION_RELEASE = 7; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 90; CEF_CHROMEELF_VERSION_MINOR = 0; CEF_CHROMEELF_VERSION_RELEASE = 4430; - CEF_CHROMEELF_VERSION_BUILD = 72; + CEF_CHROMEELF_VERSION_BUILD = 85; {$IFDEF MSWINDOWS} LIBCEF_DLL = 'libcef.dll'; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 51c0e296..b0176a72 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 281, + "InternalVersion" : 282, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "90.5.5.0" + "Version" : "90.5.7.0" } ], "UpdatePackageData" : {