1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-02-02 10:25:26 +02:00

Update to CEF 89.0.12

Modified the VCL SubProcess demo as suggested by Tomm Prami
Fixed issue #352
This commit is contained in:
Salvador Díaz Fau 2021-03-20 13:16:08 +01:00
parent 5bd415a4be
commit 0abb2732de
11 changed files with 91 additions and 101 deletions

View File

@ -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)

View File

@ -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

View File

@ -131,10 +131,10 @@
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="uCEFLoader.pas"/>
<DCCReference Include="uSimpleBrowser.pas">
<Form>Form1</Form>
</DCCReference>
<DCCReference Include="uCEFLoader.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>

View File

@ -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.

View File

@ -3,7 +3,7 @@
<ProjectGuid>{6ABCF641-08D0-4F35-9D13-2FBD18E5152A}</ProjectGuid>
<ProjectVersion>19.2</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>SubProcess.dpr</MainSource>
<MainSource>SimpleBrowser_sp.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
@ -50,7 +50,7 @@
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
<SanitizedProjectName>SubProcess</SanitizedProjectName>
<SanitizedProjectName>SimpleBrowser_sp</SanitizedProjectName>
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
<DCC_E>false</DCC_E>
<DCC_N>false</DCC_N>
@ -58,6 +58,7 @@
<DCC_F>false</DCC_F>
<DCC_K>false</DCC_K>
<DCC_ExeOutput>..\..\..\bin</DCC_ExeOutput>
<DCC_Define>CEFSUBPROCESS;$(DCC_Define)</DCC_Define>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
@ -112,6 +113,7 @@
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="uCEFLoader.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
@ -130,16 +132,21 @@
<BorlandProject>
<Delphi.Personality>
<Source>
<Source Name="MainSource">SubProcess.dpr</Source>
<Source Name="MainSource">SimpleBrowser_sp.dpr</Source>
</Source>
<Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl260.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\DataExplorerDBXPluginEnt260.bpl">DBExpress Enterprise Data Explorer Integration</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k260.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp260.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl270.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k270.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="..\..\..\bin\SimpleBrowser_sp.exe" Configuration="Release" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>SimpleBrowser_sp.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win32\Debug\SubProcess.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator">

View File

@ -6,7 +6,7 @@
<Projects Include="SimpleBrowser.dproj">
<Dependencies/>
</Projects>
<Projects Include="SubProcess.dproj">
<Projects Include="SimpleBrowser_sp.dproj">
<Dependencies/>
</Projects>
</ItemGroup>
@ -26,23 +26,23 @@
<Target Name="SimpleBrowser:Make">
<MSBuild Projects="SimpleBrowser.dproj" Targets="Make"/>
</Target>
<Target Name="SubProcess">
<MSBuild Projects="SubProcess.dproj"/>
<Target Name="SimpleBrowser_sp">
<MSBuild Projects="SimpleBrowser_sp.dproj"/>
</Target>
<Target Name="SubProcess:Clean">
<MSBuild Projects="SubProcess.dproj" Targets="Clean"/>
<Target Name="SimpleBrowser_sp:Clean">
<MSBuild Projects="SimpleBrowser_sp.dproj" Targets="Clean"/>
</Target>
<Target Name="SubProcess:Make">
<MSBuild Projects="SubProcess.dproj" Targets="Make"/>
<Target Name="SimpleBrowser_sp:Make">
<MSBuild Projects="SimpleBrowser_sp.dproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="SimpleBrowser;SubProcess"/>
<CallTarget Targets="SimpleBrowser;SimpleBrowser_sp"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="SimpleBrowser:Clean;SubProcess:Clean"/>
<CallTarget Targets="SimpleBrowser:Clean;SimpleBrowser_sp:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="SimpleBrowser:Make;SubProcess:Make"/>
<CallTarget Targets="SimpleBrowser:Make;SimpleBrowser_sp:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project>

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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';

View File

@ -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" : {