diff --git a/README.md b/README.md index 4d010406..95002946 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 99.2.7 which includes Chromium 99.0.4844.51. +CEF4Delphi uses CEF 99.2.9 which includes Chromium 99.0.4844.51. The CEF binaries used by CEF4Delphi are available for download at Spotify : -* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_windows32.tar.bz2) -* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_windows64.tar.bz2) -* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_linux32.tar.bz2) -* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_linux64.tar.bz2) -* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_linuxarm.tar.bz2) -* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_linuxarm64.tar.bz2) -* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.7%2Bg674fc01%2Bchromium-99.0.4844.51_macosx64.tar.bz2) +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_linuxarm64.tar.bz2) +* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_99.2.9%2Bgf426765%2Bchromium-99.0.4844.51_macosx64.tar.bz2) CEF4Delphi was developed and tested on Delphi 11.0 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/MiniBrowser.dpr b/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dpr index 2eb90d93..94942096 100644 --- a/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dpr +++ b/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dpr @@ -42,16 +42,19 @@ program MiniBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Winapi.Windows, + Vcl.Forms, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF } uCEFApplication, uMiniBrowser in 'uMiniBrowser.pas' {MiniBrowserFrm}, uPreferences in 'uPreferences.pas' {PreferencesFrm}, uSimpleTextViewer in 'uSimpleTextViewer.pas' {SimpleTextViewerFrm}, uFindFrm in 'uFindFrm.pas' {FindFrm}, - uDirectorySelector in 'uDirectorySelector.pas' {DirectorySelectorFrm}; + uDirectorySelector in 'uDirectorySelector.pas' {DirectorySelectorFrm}, + uSelectCertForm in 'uSelectCertForm.pas' {SelectCertForm}; {$R *.res} diff --git a/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dproj b/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dproj index 7b308d91..436932a3 100644 --- a/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dproj +++ b/demos/Delphi_VCL/MiniBrowser/MiniBrowser.dproj @@ -151,7 +151,9 @@
DirectorySelectorFrm
- dfm +
+ +
SelectCertForm
Base diff --git a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm index 6b2f13a4..f0957212 100644 --- a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm +++ b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm @@ -163,6 +163,9 @@ object MiniBrowserFrm: TMiniBrowserFrm 'https://www.youtube.com' 'https://html5demos.com/drag/' 'https://frames-per-second.appspot.com/' + + 'https://www.sede.fnmt.gob.es/certificados/persona-fisica/verific' + + 'ar-estado' 'chrome://version/' 'chrome://net-internals/' 'chrome://tracing/' @@ -288,6 +291,7 @@ object MiniBrowserFrm: TMiniBrowserFrm OnBeforeClose = Chromium1BeforeClose OnClose = Chromium1Close OnCertificateError = Chromium1CertificateError + OnSelectClientCertificate = Chromium1SelectClientCertificate OnBeforeResourceLoad = Chromium1BeforeResourceLoad OnResourceResponse = Chromium1ResourceResponse OnFileDialog = Chromium1FileDialog diff --git a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas index 8947c925..b0f97b9f 100644 --- a/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas +++ b/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas @@ -72,6 +72,7 @@ const MINIBROWSER_PREFS_AVLBL = WM_APP + $10D; MINIBROWSER_DTDATA_AVLBL = WM_APP + $10E; MINIBROWSER_SHOWFILEDLG = WM_APP + $10F; + MINIBROWSER_SELECTCERT = WM_APP + $110; MINIBROWSER_HOMEPAGE = 'https://www.google.com'; @@ -180,6 +181,7 @@ type procedure Chromium1ZoomPctAvailable(Sender: TObject; const aZoomPct: Double); procedure Chromium1DevToolsMethodResult(Sender: TObject; const browser: ICefBrowser; message_id: Integer; success: Boolean; const result: ICefValue); 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 BackBtnClick(Sender: TObject); procedure ForwardBtnClick(Sender: TObject); @@ -213,12 +215,14 @@ type procedure SaveasMHTML1Click(Sender: TObject); protected - FDevToolsMsgID : integer; - FScreenshotMsgID : integer; - FMHTMLMsgID : integer; - FDevToolsMsgValue : ustring; - FShutdownReason : string; - FHasShutdownReason : boolean; + FDevToolsMsgID : integer; + FScreenshotMsgID : integer; + FMHTMLMsgID : integer; + FDevToolsMsgValue : ustring; + FShutdownReason : string; + FHasShutdownReason : boolean; + FSelectCertCallback : ICefSelectClientCertificateCallback; + FCertificates : TCefX509CertificateArray; FResponse : TStringList; FRequest : TStringList; @@ -231,6 +235,7 @@ type FClosing : boolean; // Set to True in the CloseQuery event. procedure AddURL(const aURL : string); + procedure DestroyCertificates; procedure ShowDevTools(aPoint : TPoint); overload; procedure ShowDevTools; overload; @@ -246,7 +251,6 @@ type function ShowOpenFolderDialog(var aFilePaths : TStringList) : boolean; function ShowSaveFileDialog(var aFilePaths : TStringList) : boolean; - procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure BrowserDestroyMsg(var aMessage : TMessage); message CEF_DESTROY; procedure ShowDevToolsMsg(var aMessage : TMessage); message MINIBROWSER_SHOWDEVTOOLS; @@ -264,6 +268,7 @@ type procedure PreferencesAvailableMsg(var aMessage : TMessage); message MINIBROWSER_PREFS_AVLBL; procedure DevToolsDataAvailableMsg(var aMessage : TMessage); message MINIBROWSER_DTDATA_AVLBL; procedure ShowFileDialogMsg(var aMessage : TMessage); message MINIBROWSER_SHOWFILEDLG; + procedure SelectCertificateMsg(var aMessage : TMessage); message MINIBROWSER_SELECTCERT; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; @@ -286,7 +291,7 @@ implementation uses uPreferences, uCefStringMultimap, uCEFMiscFunctions, uSimpleTextViewer, - uCEFClient, uFindFrm, uCEFDictionaryValue, uDirectorySelector; + uCEFClient, uFindFrm, uCEFDictionaryValue, uDirectorySelector, uSelectCertForm; // Destruction steps // ================= @@ -763,6 +768,38 @@ begin TempFilePaths.Free; end; +procedure TMiniBrowserFrm.SelectCertificateMsg(var aMessage : TMessage); +var + TempSelector : TSelectCertForm; + TempInfo : string; + i : integer; +begin + if assigned(FCertificates) and assigned(FSelectCertCallback) then + try + TempSelector := TSelectCertForm.Create(self); + + i := 0; + while (i < length(FCertificates)) do + begin + TempInfo := FCertificates[i].GetSubject.GetDisplayName + ' - ' + + 'Valid until : ' + DateToStr(CefTimeToDateTime(FCertificates[i].GetValidExpiry)); + + TempSelector.Certificates.Add(TempInfo); + inc(i); + end; + + TempSelector.ShowModal; + + if TempSelector.Selected >= 0 then + FSelectCertCallback.Select(FCertificates[TempSelector.Selected]) + else + FSelectCertCallback.Select(nil); + finally + DestroyCertificates; + FreeAndNil(TempSelector); + end; +end; + procedure TMiniBrowserFrm.Chromium1FullScreenModeChange(Sender: TObject; const browser: ICefBrowser; fullscreen: Boolean); begin @@ -1117,6 +1154,30 @@ begin Chromium1.StopLoad; end; +procedure TMiniBrowserFrm.Chromium1SelectClientCertificate(Sender: TObject; + const browser: ICefBrowser; isProxy: Boolean; const host: ustring; + port: Integer; certificatesCount: NativeUInt; + const certificates: TCefX509CertificateArray; + const callback: ICefSelectClientCertificateCallback; var aResult: Boolean); +var + i : integer; +begin + if assigned(callback) and assigned(certificates) and (length(certificates) > 0) then + begin + aResult := True; + FSelectCertCallback := callback; + + SetLength(FCertificates, length(certificates)); + + for i := 0 to pred(length(certificates)) do + FCertificates[i] := certificates[i]; + + PostMessage(Handle, MINIBROWSER_SELECTCERT, 0, 0); + end + else + aResult := False; +end; + procedure TMiniBrowserFrm.Chromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring); begin @@ -1188,6 +1249,8 @@ begin FResponse := TStringList.Create; FRequest := TStringList.Create; FNavigation := TStringList.Create; + FSelectCertCallback := nil; + FCertificates := nil; FDevToolsMsgID := 0; @@ -1213,6 +1276,9 @@ begin if FHasShutdownReason then ShutdownBlockReasonDestroy(Application.Handle); + DestroyCertificates; + + FSelectCertCallback := nil; FResponse.Free; FRequest.Free; FNavigation.Free; @@ -1281,6 +1347,24 @@ begin URLCbx.Text := aURL; end; +procedure TMiniBrowserFrm.DestroyCertificates; +var + i : integer; +begin + if assigned(FCertificates) then + begin + i := 0; + while (i < length(FCertificates)) do + begin + FCertificates[i] := nil; + inc(i); + end; + + Finalize(FCertificates); + FCertificates := nil; + end; +end; + procedure TMiniBrowserFrm.akescreenshot1Click(Sender: TObject); begin inc(FDevToolsMsgID); diff --git a/demos/Delphi_VCL/MiniBrowser/uSelectCertForm.dfm b/demos/Delphi_VCL/MiniBrowser/uSelectCertForm.dfm new file mode 100644 index 00000000..47b59092 --- /dev/null +++ b/demos/Delphi_VCL/MiniBrowser/uSelectCertForm.dfm @@ -0,0 +1,78 @@ +object SelectCertForm: TSelectCertForm + Left = 0 + Top = 0 + BorderIcons = [biSystemMenu] + Caption = 'Select a certificate' + ClientHeight = 441 + ClientWidth = 612 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -12 + Font.Name = 'Segoe UI' + Font.Style = [] + Position = poScreenCenter + OnCreate = FormCreate + OnDestroy = FormDestroy + OnShow = FormShow + PixelsPerInch = 96 + TextHeight = 15 + object ButtonPnl: TPanel + Left = 0 + Top = 405 + Width = 612 + Height = 36 + Align = alBottom + BevelOuter = bvNone + Padding.Left = 50 + Padding.Right = 50 + Padding.Bottom = 10 + TabOrder = 0 + object SelectBtn: TButton + Left = 50 + Top = 0 + Width = 150 + Height = 26 + Align = alLeft + Caption = 'Select' + Enabled = False + ModalResult = 1 + TabOrder = 0 + OnClick = SelectBtnClick + end + object CancelBtn: TButton + Left = 412 + Top = 0 + Width = 150 + Height = 26 + Align = alRight + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 1 + OnClick = CancelBtnClick + end + end + object CertificatesPnl: TPanel + Left = 0 + Top = 0 + Width = 612 + Height = 405 + Align = alClient + BevelOuter = bvNone + Padding.Left = 10 + Padding.Top = 10 + Padding.Right = 10 + Padding.Bottom = 10 + TabOrder = 1 + object CertificatesLb: TListBox + Left = 10 + Top = 10 + Width = 592 + Height = 385 + Align = alClient + ItemHeight = 15 + TabOrder = 0 + OnClick = CertificatesLbClick + end + end +end diff --git a/demos/Delphi_VCL/MiniBrowser/uSelectCertForm.pas b/demos/Delphi_VCL/MiniBrowser/uSelectCertForm.pas new file mode 100644 index 00000000..dc8cff61 --- /dev/null +++ b/demos/Delphi_VCL/MiniBrowser/uSelectCertForm.pas @@ -0,0 +1,76 @@ +unit uSelectCertForm; + +interface + +uses + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, + System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, + Vcl.StdCtrls, Vcl.ExtCtrls; + +type + TSelectCertForm = class(TForm) + ButtonPnl: TPanel; + SelectBtn: TButton; + CancelBtn: TButton; + CertificatesPnl: TPanel; + CertificatesLb: TListBox; + + procedure FormShow(Sender: TObject); + procedure FormDestroy(Sender: TObject); + + procedure SelectBtnClick(Sender: TObject); + procedure CancelBtnClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure CertificatesLbClick(Sender: TObject); + + private + FCertificates : TStringList; + FSelected : integer; + + public + property Certificates : TStringList read FCertificates; + property Selected : integer read FSelected; + end; + +implementation + +{$R *.dfm} + +procedure TSelectCertForm.FormCreate(Sender: TObject); +begin + FCertificates := TStringList.Create; + FSelected := -1; +end; + +procedure TSelectCertForm.CertificatesLbClick(Sender: TObject); +begin + SelectBtn.Enabled := (CertificatesLb.ItemIndex >= 0); +end; + +procedure TSelectCertForm.FormDestroy(Sender: TObject); +begin + if assigned(FCertificates) then + FreeAndNil(FCertificates); +end; + +procedure TSelectCertForm.FormShow(Sender: TObject); +begin + CertificatesLb.Items.Clear; + + if assigned(FCertificates) and (FCertificates.Count > 0) then + CertificatesLb.Items.AddStrings(FCertificates); +end; + +procedure TSelectCertForm.CancelBtnClick(Sender: TObject); +begin + FSelected := -1; + close; +end; + +procedure TSelectCertForm.SelectBtnClick(Sender: TObject); +begin + FSelected := CertificatesLb.ItemIndex; + close; +end; + +end. diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk index 57375c6f..75528b6a 100644 --- a/packages/cef4delphi_lazarus.lpk +++ b/packages/cef4delphi_lazarus.lpk @@ -21,7 +21,7 @@ - + diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas index 28a704ec..8764fe23 100644 --- a/source/uCEFApplicationCore.pas +++ b/source/uCEFApplicationCore.pas @@ -68,7 +68,7 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 99; CEF_SUPPORTED_VERSION_MINOR = 2; - CEF_SUPPORTED_VERSION_RELEASE = 7; + CEF_SUPPORTED_VERSION_RELEASE = 9; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 99; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 22410387..906beee0 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,9 +2,9 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 364, + "InternalVersion" : 365, "Name" : "cef4delphi_lazarus.lpk", - "Version" : "99.2.7.0" + "Version" : "99.2.9.0" } ], "UpdatePackageData" : {