From 0acd59b3d263a8183db3972cbb662b2ec7cd47a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Tue, 27 Aug 2019 09:52:33 +0200 Subject: [PATCH] Update to CEF 76.1.10 - Added GlobalCEFApp.UseFakeUIForMediaStream - Added overloaded TCefBaseRefCountedOwn.SameAs --- README.md | 6 +-- demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas | 2 +- .../JavaScript/JSExtension/uJSExtension.pas | 4 +- .../JSRTTIExtension/uJSRTTIExtension.pas | 4 +- demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas | 1 + .../SimpleBrowser2/uSimpleBrowser2.dfm | 1 + .../SimpleBrowser2/uSimpleBrowser2.pas | 14 ++++++ .../SimpleOSRBrowser/uSimpleOSRBrowser.pas | 2 +- demos/Delphi_VCL/URLRequest/uURLRequest.pas | 1 + demos/Lazarus/DOMVisitor/uDOMVisitor.pas | 2 +- .../JavaScript/JSExtension/uJSExtension.pas | 6 +-- .../Lazarus/SimpleBrowser2/SimpleBrowser2.lpi | 1 - .../Lazarus/SimpleBrowser2/SimpleBrowser2.lps | 33 +++++++++++-- .../SimpleBrowser2/usimplelazarusbrowser.lfm | 5 +- .../SimpleBrowser2/usimplelazarusbrowser.pas | 13 ++++++ packages/cef4delphi_lazarus.lpk | 2 +- source/uCEFApplication.pas | 8 +++- source/uCEFBaseRefCounted.pas | 46 ++++++++++++++++++- source/uCEFInterfaces.pas | 3 +- update_CEF4Delphi.json | 4 +- 20 files changed, 130 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index b337695c..81b6254d 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ CEF4Delphi is an open source project created by Salvador D CEF4Delphi is based on DCEF3, made by Henri Gourvest. The original license of DCEF3 still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file. -CEF4Delphi uses CEF 76.1.9 which includes Chromium 76.0.3809.87. +CEF4Delphi uses CEF 76.1.10 which includes Chromium 76.0.3809.87. The CEF binaries used by CEF4Delphi are available for download at spotify : -* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_76.1.9%2Bg2cf916e%2Bchromium-76.0.3809.87_windows32.tar.bz2) -* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_76.1.9%2Bg2cf916e%2Bchromium-76.0.3809.87_windows64.tar.bz2) +* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_76.1.10%2Bg20d771a%2Bchromium-76.0.3809.87_windows32.tar.bz2) +* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_76.1.10%2Bg20d771a%2Bchromium-76.0.3809.87_windows64.tar.bz2) CEF4Delphi was developed and tested on Delphi 10.3 Rio and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2 and Lazarus 2.0.4/FPC 3.0.4. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. diff --git a/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas b/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas index b1f0cac1..edff340e 100644 --- a/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas +++ b/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas @@ -152,7 +152,7 @@ uses // procedure with a PID_RENDERER parameter. The render process receives those messages in // the GlobalCEFApp.OnProcessMessageReceived event. -// To send messages from the render process you must use the browser.SendProcessMessage +// To send messages from the render process you must use the frame.SendProcessMessage // procedure with a PID_BROWSER parameter. The browser process receives those messages in // the TChromium.OnProcessMessageReceived event. diff --git a/demos/Delphi_VCL/JavaScript/JSExtension/uJSExtension.pas b/demos/Delphi_VCL/JavaScript/JSExtension/uJSExtension.pas index dd08f1dd..b9a835cc 100644 --- a/demos/Delphi_VCL/JavaScript/JSExtension/uJSExtension.pas +++ b/demos/Delphi_VCL/JavaScript/JSExtension/uJSExtension.pas @@ -154,11 +154,11 @@ uses // extension called "myextension.mouseover". // The TTestExtensionHandler.Execute function is executed in the renderer process and it -// can use the TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg) function +// can use the TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage(PID_BROWSER, msg) function // to send a message with the results to the browser process. // TCefv8ContextRef.Current returns the v8 context for the frame that is currently -// executing JavaScript, TCefv8ContextRef.Current.Browser.SendProcessMessage sends a message +// executing JavaScript, TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage sends a message // to the right browser even if you have created several browsers in one app. // That message is received in the TChromium.OnProcessMessageReceived event. diff --git a/demos/Delphi_VCL/JavaScript/JSRTTIExtension/uJSRTTIExtension.pas b/demos/Delphi_VCL/JavaScript/JSRTTIExtension/uJSRTTIExtension.pas index cda79530..7e264e9c 100644 --- a/demos/Delphi_VCL/JavaScript/JSRTTIExtension/uJSRTTIExtension.pas +++ b/demos/Delphi_VCL/JavaScript/JSRTTIExtension/uJSRTTIExtension.pas @@ -135,10 +135,10 @@ uses // TTestExtension can send information back to the browser with a process message. // The TTestExtension.mouseover function do this by calling -// TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg); +// TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage(PID_BROWSER, msg); // TCefv8ContextRef.Current returns the v8 context for the frame that is currently executing JS, -// TCefv8ContextRef.Current.Browser.SendProcessMessage should send a message to the right browser even +// TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage should send a message to the right browser even // if you have created several browsers in one app. // That message is received in the TChromium.OnProcessMessageReceived event. diff --git a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas index 95b29e66..b969d898 100644 --- a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas +++ b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas @@ -289,6 +289,7 @@ begin GlobalCEFApp.DisableFeatures := 'NetworkService,OutOfBlinkCors'; GlobalCEFApp.LogFile := 'debug.log'; GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO; + //GlobalCEFApp.RemoteDebuggingPort := 19999; end; procedure TMiniBrowserFrm.BackBtnClick(Sender: TObject); diff --git a/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.dfm b/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.dfm index 4a4238d7..9e168af3 100644 --- a/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.dfm +++ b/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.dfm @@ -73,6 +73,7 @@ object Form1: TForm1 OnAfterCreated = Chromium1AfterCreated OnBeforeClose = Chromium1BeforeClose OnClose = Chromium1Close + OnOpenUrlFromTab = Chromium1OpenUrlFromTab Left = 56 Top = 152 end diff --git a/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas b/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas index b0d0aa74..9ba479d0 100644 --- a/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas +++ b/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas @@ -79,6 +79,11 @@ type var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean); + procedure Chromium1OpenUrlFromTab(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; + const targetUrl: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; + out Result: Boolean); protected // Variables to control when can we destroy the form safely FCanClose : boolean; // Set to True in TChromium.OnBeforeClose @@ -189,6 +194,15 @@ begin aAction := cbaDelay; end; +procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; + const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; + userGesture: Boolean; out Result: Boolean); +begin + // For simplicity, this demo blocks all popup windows and new tabs + Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]); +end; + procedure TForm1.BrowserCreatedMsg(var aMessage : TMessage); begin Caption := 'Simple Browser 2'; diff --git a/demos/Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas b/demos/Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas index a1a5cc10..414eaf7b 100644 --- a/demos/Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas +++ b/demos/Delphi_VCL/SimpleOSRBrowser/uSimpleOSRBrowser.pas @@ -422,7 +422,7 @@ begin end; end; -procedure TForm1.chrmosrPaint(Sender : TObject; +procedure TForm1.chrmosrPaint( Sender : TObject; const browser : ICefBrowser; kind : TCefPaintElementType; dirtyRectsCount : NativeUInt; diff --git a/demos/Delphi_VCL/URLRequest/uURLRequest.pas b/demos/Delphi_VCL/URLRequest/uURLRequest.pas index eae8dffd..220fbbed 100644 --- a/demos/Delphi_VCL/URLRequest/uURLRequest.pas +++ b/demos/Delphi_VCL/URLRequest/uURLRequest.pas @@ -72,6 +72,7 @@ type procedure CEFUrlRequestClientComponent1DownloadProgress(Sender: TObject; const request: ICefUrlRequest; current, total: Int64); procedure CEFUrlRequestClientComponent1RequestComplete(Sender: TObject; const request: ICefUrlRequest); procedure CEFUrlRequestClientComponent1CreateURLRequest(Sender: TObject); + private FStream : TMemoryStream; FCanClose : boolean; diff --git a/demos/Lazarus/DOMVisitor/uDOMVisitor.pas b/demos/Lazarus/DOMVisitor/uDOMVisitor.pas index b073ca28..6af6cacc 100644 --- a/demos/Lazarus/DOMVisitor/uDOMVisitor.pas +++ b/demos/Lazarus/DOMVisitor/uDOMVisitor.pas @@ -144,7 +144,7 @@ uses // procedure with a PID_RENDERER parameter. The render process receives those messages in // the GlobalCEFApp.OnProcessMessageReceived event. -// To send messages from the render process you must use the browser.SendProcessMessage +// To send messages from the render process you must use the frame.SendProcessMessage // procedure with a PID_BROWSER parameter. The browser process receives those messages in // the TChromium.OnProcessMessageReceived event. diff --git a/demos/Lazarus/JavaScript/JSExtension/uJSExtension.pas b/demos/Lazarus/JavaScript/JSExtension/uJSExtension.pas index 2f418ada..2752f2d8 100644 --- a/demos/Lazarus/JavaScript/JSExtension/uJSExtension.pas +++ b/demos/Lazarus/JavaScript/JSExtension/uJSExtension.pas @@ -1,4 +1,4 @@ -// ************************************************************************ +// ************************************************************************ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // @@ -159,11 +159,11 @@ uses // extension called "myextension.mouseover". // The TTestExtensionHandler.Execute function is executed in the renderer process and it -// can use the TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg) function +// can use the TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage(PID_BROWSER, msg) function // to send a message with the results to the browser process. // TCefv8ContextRef.Current returns the v8 context for the frame that is currently -// executing JavaScript, TCefv8ContextRef.Current.Browser.SendProcessMessage sends a message +// executing JavaScript, TCefv8ContextRef.Current.Browser.MainFrame.SendProcessMessage sends a message // to the right browser even if you have created several browsers in one app. // That message is received in the TChromium.OnProcessMessageReceived event. diff --git a/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lpi b/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lpi index ef8ffde5..803c24ea 100644 --- a/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lpi +++ b/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lpi @@ -42,7 +42,6 @@ - diff --git a/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lps b/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lps index bdd346d1..dac3d456 100644 --- a/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lps +++ b/demos/Lazarus/SimpleBrowser2/SimpleBrowser2.lps @@ -4,11 +4,11 @@ - + - + @@ -35,8 +35,8 @@ - - + + @@ -416,8 +416,15 @@ + + + + + + + - + @@ -430,6 +437,22 @@ + + + + + + + + + + + + + + + + diff --git a/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.lfm b/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.lfm index 6bb85bb3..2de5c6a8 100644 --- a/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.lfm +++ b/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.lfm @@ -1,7 +1,7 @@ object Form1: TForm1 - Left = 201 + Left = 407 Height = 574 - Top = 182 + Top = 183 Width = 878 Caption = 'Initializing browser. Please wait...' ClientHeight = 574 @@ -62,6 +62,7 @@ object Form1: TForm1 OnAfterCreated = Chromium1AfterCreated OnBeforeClose = Chromium1BeforeClose OnClose = Chromium1Close + OnOpenUrlFromTab = Chromium1OpenUrlFromTab left = 40 top = 136 end diff --git a/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.pas b/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.pas index f2e31efc..a4d9a9fc 100644 --- a/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.pas +++ b/demos/Lazarus/SimpleBrowser2/usimplelazarusbrowser.pas @@ -67,6 +67,10 @@ type var noJavascriptAccess: Boolean; var Result: Boolean); procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); + procedure Chromium1OpenUrlFromTab(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; + const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; + userGesture: Boolean; out Result: Boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); @@ -167,6 +171,15 @@ procedure TForm1.Chromium1BeforePopup(Sender: TObject; begin // For simplicity, this demo blocks all popup windows and new tabs Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]); +end; + +procedure TForm1.Chromium1OpenUrlFromTab(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out + Result: Boolean); +begin + // For simplicity, this demo blocks all popup windows and new tabs + Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]); end; procedure TForm1.Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk index 917a9ab3..13472d08 100644 --- a/packages/cef4delphi_lazarus.lpk +++ b/packages/cef4delphi_lazarus.lpk @@ -21,7 +21,7 @@ - + diff --git a/source/uCEFApplication.pas b/source/uCEFApplication.pas index 38c23ee6..96991478 100644 --- a/source/uCEFApplication.pas +++ b/source/uCEFApplication.pas @@ -62,7 +62,7 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 76; CEF_SUPPORTED_VERSION_MINOR = 1; - CEF_SUPPORTED_VERSION_RELEASE = 9; + CEF_SUPPORTED_VERSION_RELEASE = 10; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 76; @@ -121,6 +121,7 @@ type FFlashEnabled : boolean; FEnableMediaStream : boolean; FEnableSpeechInput : boolean; + FUseFakeUIForMediaStream : boolean; FEnableGPU : boolean; FCheckCEFFiles : boolean; FLibLoaded : boolean; @@ -389,6 +390,7 @@ type property FlashEnabled : boolean read FFlashEnabled write FFlashEnabled; property EnableMediaStream : boolean read FEnableMediaStream write FEnableMediaStream; property EnableSpeechInput : boolean read FEnableSpeechInput write FEnableSpeechInput; + property UseFakeUIForMediaStream : boolean read FUseFakeUIForMediaStream write FUseFakeUIForMediaStream; property EnableGPU : boolean read FEnableGPU write FEnableGPU; property CheckCEFFiles : boolean read FCheckCEFFiles write FCheckCEFFiles; property ShowMessageDlg : boolean read FShowMessageDlg write FShowMessageDlg; @@ -578,6 +580,7 @@ begin FFlashEnabled := True; FEnableMediaStream := True; FEnableSpeechInput := True; + FUseFakeUIForMediaStream := False; FEnableGPU := False; FCustomCommandLines := nil; FCustomCommandLineValues := nil; @@ -1608,6 +1611,9 @@ begin commandLine.AppendSwitchWithValue('--enable-media-stream', IntToStr(Ord(FEnableMediaStream))); commandLine.AppendSwitchWithValue('--enable-speech-input', IntToStr(Ord(FEnableSpeechInput))); + if FUseFakeUIForMediaStream then + commandLine.AppendSwitch('--use-fake-ui-for-media-stream'); + if not(FEnableGPU) then begin commandLine.AppendSwitch('--disable-gpu'); diff --git a/source/uCEFBaseRefCounted.pas b/source/uCEFBaseRefCounted.pas index edbb141e..41e5301a 100644 --- a/source/uCEFBaseRefCounted.pas +++ b/source/uCEFBaseRefCounted.pas @@ -76,7 +76,8 @@ type public constructor CreateData(size: Cardinal; owned : boolean = False); virtual; destructor Destroy; override; - function SameAs(aData : Pointer) : boolean; + function SameAs(aData : Pointer) : boolean; overload; + function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload; function Wrap: Pointer; end; @@ -90,7 +91,8 @@ type public constructor Create(data: Pointer); virtual; destructor Destroy; override; - function SameAs(aData : Pointer) : boolean; + function SameAs(aData : Pointer) : boolean; overload; + function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload; function Wrap: Pointer; class function UnWrap(data: Pointer): ICefBaseRefCounted; end; @@ -221,6 +223,26 @@ begin Result := (FData = aData); end; +function TCefBaseRefCountedOwn.SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; +var + TempData : Pointer; +begin + Result := False; + + if (aBaseRefCounted <> nil) then + begin + TempData := aBaseRefCounted.Wrap; + + if (TempData <> nil) then + begin + Result := SameAs(TempData); + + if assigned(PCefBaseRefCounted(TempData)^.release) then + PCefBaseRefCounted(TempData)^.release(PCefBaseRefCounted(TempData)); + end; + end; +end; + function TCefBaseRefCountedOwn.Wrap: Pointer; begin Result := FData; @@ -280,6 +302,26 @@ begin Result := (FData = aData); end; +function TCefBaseRefCountedRef.SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; +var + TempData : Pointer; +begin + Result := False; + + if (aBaseRefCounted <> nil) then + begin + TempData := aBaseRefCounted.Wrap; + + if (TempData <> nil) then + begin + Result := SameAs(TempData); + + if assigned(PCefBaseRefCounted(TempData)^.release) then + PCefBaseRefCounted(TempData)^.release(PCefBaseRefCounted(TempData)); + end; + end; +end; + class function TCefBaseRefCountedRef.UnWrap(data: Pointer): ICefBaseRefCounted; begin if (data <> nil) then diff --git a/source/uCEFInterfaces.pas b/source/uCEFInterfaces.pas index c287f9a4..3f96c726 100644 --- a/source/uCEFInterfaces.pas +++ b/source/uCEFInterfaces.pas @@ -442,7 +442,8 @@ type ICefBaseRefCounted = interface ['{1F9A7B44-DCDC-4477-9180-3ADD44BDEB7B}'] function Wrap: Pointer; - function SameAs(aData : Pointer) : boolean; + function SameAs(aData : Pointer) : boolean; overload; + function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload; function HasOneRef : boolean; function HasAtLeastOneRef : boolean; end; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 18497e92..22685a10 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 21, + "InternalVersion" : 22, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "76.1.9.0" + "Version" : "76.1.10.0" } ], "UpdatePackageData" : {