From 3bca41ef4a246df5b5756899916a918e713771bc Mon Sep 17 00:00:00 2001 From: salvadordf Date: Tue, 3 May 2022 12:43:16 +0200 Subject: [PATCH] Update to CEF 101.0.15 --- README.md | 16 +- demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm | 5 + demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas | 19 +++ .../MiniBrowser/uMiniBrowser.lfm | 5 + .../MiniBrowser/uMiniBrowser.pas | 35 +++- packages/CEF4Delphi.dpk | 3 +- packages/CEF4DelphiVCLRTL.dpk | 3 +- packages/CEF4DelphiVCLRTL.dproj | 1 + packages/cef4delphi_lazarus.lpk | 8 +- packages/cef4delphi_lazarus.pas | 2 +- source/uCEFApplicationCore.pas | 14 +- source/uCEFChromiumCore.pas | 44 ++++- source/uCEFChromiumEvents.pas | 4 + source/uCEFChromiumOptions.pas | 3 + source/uCEFClient.pas | 45 +++++- source/uCEFCommandHandler.pas | 151 ++++++++++++++++++ source/uCEFConstants.pas | 10 +- source/uCEFDownloadHandler.pas | 40 ++++- source/uCEFDragData.pas | 6 + source/uCEFInterfaces.pas | 19 ++- source/uCEFTypes.pas | 16 +- update_CEF4Delphi.json | 4 +- 22 files changed, 414 insertions(+), 39 deletions(-) create mode 100644 source/uCEFCommandHandler.pas diff --git a/README.md b/README.md index 7d11a896..cd93a395 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ 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 100.0.24 which includes Chromium 100.0.4896.127. +CEF4Delphi uses CEF 101.0.15 which includes Chromium 101.0.4951.54. The CEF binaries used by CEF4Delphi are available for download at Spotify : -* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_windows32.tar.bz2) -* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_windows64.tar.bz2) -* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_linux32.tar.bz2) -* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_linux64.tar.bz2) -* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_linuxarm.tar.bz2) -* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_linuxarm64.tar.bz2) -* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_100.0.24%2Bg0783cf8%2Bchromium-100.0.4896.127_macosx64.tar.bz2) +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_linuxarm64.tar.bz2) +* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_101.0.15%2Bgca159c5%2Bchromium-101.0.4951.54_macosx64.tar.bz2) CEF4Delphi was developed and tested on Delphi 11.1 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3, Delphi 10.4 and Lazarus 2.2.0/FPC 3.2.2. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. diff --git a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm index 26f6cf1d..6e53fc43 100644 --- a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm +++ b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm @@ -285,6 +285,7 @@ object MiniBrowserFrm: TMiniBrowserFrm OnStatusMessage = Chromium1StatusMessage OnLoadingProgressChange = Chromium1LoadingProgressChange OnCursorChange = Chromium1CursorChange + OnCanDownload = Chromium1CanDownload OnBeforeDownload = Chromium1BeforeDownload OnDownloadUpdated = Chromium1DownloadUpdated OnAfterCreated = Chromium1AfterCreated @@ -398,6 +399,10 @@ object MiniBrowserFrm: TMiniBrowserFrm Caption = 'User agent...' OnClick = Useragent1Click end + object Allowdownloads1: TMenuItem + Caption = 'Allow downloads' + OnClick = Allowdownloads1Click + end object N5: TMenuItem Caption = '-' end diff --git a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas index 50ccd671..ede04203 100644 --- a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas +++ b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas @@ -145,6 +145,7 @@ type ClearallstorageforcurrentURL1: TMenuItem; CEFinfo1: TMenuItem; SaveasMHTML1: TMenuItem; + Allowdownloads1: TMenuItem; procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); @@ -186,6 +187,7 @@ type procedure Chromium1FileDialog(Sender: TObject; const browser: ICefBrowser; mode: Cardinal; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback; out Result: Boolean); procedure Chromium1SelectClientCertificate(Sender: TObject; const browser: ICefBrowser; isProxy: Boolean; const host: ustring; port: Integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback; var aResult: Boolean); procedure Chromium1CursorChange(Sender: TObject; const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult: Boolean); + procedure Chromium1CanDownload(Sender: TObject; const browser: ICefBrowser; const url, request_method: ustring; var aResult: Boolean); procedure BackBtnClick(Sender: TObject); procedure ForwardBtnClick(Sender: TObject); @@ -217,6 +219,7 @@ type procedure ClearallstorageforcurrentURL1Click(Sender: TObject); procedure CEFinfo1Click(Sender: TObject); procedure SaveasMHTML1Click(Sender: TObject); + procedure Allowdownloads1Click(Sender: TObject); protected FPendingMsgID : integer; @@ -225,6 +228,7 @@ type FHasShutdownReason : boolean; FSelectCertCallback : ICefSelectClientCertificateCallback; FCertificates : TCefX509CertificateArray; + FAllowDownloads : boolean; FResponse : TStringList; FRequest : TStringList; @@ -482,6 +486,13 @@ begin InspectRequest(request); end; +procedure TMiniBrowserFrm.Chromium1CanDownload(Sender: TObject; + const browser: ICefBrowser; const url, request_method: ustring; + var aResult: Boolean); +begin + aResult := FAllowDownloads; +end; + procedure TMiniBrowserFrm.Chromium1CertificateError(Sender: TObject; const browser: ICefBrowser; certError: Integer; const requestUrl: ustring; const sslInfo: ICefSslInfo; @@ -872,6 +883,11 @@ begin end; end; +procedure TMiniBrowserFrm.Allowdownloads1Click(Sender: TObject); +begin + FAllowDownloads := not(FAllowDownloads); +end; + procedure TMiniBrowserFrm.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); begin @@ -1263,6 +1279,7 @@ begin FSelectCertCallback := nil; FCertificates := nil; FPendingMsgID := 0; + FAllowDownloads := True; // Windows may show this text message while shutting down the operating system FShutdownReason := 'MiniBrowser closing...'; @@ -1584,6 +1601,8 @@ begin DevTools1.Caption := 'Hide DevTools' else DevTools1.Caption := 'Show DevTools'; + + Allowdownloads1.Checked := FAllowDownloads; end; procedure TMiniBrowserFrm.Preferences1Click(Sender: TObject); diff --git a/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.lfm b/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.lfm index b33ed371..0c6e0025 100644 --- a/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.lfm +++ b/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.lfm @@ -258,6 +258,7 @@ object MiniBrowserFrm: TMiniBrowserFrm OnStatusMessage = Chromium1StatusMessage OnLoadingProgressChange = Chromium1LoadingProgressChange OnCursorChange = Chromium1CursorChange + OnCanDownload = Chromium1CanDownload OnBeforeDownload = Chromium1BeforeDownload OnDownloadUpdated = Chromium1DownloadUpdated OnAfterCreated = Chromium1AfterCreated @@ -349,6 +350,10 @@ object MiniBrowserFrm: TMiniBrowserFrm Caption = 'Flush cookies' OnClick = MenuItem3Click end + object Allowdownloads1: TMenuItem + Caption = 'Allow downloads' + OnClick = Allowdownloads1Click + end object N5: TMenuItem Caption = '-' end diff --git a/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.pas b/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.pas index 05136824..d0955f4f 100644 --- a/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.pas +++ b/demos/Lazarus_Windows/MiniBrowser/uMiniBrowser.pas @@ -94,6 +94,7 @@ type MenuItem4: TMenuItem; MenuItem5: TMenuItem; MenuItem6: TMenuItem; + Allowdownloads1: TMenuItem; NavControlPnl: TPanel; NavButtonPnl: TPanel; StatusPnl: TPanel; @@ -132,7 +133,10 @@ type OpenfilewithaDAT1: TMenuItem; N5: TMenuItem; Memoryinfo1: TMenuItem; + procedure Allowdownloads1Click(Sender: TObject); procedure CEFWindowParent1DragDrop(Sender, Source: TObject; X, Y: Integer); + procedure Chromium1CanDownload(Sender: TObject; const browser: ICefBrowser; + const url, request_method: ustring; var aResult: boolean); procedure Chromium1CookiesFlushed(Sender: TObject); procedure Chromium1CursorChange(Sender: TObject; const browser: ICefBrowser; cursor_: TCefCursorHandle; @@ -246,11 +250,12 @@ type var aResult: Boolean); protected - FResponse : TStringList; - FRequest : TStringList; - FNavigation : TStringList; - FShutdownReason : string; - FHasShutdownReason : boolean; + FResponse : TStringList; + FRequest : TStringList; + FNavigation : TStringList; + FShutdownReason : string; + FHasShutdownReason : boolean; + FAllowDownloads : boolean; // Variables to control when can we destroy the form safely FCanClose : boolean; // Set to True in TChromium.OnBeforeClose @@ -323,7 +328,8 @@ begin GlobalCEFApp.cache := 'cache'; GlobalCEFApp.LogFile := 'debug.log'; GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO; - GlobalCEFApp.EnablePrintPreview := True; + GlobalCEFApp.EnablePrintPreview := True; + GlobalCEFApp.EnableGPU := True; end; procedure TMiniBrowserFrm.BackBtnClick(Sender: TObject); @@ -1065,6 +1071,7 @@ begin FRequest := TStringList.Create; FNavigation := TStringList.Create; FPendingMsgID := 0; + FAllowDownloads := True; // Windows may show this text message while shutting down the operating system FShutdownReason := 'MiniBrowser closing...'; @@ -1183,6 +1190,18 @@ begin end; +procedure TMiniBrowserFrm.Chromium1CanDownload(Sender: TObject; + const browser: ICefBrowser; const url, request_method: ustring; + var aResult: boolean); +begin + aResult := FAllowDownloads; +end; + +procedure TMiniBrowserFrm.Allowdownloads1Click(Sender: TObject); +begin + FAllowDownloads := not(FAllowDownloads); +end; + procedure TMiniBrowserFrm.CookiesFlushedMsg(var aMessage : TMessage); begin showmessage('The cookies were flushed successfully'); @@ -1410,7 +1429,9 @@ begin if DevTools.Visible then DevTools1.Caption := 'Hide DevTools' else - DevTools1.Caption := 'Show DevTools'; + DevTools1.Caption := 'Show DevTools'; + + Allowdownloads1.Checked := FAllowDownloads; end; procedure TMiniBrowserFrm.Preferences1Click(Sender: TObject); diff --git a/packages/CEF4Delphi.dpk b/packages/CEF4Delphi.dpk index ac4f7e1c..5bda59d5 100644 --- a/packages/CEF4Delphi.dpk +++ b/packages/CEF4Delphi.dpk @@ -222,7 +222,8 @@ contains uCEFTimerWorkScheduler in '..\source\uCEFTimerWorkScheduler.pas', uCEFFrameHandler in '..\source\uCEFFrameHandler.pas', uCEFOverlayController in '..\source\uCEFOverlayController.pas', - uCEFFileDialogInfo in '..\source\uCEFFileDialogInfo.pas'; + uCEFFileDialogInfo in '..\source\uCEFFileDialogInfo.pas', + uCEFCommandHandler in '..\source\uCEFCommandHandler.pas'; end. diff --git a/packages/CEF4DelphiVCLRTL.dpk b/packages/CEF4DelphiVCLRTL.dpk index 1829114d..3353ad79 100644 --- a/packages/CEF4DelphiVCLRTL.dpk +++ b/packages/CEF4DelphiVCLRTL.dpk @@ -222,7 +222,8 @@ contains uCEFFrameHandler in '..\source\uCEFFrameHandler.pas', uCEFOverlayController in '..\source\uCEFOverlayController.pas', uCEFFileDialogInfo in '..\source\uCEFFileDialogInfo.pas', - uCEFArgCopy in '..\source\uCEFArgCopy.pas'; + uCEFArgCopy in '..\source\uCEFArgCopy.pas', + uCEFCommandHandler in '..\source\uCEFCommandHandler.pas'; end. diff --git a/packages/CEF4DelphiVCLRTL.dproj b/packages/CEF4DelphiVCLRTL.dproj index 481a7861..7dc640fd 100644 --- a/packages/CEF4DelphiVCLRTL.dproj +++ b/packages/CEF4DelphiVCLRTL.dproj @@ -304,6 +304,7 @@ + Base diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk index e2ff69ee..fdfba58a 100644 --- a/packages/cef4delphi_lazarus.lpk +++ b/packages/cef4delphi_lazarus.lpk @@ -21,8 +21,8 @@ - - + + @@ -845,6 +845,10 @@ + + + + diff --git a/packages/cef4delphi_lazarus.pas b/packages/cef4delphi_lazarus.pas index a9c7fe4b..66629607 100644 --- a/packages/cef4delphi_lazarus.pas +++ b/packages/cef4delphi_lazarus.pas @@ -66,7 +66,7 @@ uses uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa, uCEFBrowserWindow, uCEFOsrBrowserWindow, uCEFTimerWorkScheduler, uCEFFrameHandler, uCEFOverlayController, uCEFFileDialogInfo, uCEFArgCopy, - LazarusPackageIntf; + uCEFCommandHandler, LazarusPackageIntf; implementation diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas index f0e2c32d..2147f904 100644 --- a/source/uCEFApplicationCore.pas +++ b/source/uCEFApplicationCore.pas @@ -66,15 +66,15 @@ uses uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar; const - CEF_SUPPORTED_VERSION_MAJOR = 100; + CEF_SUPPORTED_VERSION_MAJOR = 101; CEF_SUPPORTED_VERSION_MINOR = 0; - CEF_SUPPORTED_VERSION_RELEASE = 24; + CEF_SUPPORTED_VERSION_RELEASE = 15; CEF_SUPPORTED_VERSION_BUILD = 0; - CEF_CHROMEELF_VERSION_MAJOR = 100; + CEF_CHROMEELF_VERSION_MAJOR = 101; CEF_CHROMEELF_VERSION_MINOR = 0; - CEF_CHROMEELF_VERSION_RELEASE = 4896; - CEF_CHROMEELF_VERSION_BUILD = 127; + CEF_CHROMEELF_VERSION_RELEASE = 4951; + CEF_CHROMEELF_VERSION_BUILD = 54; {$IFDEF MSWINDOWS} LIBCEF_DLL = 'libcef.dll'; @@ -131,7 +131,6 @@ type FAcceptLanguageList : ustring; FCookieableSchemesList : ustring; FCookieableSchemesExcludeDefaults : boolean; - FApplicationClientID : ustring; // Fields used to set command line switches FSingleProcess : boolean; @@ -446,7 +445,6 @@ type property AcceptLanguageList : ustring read FAcceptLanguageList write FAcceptLanguageList; property CookieableSchemesList : ustring read FCookieableSchemesList write FCookieableSchemesList; property CookieableSchemesExcludeDefaults : boolean read FCookieableSchemesExcludeDefaults write FCookieableSchemesExcludeDefaults; - property ApplicationClientID : ustring read FApplicationClientID write FApplicationClientID; // Properties used to set command line switches property SingleProcess : Boolean read FSingleProcess write FSingleProcess; // --single-process @@ -694,7 +692,6 @@ begin FAcceptLanguageList := ''; FCookieableSchemesList := ''; FCookieableSchemesExcludeDefaults := False; - FApplicationClientID := ''; // Fields used to set command line switches FSingleProcess := False; @@ -1426,7 +1423,6 @@ begin aSettings.accept_language_list := CefString(FAcceptLanguageList); aSettings.cookieable_schemes_list := CefString(FCookieableSchemesList); aSettings.cookieable_schemes_exclude_defaults := Ord(FCookieableSchemesExcludeDefaults); - aSettings.application_client_id_for_file_scanning := CefString(FApplicationClientID); end; function TCefApplicationCore.InitializeLibrary(const aApp : ICefApp) : boolean; diff --git a/source/uCEFChromiumCore.pas b/source/uCEFChromiumCore.pas index c0fd87fa..dcea1353 100644 --- a/source/uCEFChromiumCore.pas +++ b/source/uCEFChromiumCore.pas @@ -198,6 +198,7 @@ type FOnCursorChange : TOnCursorChange; // ICefDownloadHandler + FOnCanDownload : TOnCanDownloadEvent; FOnBeforeDownload : TOnBeforeDownload; FOnDownloadUpdated : TOnDownloadUpdated; @@ -316,6 +317,9 @@ type FOnFrameDetached : TOnFrameDetached; FOnMainFrameChanged : TOnMainFrameChanged; + // ICefCommandHandler + FOnChromeCommand : TOnChromeCommandEvent; + // Custom FOnTextResultAvailable : TOnTextResultAvailableEvent; FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; @@ -534,6 +538,7 @@ type procedure doOnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); virtual; // ICefDownloadHandler + function doOnCanDownload(const browser: ICefBrowser; const url, request_method: ustring): boolean; procedure doOnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); virtual; procedure doOnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); virtual; @@ -649,6 +654,9 @@ type procedure doOnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame); procedure doOnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame); + // ICefCommandHandler + function doOnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; + // Custom procedure GetSettings(var aSettings : TCefBrowserSettings); procedure doCookiesDeleted(numDeleted : integer); virtual; @@ -678,6 +686,7 @@ type procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); virtual; procedure doBrowserNavigation(aTask : TCefBrowserNavigation); virtual; function MustCreateAudioHandler : boolean; virtual; + function MustCreateCommandHandler : boolean; virtual; function MustCreateDevToolsMessageObserver : boolean; virtual; function MustCreateLoadHandler : boolean; virtual; function MustCreateFocusHandler : boolean; virtual; @@ -1016,6 +1025,7 @@ type property OnCursorChange : TOnCursorChange read FOnCursorChange write FOnCursorChange; // ICefDownloadHandler + property OnCanDownload : TOnCanDownloadEvent read FOnCanDownload write FOnCanDownload; property OnBeforeDownload : TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload; property OnDownloadUpdated : TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated; @@ -1135,6 +1145,9 @@ type property OnFrameAttached : TOnFrameAttached read FOnFrameAttached write FOnFrameAttached; property OnFrameDetached : TOnFrameDetached read FOnFrameDetached write FOnFrameDetached; property OnMainFrameChanged : TOnMainFrameChanged read FOnMainFrameChanged write FOnMainFrameChanged; + + // ICefCommandHandler + property OnChromeCommand : TOnChromeCommandEvent read FOnChromeCommand write FOnChromeCommand; end; TBrowserInfo = class @@ -1734,6 +1747,7 @@ begin FOnCursorChange := nil; // ICefDownloadHandler + FOnCanDownload := nil; FOnBeforeDownload := nil; FOnDownloadUpdated := nil; @@ -1852,6 +1866,9 @@ begin FOnFrameDetached := nil; FOnMainFrameChanged := nil; + // ICefCommandHandler + FOnChromeCommand := nil; + // Custom FOnTextResultAvailable := nil; FOnPdfPrintFinished := nil; @@ -2387,6 +2404,7 @@ begin aSettings.webgl := FOptions.Webgl; aSettings.background_color := FOptions.BackgroundColor; aSettings.accept_language_list := CefString(FOptions.AcceptLanguageList); + aSettings.chrome_status_bubble := FOptions.ChromeStatusBubble; end; end; @@ -4724,7 +4742,8 @@ end; function TChromiumCore.MustCreateDownloadHandler : boolean; begin - Result := assigned(FOnBeforeDownload) or + Result := assigned(FOnCanDownload) or + assigned(FOnBeforeDownload) or assigned(FOnDownloadUpdated); end; @@ -4839,6 +4858,11 @@ begin assigned(FOnMainFrameChanged); end; +function TChromiumCore.MustCreateCommandHandler : boolean; +begin + Result := assigned(FOnChromeCommand); +end; + {$IFDEF MSWINDOWS} procedure TChromiumCore.PrefsAvailableMsg(aResultOK : boolean); begin @@ -5285,6 +5309,16 @@ begin FOnRunContextMenu(Self, browser, frame, params, model, callback, Result); end; +function TChromiumCore.doOnCanDownload(const browser : ICefBrowser; + const url : ustring; + const request_method : ustring): boolean; +begin + Result := True; + + if assigned(FOnCanDownload) then + FOnCanDownload(Self, browser, url, request_method, Result); +end; + procedure TChromiumCore.doOnBeforeDownload(const browser : ICefBrowser; const downloadItem : ICefDownloadItem; const suggestedName : ustring; @@ -5795,6 +5829,14 @@ begin FOnMainFrameChanged(self, browser, old_frame, new_frame); end; +function TChromiumCore.doOnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; +begin + Result := False; + + if assigned(FOnChromeCommand) then + FOnChromeCommand(self, browser, command_id, disposition, Result); +end; + procedure TChromiumCore.doOnFullScreenModeChange(const browser : ICefBrowser; fullscreen : Boolean); begin diff --git a/source/uCEFChromiumEvents.pas b/source/uCEFChromiumEvents.pas index d58eb169..6f871b0e 100644 --- a/source/uCEFChromiumEvents.pas +++ b/source/uCEFChromiumEvents.pas @@ -94,6 +94,7 @@ type TOnCursorChange = procedure(Sender: TObject; const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean) of Object; // ICefDownloadHandler + TOnCanDownloadEvent = procedure(Sender: TObject; const browser: ICefBrowser; const url, request_method: ustring; var aResult: boolean) of object; TOnBeforeDownload = procedure(Sender: TObject; const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback) of object; TOnDownloadUpdated = procedure(Sender: TObject; const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback) of object; @@ -212,6 +213,9 @@ type TOnFrameDetached = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame) of object; TOnMainFrameChanged = procedure(Sender: TObject; const browser: ICefBrowser; const old_frame, new_frame: ICefFrame) of object; + // ICefCommandHandler + TOnChromeCommandEvent = procedure(Sender: TObject; const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition; var aResult: boolean) of object; + // Custom TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object; TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; diff --git a/source/uCEFChromiumOptions.pas b/source/uCEFChromiumOptions.pas index 5b374b7b..52677527 100644 --- a/source/uCEFChromiumOptions.pas +++ b/source/uCEFChromiumOptions.pas @@ -73,6 +73,7 @@ type FWebgl : TCefState; FBackgroundColor : TCefColor; FAcceptLanguageList : ustring; + FChromeStatusBubble : TCefState; public constructor Create; virtual; @@ -92,6 +93,7 @@ type property BackgroundColor : TCefColor read FBackgroundColor write FBackgroundColor default 0; property AcceptLanguageList : ustring read FAcceptLanguageList write FAcceptLanguageList; property WindowlessFrameRate : Integer read FWindowlessFrameRate write FWindowlessFrameRate default CEF_OSR_FRAMERATE_DEFAULT; + property ChromeStatusBubble : TCefState read FChromeStatusBubble write FChromeStatusBubble default STATE_DEFAULT; end; implementation @@ -111,6 +113,7 @@ begin FDatabases := STATE_DEFAULT; FWebgl := STATE_DEFAULT; FBackgroundColor := 0; + FChromeStatusBubble := STATE_DEFAULT; end; end. diff --git a/source/uCEFClient.pas b/source/uCEFClient.pas index 0083f64b..94f3dd91 100644 --- a/source/uCEFClient.pas +++ b/source/uCEFClient.pas @@ -55,6 +55,7 @@ type TCefClientRef = class(TCefBaseRefCountedRef, ICefClient) protected procedure GetAudioHandler(var aHandler : ICefAudioHandler); virtual; + procedure GetCommandHandler(var aHandler : ICefCommandHandler); virtual; procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); virtual; procedure GetDialogHandler(var aHandler : ICefDialogHandler); virtual; procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); virtual; @@ -81,6 +82,7 @@ type TCefClientOwn = class(TCefBaseRefCountedOwn, ICefClient) protected procedure GetAudioHandler(var aHandler : ICefAudioHandler); virtual; + procedure GetCommandHandler(var aHandler : ICefCommandHandler); virtual; procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); virtual; procedure GetDialogHandler(var aHandler : ICefDialogHandler); virtual; procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); virtual; @@ -108,6 +110,7 @@ type protected FEvents : Pointer; FAudioHandler : ICefAudioHandler; + FCommandHandler : ICefCommandHandler; FLoadHandler : ICefLoadHandler; FFocusHandler : ICefFocusHandler; FContextMenuHandler : ICefContextMenuHandler; @@ -125,6 +128,7 @@ type FFrameHandler : ICefFrameHandler; procedure GetAudioHandler(var aHandler : ICefAudioHandler); override; + procedure GetCommandHandler(var aHandler : ICefCommandHandler); override; procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); override; procedure GetDialogHandler(var aHandler : ICefDialogHandler); override; procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); override; @@ -163,7 +167,7 @@ uses uCEFDisplayHandler, uCEFDownloadHandler, uCEFJsDialogHandler, uCEFLifeSpanHandler, uCEFRequestHandler, uCEFRenderHandler, uCEFDragHandler, uCEFFindHandler, uCEFConstants, uCEFApplicationCore, uCEFFrame, uCEFAudioHandler, - uCEFPrintHandler, uCEFFrameHandler; + uCEFPrintHandler, uCEFFrameHandler, uCEFCommandHandler; // ****************************************************** @@ -183,6 +187,11 @@ begin aHandler := nil; end; +procedure TCefClientRef.GetCommandHandler(var aHandler : ICefCommandHandler); +begin + aHandler := nil; +end; + procedure TCefClientRef.GetContextMenuHandler(var aHandler : ICefContextMenuHandler); begin aHandler := nil; @@ -291,6 +300,23 @@ begin end; end; +function cef_client_own_get_command_handler(self: PCefClient): PCefCommandHandler; stdcall; +var + TempObject : TObject; + TempHandler : ICefCommandHandler; +begin + Result := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefClientOwn) then + try + TCefClientOwn(TempObject).GetCommandHandler(TempHandler); + if (TempHandler <> nil) then Result := TempHandler.Wrap; + finally + TempHandler := nil; + end; +end; + function cef_client_own_get_context_menu_handler(self: PCefClient): PCefContextMenuHandler; stdcall; var TempObject : TObject; @@ -572,6 +598,7 @@ begin with PCefClient(FData)^ do begin get_audio_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_audio_handler; + get_command_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_command_handler; get_context_menu_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_context_menu_handler; get_dialog_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_dialog_handler; get_display_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_display_handler; @@ -596,6 +623,11 @@ begin aHandler := nil; end; +procedure TCefClientOwn.GetCommandHandler(var aHandler : ICefCommandHandler); +begin + aHandler := nil; +end; + procedure TCefClientOwn.GetContextMenuHandler(var aHandler : ICefContextMenuHandler); begin aHandler := nil; @@ -707,6 +739,7 @@ begin else begin if events.MustCreateAudioHandler then FAudioHandler := TCustomAudioHandler.Create(events); + if events.MustCreateCommandHandler then FCommandHandler := TCustomCommandHandler.Create(events); if events.MustCreateLoadHandler then FLoadHandler := TCustomLoadHandler.Create(events); if events.MustCreateFocusHandler then FFocusHandler := TCustomFocusHandler.Create(events); if events.MustCreateContextMenuHandler then FContextMenuHandler := TCustomContextMenuHandler.Create(events); @@ -738,6 +771,7 @@ begin FEvents := nil; if (FAudioHandler <> nil) then FAudioHandler.RemoveReferences; + if (FCommandHandler <> nil) then FCommandHandler.RemoveReferences; if (FLoadHandler <> nil) then FLoadHandler.RemoveReferences; if (FFocusHandler <> nil) then FFocusHandler.RemoveReferences; if (FContextMenuHandler <> nil) then FContextMenuHandler.RemoveReferences; @@ -758,6 +792,7 @@ end; procedure TCustomClientHandler.InitializeVars; begin FAudioHandler := nil; + FCommandHandler := nil; FLoadHandler := nil; FFocusHandler := nil; FContextMenuHandler := nil; @@ -784,6 +819,14 @@ begin aHandler := nil; end; +procedure TCustomClientHandler.GetCommandHandler(var aHandler : ICefCommandHandler); +begin + if (FCommandHandler <> nil) then + aHandler := FCommandHandler + else + aHandler := nil; +end; + procedure TCustomClientHandler.GetContextMenuHandler(var aHandler : ICefContextMenuHandler); begin if (FContextMenuHandler <> nil) then diff --git a/source/uCEFCommandHandler.pas b/source/uCEFCommandHandler.pas new file mode 100644 index 00000000..74fffee8 --- /dev/null +++ b/source/uCEFCommandHandler.pas @@ -0,0 +1,151 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2022 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFCommandHandler; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefCommandHandlerOwn = class(TCefBaseRefCountedOwn, ICefCommandHandler) + protected + function OnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; virtual; + + procedure RemoveReferences; virtual; + + public + constructor Create; virtual; + end; + + TCustomCommandHandler = class(TCefCommandHandlerOwn) + protected + FEvents : Pointer; + + function OnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; override; + + procedure RemoveReferences; override; + + public + constructor Create(const events : IChromiumEvents); reintroduce; virtual; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser; + +function cef_command_handler_on_chrome_command(self : PCefCommandHandler; + browser : PCefBrowser; + command_id : integer; + disposition : TCefWindowOpenDisposition): Integer; stdcall; +var + TempObject : TObject; +begin + Result := Ord(False); + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefCommandHandlerOwn) then + Result := Ord(TCefCommandHandlerOwn(TempObject).OnChromeCommand(TCefBrowserRef.UnWrap(browser), + command_id, + disposition)); +end; + +constructor TCefCommandHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefCommandHandler)); + + PCefCommandHandler(FData)^.on_chrome_command := {$IFDEF FPC}@{$ENDIF}cef_command_handler_on_chrome_command; +end; + +function TCefCommandHandlerOwn.OnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; +begin + Result := False; +end; + +procedure TCefCommandHandlerOwn.RemoveReferences; +begin + // +end; + + +// TCustomCommandHandler + +constructor TCustomCommandHandler.Create(const events : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomCommandHandler.Destroy; +begin + RemoveReferences; + + inherited Destroy; +end; + +procedure TCustomCommandHandler.RemoveReferences; +begin + FEvents := nil; +end; + +function TCustomCommandHandler.OnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; +begin + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnChromeCommand(browser, command_id, disposition) + else + Result := inherited OnChromeCommand(browser, command_id, disposition); +end; + +end. diff --git a/source/uCEFConstants.pas b/source/uCEFConstants.pas index ee452d66..775d254e 100644 --- a/source/uCEFConstants.pas +++ b/source/uCEFConstants.pas @@ -381,14 +381,21 @@ const // /include/internal/cef_types.h (cef_transition_type_t) TT_LINK = 0; TT_EXPLICIT = 1; + TT_AUTO_BOOKMARK = 2; TT_AUTO_SUBFRAME = 3; TT_MANUAL_SUBFRAME = 4; + TT_GENERATED = 5; + TT_AUTO_TOPLEVEL = 6; TT_FORM_SUBMIT = 7; TT_RELOAD = 8; + TT_KEYWORD = 9; + TT_KEYWORD_GENERATED = 10; TT_SOURCE_MASK = $000000FF; TT_BLOCKED_FLAG = $00800000; TT_FORWARD_BACK_FLAG = $01000000; TT_DIRECT_LOAD_FLAG = $02000000; + TT_HOME_PAGE_FLAG = $04000000; + TT_FROM_API_FLAG = $08000000; TT_CHAIN_START_FLAG = $10000000; TT_CHAIN_END_FLAG = $20000000; TT_CLIENT_REDIRECT_FLAG = $40000000; @@ -751,7 +758,8 @@ const {$IFDEF CEF4DELHI_ALLOC_DEBUG} CEF4DELPHI_ALLOC_PADDING = Pointer($44332211); // Some random value used as padding {$ENDIF} -implementation + + implementation end. diff --git a/source/uCEFDownloadHandler.pas b/source/uCEFDownloadHandler.pas index 15058c21..7f2e4be4 100644 --- a/source/uCEFDownloadHandler.pas +++ b/source/uCEFDownloadHandler.pas @@ -54,6 +54,7 @@ uses type TCefDownloadHandlerOwn = class(TCefBaseRefCountedOwn, ICefDownloadHandler) protected + function CanDownload(const browser: ICefBrowser; const url, request_method: ustring): boolean; virtual; procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); virtual; procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); virtual; @@ -67,6 +68,7 @@ type protected FEvents : Pointer; + function CanDownload(const browser: ICefBrowser; const url, request_method: ustring): boolean; override; procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); override; procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); override; @@ -83,6 +85,22 @@ uses uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFDownLoadItem, uCEFBeforeDownloadCallback, uCEFDownloadItemCallback; +function cef_download_handler_can_download( self : PCefDownloadHandler; + browser : PCefBrowser; + const url : PCefString; + const request_method : PCefString): integer; stdcall; +var + TempObject : TObject; +begin + Result := Ord(True); + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefDownloadHandlerOwn) then + Result := Ord(TCefDownloadHandlerOwn(TempObject).CanDownload(TCefBrowserRef.UnWrap(browser), + CefString(url), + CefString(request_method))); +end; + procedure cef_download_handler_on_before_download( self : PCefDownloadHandler; browser : PCefBrowser; download_item : PCefDownloadItem; @@ -121,11 +139,17 @@ begin with PCefDownloadHandler(FData)^ do begin + can_download := {$IFDEF FPC}@{$ENDIF}cef_download_handler_can_download; on_before_download := {$IFDEF FPC}@{$ENDIF}cef_download_handler_on_before_download; on_download_updated := {$IFDEF FPC}@{$ENDIF}cef_download_handler_on_download_updated; end; end; +function TCefDownloadHandlerOwn.CanDownload(const browser: ICefBrowser; const url, request_method: ustring): boolean; +begin + Result := True; +end; + procedure TCefDownloadHandlerOwn.OnBeforeDownload(const browser : ICefBrowser; const downloadItem : ICefDownloadItem; const suggestedName : ustring; @@ -167,19 +191,31 @@ begin FEvents := nil; end; +function TCustomDownloadHandler.CanDownload(const browser : ICefBrowser; + const url : ustring; + const request_method : ustring): boolean; +begin + Result := True; + + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnCanDownload(browser, url, request_method); +end; + procedure TCustomDownloadHandler.OnBeforeDownload(const browser : ICefBrowser; const downloadItem : ICefDownloadItem; const suggestedName : ustring; const callback : ICefBeforeDownloadCallback); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnBeforeDownload(browser, downloadItem, suggestedName, callback); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnBeforeDownload(browser, downloadItem, suggestedName, callback); end; procedure TCustomDownloadHandler.OnDownloadUpdated(const browser : ICefBrowser; const downloadItem : ICefDownloadItem; const callback : ICefDownloadItemCallback); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnDownloadUpdated(browser, downloadItem, callback); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnDownloadUpdated(browser, downloadItem, callback); end; end. diff --git a/source/uCEFDragData.pas b/source/uCEFDragData.pas index 1baa3103..60013641 100644 --- a/source/uCEFDragData.pas +++ b/source/uCEFDragData.pas @@ -81,6 +81,7 @@ type procedure SetFragmentBaseUrl(const baseUrl: ustring); procedure ResetFileContents; procedure AddFile(const path, displayName: ustring); + procedure ClearFilenames; function GetImage : ICefImage; function GetImageHotspot : TCefPoint; function HasImage : boolean; @@ -103,6 +104,11 @@ begin PCefDragData(FData)^.add_file(FData, @TempPath, @TempName); end; +procedure TCefDragDataRef.ClearFilenames; +begin + PCefDragData(FData)^.clear_filenames(FData); +end; + function TCefDragDataRef.GetImage : ICefImage; begin Result := TCefImageRef.UnWrap(PCefDragData(FData)^.get_image(FData)); diff --git a/source/uCEFInterfaces.pas b/source/uCEFInterfaces.pas index 2a7a7de9..deab6545 100644 --- a/source/uCEFInterfaces.pas +++ b/source/uCEFInterfaces.pas @@ -102,6 +102,7 @@ type ICefRenderProcessHandler = interface; ICefProcessMessage = interface; ICefLifeSpanHandler = interface; + ICefCommandHandler = interface; ICefGetExtensionResourceCallback = interface; ICefExtensionHandler = interface; ICefExtension = interface; @@ -346,6 +347,7 @@ type procedure doOnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); // ICefDownloadHandler + function doOnCanDownload(const browser: ICefBrowser; const url, request_method: ustring): boolean; procedure doOnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); procedure doOnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); @@ -461,6 +463,9 @@ type procedure doOnFrameDetached(const browser: ICefBrowser; const frame: ICefFrame); procedure doOnMainFrameChanged(const browser: ICefBrowser; const old_frame, new_frame: ICefFrame); + // ICefCommandHandler + function doOnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; + // Custom procedure doCookiesDeleted(numDeleted : integer); procedure doPdfPrintFinished(aResultOK : boolean); @@ -489,6 +494,7 @@ type procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); procedure doBrowserNavigation(aTask : TCefBrowserNavigation); function MustCreateAudioHandler : boolean; + function MustCreateCommandHandler : boolean; function MustCreateLoadHandler : boolean; function MustCreateFocusHandler : boolean; function MustCreateContextMenuHandler : boolean; @@ -956,6 +962,7 @@ type // /include/capi/cef_download_handler_capi.h (cef_download_handler_t) ICefDownloadHandler = interface(ICefBaseRefCounted) ['{3137F90A-5DC5-43C1-858D-A269F28EF4F1}'] + function CanDownload(const browser: ICefBrowser; const url, request_method: ustring): boolean; procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); @@ -1813,6 +1820,15 @@ type procedure RemoveReferences; // custom procedure to clear all references end; + // TCefCommandHandler + // /include/capi/cef_command_handler_capi.h (cef_command_handler_t) + ICefCommandHandler = interface(ICefBaseRefCounted) + ['{7C931B93-53DC-4607-AABB-2CB4AEF7FB96}'] + function OnChromeCommand(const browser: ICefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): boolean; + + procedure RemoveReferences; // custom procedure to clear all references + end; + // TCefGetExtensionResourceCallback // /include/capi/cef_extension_handler_capi.h (cef_get_extension_resource_callback_t) ICefGetExtensionResourceCallback = interface(ICefBaseRefCounted) @@ -2067,6 +2083,7 @@ type ICefClient = interface(ICefBaseRefCounted) ['{1D502075-2FF0-4E13-A112-9E541CD811F4}'] procedure GetAudioHandler(var aHandler : ICefAudioHandler); + procedure GetCommandHandler(var aHandler : ICefCommandHandler); procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); procedure GetDialogHandler(var aHandler : ICefDialogHandler); procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); @@ -2159,6 +2176,7 @@ type procedure SetFragmentBaseUrl(const baseUrl: ustring); procedure ResetFileContents; procedure AddFile(const path, displayName: ustring); + procedure ClearFilenames; function GetImage : ICefImage; function GetImageHotspot : TCefPoint; function HasImage : boolean; @@ -2533,7 +2551,6 @@ type procedure SetVisible(visible: boolean); function IsVisible: boolean; function IsDrawn: boolean; - property ContentsView : ICefView read GetContentsView; property Window : ICefWindow read GetWindow; property DockingMode : TCefDockingMode read GetDockingMode; diff --git a/source/uCEFTypes.pas b/source/uCEFTypes.pas index f5cecc7e..4268d194 100644 --- a/source/uCEFTypes.pas +++ b/source/uCEFTypes.pas @@ -70,6 +70,7 @@ type PCefBinaryValue = ^TCefBinaryValue; PCefSchemeRegistrar = ^TCefSchemeRegistrar; PCefCommandLine = ^TCefCommandLine; + PCefCommandHandler = ^TCefCommandHandler; PCefBaseRefCounted = ^TCefBaseRefCounted; PCefBaseScoped = ^TCefBaseScoped; PCefWindowInfo = ^TCefWindowInfo; @@ -751,7 +752,9 @@ type WOD_NEW_WINDOW, WOD_SAVE_TO_DISK, WOD_OFF_THE_RECORD, - WOD_IGNORE_ACTION + WOD_IGNORE_ACTION, + WOD_SWITCH_TO_TAB, + WOD_NEW_PICTURE_IN_PICTURE ); // /include/internal/cef_types.h (cef_text_input_mode_t) @@ -1220,7 +1223,6 @@ type accept_language_list : TCefString; cookieable_schemes_list : TCefString; cookieable_schemes_exclude_defaults : integer; - application_client_id_for_file_scanning : TCefString; end; // /include/internal/cef_types_win.h (cef_window_info_t) @@ -1323,6 +1325,7 @@ type webgl : TCefState; background_color : TCefColor; accept_language_list : TCefString; + chrome_status_bubble : TCefState; end; // /include/internal/cef_types.h (cef_screen_info_t) @@ -1545,6 +1548,7 @@ type // /include/capi/cef_download_handler_capi.h (cef_download_handler_t) TCefDownloadHandler = record base : TCefBaseRefCounted; + can_download : function(self: PCefDownloadHandler; browser: PCefBrowser; const url, request_method: PCefString): integer; stdcall; on_before_download : procedure(self: PCefDownloadHandler; browser: PCefBrowser; download_item: PCefDownloadItem; const suggested_name: PCefString; callback: PCefBeforeDownloadCallback); stdcall; on_download_updated : procedure(self: PCefDownloadHandler; browser: PCefBrowser; download_item: PCefDownloadItem; callback: PCefDownloadItemCallback); stdcall; end; @@ -2270,6 +2274,7 @@ type set_fragment_base_url : procedure(self: PCefDragData; const base_url: PCefString); stdcall; reset_file_contents : procedure(self: PCefDragData); stdcall; add_file : procedure(self: PCefDragData; const path, display_name: PCefString); stdcall; + clear_filenames : procedure(self: PCefDragData); stdcall; get_image : function(self: PCefDragData): PCefImage; stdcall; get_image_hotspot : function(self: PCefDragData): PCefPoint; stdcall; has_image : function(self: PCefDragData): Integer; stdcall; @@ -2300,6 +2305,12 @@ type prepend_wrapper : procedure(self: PCefCommandLine; const wrapper: PCefString); stdcall; end; + // /include/capi/cef_command_handler_capi.h (cef_command_handler_t) + TCefCommandHandler = record + base : TCefBaseRefCounted; + on_chrome_command : function(self: PCefCommandHandler; browser: PCefBrowser; command_id: integer; disposition: TCefWindowOpenDisposition): Integer; stdcall; + end; + // /include/capi/cef_scheme_capi.h (cef_scheme_registrar_t) TCefSchemeRegistrar = record base : TCefBaseScoped; @@ -2823,6 +2834,7 @@ type TCefClient = record base : TCefBaseRefCounted; get_audio_handler : function(self: PCefClient): PCefAudioHandler; stdcall; + get_command_handler : function(self: PCefClient): PCefCommandHandler; stdcall; get_context_menu_handler : function(self: PCefClient): PCefContextMenuHandler; stdcall; get_dialog_handler : function(self: PCefClient): PCefDialogHandler; stdcall; get_display_handler : function(self: PCefClient): PCefDisplayHandler; stdcall; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 57621c81..45f9f129 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 392, + "InternalVersion" : 393, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "100.0.24.0" + "Version" : "101.0.15.0" } ], "UpdatePackageData" : {