diff --git a/README.md b/README.md index 280ef9fd..22a56eb6 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,19 @@ 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 89.0.7 which includes Chromium 89.0.4389.72. +CEF4Delphi uses CEF 89.0.12 which includes Chromium 89.0.4389.90. The CEF binaries used by CEF4Delphi are available for download at spotify : -* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_windows32.tar.bz2) -* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_windows64.tar.bz2) -* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linux32.tar.bz2) -* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linux64.tar.bz2) -* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linuxarm.tar.bz2) -* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linuxarm64.tar.bz2) -* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_macosx64.tar.bz2) +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linuxarm64.tar.bz2) +* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_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. -CEF4Delphi demos have been tested in Windows 7, Windows 10, Linux Mint 20.1 and Raspberry Pi OS. +CEF4Delphi demos have been tested in Windows 7, Windows 10, Linux Mint 20.1 and Raspberry Pi OS. ## Links * [Installation instructions and more information about CEF4Delphi](https://www.briskbard.com/index.php?lang=en&pageid=cef) diff --git a/demos/Delphi_VCL/SubProcess/SimpleBrowser.dpr b/demos/Delphi_VCL/SubProcess/SimpleBrowser.dpr index 61669b4d..a0135225 100644 --- a/demos/Delphi_VCL/SubProcess/SimpleBrowser.dpr +++ b/demos/Delphi_VCL/SubProcess/SimpleBrowser.dpr @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Díaz Fau. All rights reserved. +// Copyright © 2021 Salvador Díaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -46,18 +46,14 @@ uses {$ELSE} Forms, Windows, - {$ENDIF } - uCEFApplication, - uSimpleBrowser in 'uSimpleBrowser.pas' {Form1}, - uCEFLoader in 'uCEFLoader.pas'; + {$ENDIF} + uCEFLoader in 'uCEFLoader.pas', + uSimpleBrowser in 'uSimpleBrowser.pas' {Form1}; {$R *.res} // CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. // If you don't add this flag the rederer process will crash when you try to load large images. -// The IMAGE_FILE_LARGE_ADDRESS_AWARE constant is declared in WinApi.Windows. If you don't want to add -// WinApi.Windows to the 'uses' section in this file just replace the following line by -// {$SetPEFlags $20} {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin diff --git a/demos/Delphi_VCL/SubProcess/SimpleBrowser.dproj b/demos/Delphi_VCL/SubProcess/SimpleBrowser.dproj index e22b94d1..0326a8b9 100644 --- a/demos/Delphi_VCL/SubProcess/SimpleBrowser.dproj +++ b/demos/Delphi_VCL/SubProcess/SimpleBrowser.dproj @@ -131,10 +131,10 @@ MainSource +
Form1
- Cfg_2 Base diff --git a/demos/Delphi_VCL/SubProcess/SubProcess.dpr b/demos/Delphi_VCL/SubProcess/SimpleBrowser_sp.dpr similarity index 65% rename from demos/Delphi_VCL/SubProcess/SubProcess.dpr rename to demos/Delphi_VCL/SubProcess/SimpleBrowser_sp.dpr index 143e88bf..0240af9d 100644 --- a/demos/Delphi_VCL/SubProcess/SubProcess.dpr +++ b/demos/Delphi_VCL/SubProcess/SimpleBrowser_sp.dpr @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Díaz Fau. All rights reserved. +// Copyright © 2021 Salvador Díaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -35,7 +35,7 @@ * *) -program SubProcess; +program SimpleBrowser_sp; {$I cef.inc} @@ -45,34 +45,22 @@ uses {$ELSE} Windows, {$ENDIF} - uCEFApplicationCore; + uCEFLoader in 'uCEFLoader.pas'; // CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes // to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin - GlobalCEFApp := TCefApplicationCore.Create; + // This SubProcess project is only used for the CEF subprocesses and it needs + // to declare "CEFSUBPROCESS" conditional define. Follow these steps to add it: + // 1. Open the project options in the Project->Options menu option and select + // "Building->Delphi Compiler" on the left. + // 2. Select "All configurations - All platforms" option as the "Target" on + // the right section of that window. + // 3. Add "CEFSUBPROCESS" (without quotes) in the "Conditional defines" box. - // The main process and the subprocess *MUST* have the same GlobalCEFApp - // properties and events, specially FrameworkDirPath, ResourcesDirPath, - // LocalesDirPath, cache and UserDataPath paths. - - // The demos are compiled into the BIN directory. Make sure SubProcess.exe - // and SimpleBrowser.exe are in that directory or this demo won't work. - - // In case you want to use custom directories for the CEF3 binaries, cache - // and user data. -{ - GlobalCEFApp.FrameworkDirPath := 'cef'; - GlobalCEFApp.ResourcesDirPath := 'cef'; - GlobalCEFApp.LocalesDirPath := 'cef\locales'; - GlobalCEFApp.cache := 'cef\cache'; - GlobalCEFApp.UserDataPath := 'cef\User Data'; -} - - GlobalCEFApp.StartSubProcess; - GlobalCEFApp.Free; - GlobalCEFApp := nil; + // uCEFLoader will call CreateGlobalCEFApp and DestroyGlobalCEFApp in the + // initialization and finalization sections of that unit. end. diff --git a/demos/Delphi_VCL/SubProcess/SubProcess.dproj b/demos/Delphi_VCL/SubProcess/SimpleBrowser_sp.dproj similarity index 98% rename from demos/Delphi_VCL/SubProcess/SubProcess.dproj rename to demos/Delphi_VCL/SubProcess/SimpleBrowser_sp.dproj index 0bd0bb26..c348e895 100644 --- a/demos/Delphi_VCL/SubProcess/SubProcess.dproj +++ b/demos/Delphi_VCL/SubProcess/SimpleBrowser_sp.dproj @@ -3,7 +3,7 @@ {6ABCF641-08D0-4F35-9D13-2FBD18E5152A} 19.2 VCL - SubProcess.dpr + SimpleBrowser_sp.dpr True Release Win32 @@ -50,7 +50,7 @@ System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= $(BDS)\bin\delphi_PROJECTICON.ico - SubProcess + SimpleBrowser_sp .\$(Platform)\$(Config) false false @@ -58,6 +58,7 @@ false false ..\..\..\bin + CEFSUBPROCESS;$(DCC_Define) Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) @@ -112,6 +113,7 @@ MainSource + Cfg_2 Base @@ -130,16 +132,21 @@ - SubProcess.dpr + SimpleBrowser_sp.dpr - IP Abstraction Indy Implementation Design Time - DBExpress Enterprise Data Explorer Integration - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components + IP Abstraction Indy Implementation Design Time + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + SimpleBrowser_sp.exe + true + + diff --git a/demos/Delphi_VCL/SubProcess/SubProcessGrp.groupproj b/demos/Delphi_VCL/SubProcess/SubProcessGrp.groupproj index 94a0c44a..2b80ccf5 100644 --- a/demos/Delphi_VCL/SubProcess/SubProcessGrp.groupproj +++ b/demos/Delphi_VCL/SubProcess/SubProcessGrp.groupproj @@ -6,7 +6,7 @@ - + @@ -26,23 +26,23 @@ - - + + - - + + - - + + - + - + - + diff --git a/demos/Delphi_VCL/SubProcess/uCEFLoader.pas b/demos/Delphi_VCL/SubProcess/uCEFLoader.pas index 379aca29..d13b13bc 100644 --- a/demos/Delphi_VCL/SubProcess/uCEFLoader.pas +++ b/demos/Delphi_VCL/SubProcess/uCEFLoader.pas @@ -42,17 +42,26 @@ interface implementation uses + {$IFDEF CEFSUBPROCESS} + uCEFApplicationCore; + {$ELSE} uCEFApplication; - - // Follow these steps to test this demo : - // 1. Build the SubProcess project in this directory. - // 2. Copy the CEF binaries to the BIN directory in CEF4Delphi. - // 3. Build this project : SimpleBrowser - // 4. Run this demo : SimpleBrowser + {$ENDIF} procedure CreateGlobalCEFApp; begin + // In case you prefer to call CreateGlobalCEFApp and DestroyGlobalCEFApp manually + // you have to remember that GlobalCEFApp can only be initialized *ONCE* per process. + // This is a CEF requirement and there's no workaround. + if (GlobalCEFApp <> nil) then + exit; + + {$IFDEF CEFSUBPROCESS} + GlobalCEFApp := TCefApplicationCore.Create; + {$ELSE} GlobalCEFApp := TCefApplication.Create; + GlobalCEFApp.BrowserSubprocessPath := 'SimpleBrowser_sp.exe'; + {$ENDIF} // In case you want to use custom directories for the CEF binaries, cache and user data. // If you don't set a cache directory the browser will use in-memory cache. @@ -65,12 +74,9 @@ begin GlobalCEFApp.UserDataPath := 'cef\User Data'; } - GlobalCEFApp.BrowserSubprocessPath := 'SubProcess.exe'; - // This demo uses a different EXE for the subprocesses. // With this configuration it's not necessary to have the // GlobalCEFApp.StartMainProcess call in a if..then clause. - GlobalCEFApp.StartMainProcess; end; diff --git a/demos/Delphi_VCL/SubProcess/uSimpleBrowser.dfm b/demos/Delphi_VCL/SubProcess/uSimpleBrowser.dfm index fc3d0e45..b30b20d6 100644 --- a/demos/Delphi_VCL/SubProcess/uSimpleBrowser.dfm +++ b/demos/Delphi_VCL/SubProcess/uSimpleBrowser.dfm @@ -1,7 +1,7 @@ object Form1: TForm1 Left = 0 Top = 0 - Caption = 'Simple Browser' + Caption = 'Simple Browser - Initializing browser. Please wait...' ClientHeight = 624 ClientWidth = 1038 Color = clBtnFace @@ -12,8 +12,8 @@ object Form1: TForm1 Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnActivate = FormActivate OnCloseQuery = FormCloseQuery - OnShow = FormShow PixelsPerInch = 96 TextHeight = 13 object ChromiumWindow1: TChromiumWindow @@ -24,7 +24,6 @@ object Form1: TForm1 Align = alClient TabOrder = 0 OnClose = ChromiumWindow1Close - OnBeforeClose = ChromiumWindow1BeforeClose OnAfterCreated = ChromiumWindow1AfterCreated end object AddressPnl: TPanel diff --git a/demos/Delphi_VCL/SubProcess/uSimpleBrowser.pas b/demos/Delphi_VCL/SubProcess/uSimpleBrowser.pas index 91f04d8a..8f5fb896 100644 --- a/demos/Delphi_VCL/SubProcess/uSimpleBrowser.pas +++ b/demos/Delphi_VCL/SubProcess/uSimpleBrowser.pas @@ -50,7 +50,7 @@ uses Controls, Forms, Dialogs, StdCtrls, ExtCtrls, {$ENDIF} uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, - uCEFWinControl, uCEFSentinel; + uCEFWinControl, uCEFSentinel, uCEFLinkedWinControlBase; type TForm1 = class(TForm) @@ -60,12 +60,11 @@ type GoBtn: TButton; Timer1: TTimer; procedure GoBtnClick(Sender: TObject); - procedure FormShow(Sender: TObject); procedure ChromiumWindow1AfterCreated(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure ChromiumWindow1Close(Sender: TObject); - procedure ChromiumWindow1BeforeClose(Sender: TObject); + procedure FormActivate(Sender: TObject); private // You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned. procedure WMMove(var aMessage : TWMMove); message WM_MOVE; @@ -109,12 +108,11 @@ uses // Destruction steps // ================= // 1. The FormCloseQuery event sets CanClose to False and calls TChromiumWindow.CloseBrowser, which triggers the TChromiumWindow.OnClose event. -// 2. The TChromiumWindow.OnClose event calls TChromiumWindow.DestroyChildWindow which triggers the TChromiumWindow.OnBeforeClose event. -// 3. TChromiumWindow.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form. +// 2. The TChromiumWindow.OnClose sets FCanClose := True and sends WM_CLOSE to the form. procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin - if GlobalCEFApp.LibLoaded then + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin CanClose := FCanClose; @@ -129,11 +127,13 @@ begin CanClose := True; end; -procedure TForm1.FormShow(Sender: TObject); +procedure TForm1.FormActivate(Sender: TObject); begin - Caption := 'Simple Browser - Initializing browser. Please wait...'; + if ChromiumWindow1.Initialized then + exit; - ChromiumWindow1.ChromiumBrowser.OnBeforePopup := Chromium_OnBeforePopup; + ChromiumWindow1.ChromiumBrowser.OnBeforePopup := Chromium_OnBeforePopup; + ChromiumWindow1.ChromiumBrowser.DefaultURL := AddressEdt.Text; // You *MUST* call CreateBrowser to create and initialize the browser. // This will trigger the AfterCreated event when the browser is fully @@ -141,20 +141,11 @@ begin // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser // If it's not initialized yet, we use a simple timer to create the browser later. - if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True; + if not(ChromiumWindow1.CreateBrowser) then + Timer1.Enabled := True; end; procedure TForm1.ChromiumWindow1Close(Sender: TObject); -begin - // DestroyChildWindow will destroy the child window created by CEF at the top of the Z order. - if not(ChromiumWindow1.DestroyChildWindow) then - begin - FCanClose := True; - PostMessage(Handle, WM_CLOSE, 0, 0); - end; -end; - -procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject); begin FCanClose := True; PostMessage(Handle, WM_CLOSE, 0, 0); @@ -176,10 +167,9 @@ end; procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject); begin - // Now the browser is fully initialized we can load the initial web page. + // Now the browser is fully initialized we can enable the user interface. Caption := 'Simple Browser'; AddressPnl.Enabled := True; - GoBtn.Click; end; procedure TForm1.GoBtnClick(Sender: TObject); @@ -199,28 +189,32 @@ procedure TForm1.WMMove(var aMessage : TWMMove); begin inherited; - if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; + if (ChromiumWindow1 <> nil) then + ChromiumWindow1.NotifyMoveOrResizeStarted; end; procedure TForm1.WMMoving(var aMessage : TMessage); begin inherited; - if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; + if (ChromiumWindow1 <> nil) then + ChromiumWindow1.NotifyMoveOrResizeStarted; end; procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage); begin inherited; - if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then + GlobalCEFApp.OsmodalLoop := True; end; procedure TForm1.WMExitMenuLoop(var aMessage: TMessage); begin inherited; - if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then + GlobalCEFApp.OsmodalLoop := False; end; end. diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas index a0b757e2..3568197c 100644 --- a/source/uCEFApplicationCore.pas +++ b/source/uCEFApplicationCore.pas @@ -66,13 +66,13 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 89; CEF_SUPPORTED_VERSION_MINOR = 0; - CEF_SUPPORTED_VERSION_RELEASE = 7; + CEF_SUPPORTED_VERSION_RELEASE = 12; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 89; CEF_CHROMEELF_VERSION_MINOR = 0; CEF_CHROMEELF_VERSION_RELEASE = 4389; - CEF_CHROMEELF_VERSION_BUILD = 72; + CEF_CHROMEELF_VERSION_BUILD = 90; {$IFDEF MSWINDOWS} LIBCEF_DLL = 'libcef.dll'; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 8578e9c4..4944a180 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 269, + "InternalVersion" : 270, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "89.0.7.0" + "Version" : "89.0.12.0" } ], "UpdatePackageData" : {