From d24eec27948c7437f33ba9a50219a3f3619fecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Sat, 1 May 2021 10:06:25 +0200 Subject: [PATCH] Update to CEF 90.6.3 Enabled the ChromeRuntime mode to the TinyBrowser2 demo for Lazarus in Windows. --- README.md | 16 +++---- .../TinyBrowser2/uTinyBrowser2.pas | 43 +++++++++++++------ packages/cef4delphi_lazarus.lpk | 2 +- source/uCEFApplicationCore.pas | 2 +- update_CEF4Delphi.json | 4 +- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5123889a..00f769ac 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.6.2 which includes Chromium 90.0.4430.93. +CEF4Delphi uses CEF 90.6.3 which includes Chromium 90.0.4430.93. The CEF binaries used by CEF4Delphi are available for download at spotify : -* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_windows32.tar.bz2) -* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_windows64.tar.bz2) -* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_linux32.tar.bz2) -* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_linux64.tar.bz2) -* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_linuxarm.tar.bz2) -* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_linuxarm64.tar.bz2) -* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.2%2Bg5c92ffb%2Bchromium-90.0.4430.93_macosx64.tar.bz2) +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_linuxarm64.tar.bz2) +* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_90.6.3%2Bgc53c523%2Bchromium-90.0.4430.93_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/Lazarus_Windows/TinyBrowser2/uTinyBrowser2.pas b/demos/Lazarus_Windows/TinyBrowser2/uTinyBrowser2.pas index 11e6ae45..39b1052c 100644 --- a/demos/Lazarus_Windows/TinyBrowser2/uTinyBrowser2.pas +++ b/demos/Lazarus_Windows/TinyBrowser2/uTinyBrowser2.pas @@ -37,19 +37,21 @@ unit uTinyBrowser2; -{$MODE Delphi} +{$MODE Delphi} interface uses + Types, SysUtils, uCEFInterfaces, uCEFTypes, uCEFChromiumCore; type TTinyBrowser2 = class private - FChromium : TChromiumCore; + FChromium : TChromiumCore; + + function GetClient : ICefClient; - procedure Chromium_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); 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); @@ -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; @@ -81,7 +85,7 @@ implementation // and it's necessary to close the message loop. uses - uCEFApplication; + uCEFApplication, uCEFConstants, uCEFMiscFunctions; var TinyBrowser : TTinyBrowser2 = nil; @@ -89,14 +93,22 @@ var procedure GlobalCEFApp_OnContextInitialized; 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.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 @@ -130,22 +142,29 @@ begin inherited Destroy; end; -procedure TTinyBrowser2.AfterConstruction; +procedure TTinyBrowser2.AfterConstruction; +var + TempHandle : TCefWindowHandle; + TempRect : TRect; begin inherited AfterConstruction; FChromium := TChromiumCore.Create(nil); FChromium.DefaultURL := 'https://www.google.com'; - FChromium.OnClose := Chromium_OnClose; FChromium.OnBeforeClose := Chromium_OnBeforeClose; FChromium.OnBeforePopup := Chromium_OnBeforePopup; FChromium.OnOpenUrlFromTab := Chromium_OnOpenUrlFromTab; - FChromium.CreateBrowser('Tiny Browser 2'); -end; -procedure TTinyBrowser2.Chromium_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); + InitializeWindowHandle(TempHandle); + FChromium.CreateBrowser(TempHandle, TempRect, 'Tiny Browser 2', nil, nil, True); +end; + +function TTinyBrowser2.GetClient : ICefClient; begin - aAction := cbaClose; + if (FChromium <> nil) then + Result := FChromium.CefClient + else + Result := nil; end; procedure TTinyBrowser2.Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk index 8291b0d4..e678dadf 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 32b61128..1cad5293 100644 --- a/source/uCEFApplicationCore.pas +++ b/source/uCEFApplicationCore.pas @@ -66,7 +66,7 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 90; CEF_SUPPORTED_VERSION_MINOR = 6; - CEF_SUPPORTED_VERSION_RELEASE = 2; + CEF_SUPPORTED_VERSION_RELEASE = 3; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 90; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 8f26e5da..5883dedc 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 285, + "InternalVersion" : 286, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "90.6.2.0" + "Version" : "90.6.3.0" } ], "UpdatePackageData" : {