From b5b9547d280875e95cfe445869b348d65fe329b1 Mon Sep 17 00:00:00 2001 From: Salvador Diaz Fau Date: Wed, 22 Mar 2017 15:22:11 +0100 Subject: [PATCH] Update to CEF 3.2987.1596.gc2b4638 * New properties in TCEFApplication : SmoothScrolling, FastUnload, DisableSafeBrowsing. * Bug fix in CefResponseFilter. Thanks to Zdravko Gabrovski! * MiniBrowser now has a context menu option to visit the DOM. --- demos/MiniBrowser/MiniBrowser.dpr | 51 ++++++- demos/MiniBrowser/MiniBrowser.dproj | 1 - demos/MiniBrowser/MiniBrowser.dsk | 174 +++++++++++++---------- demos/MiniBrowser/MiniBrowser.identcache | Bin 675 -> 672 bytes demos/MiniBrowser/MiniBrowser.stat | 12 +- demos/MiniBrowser/uMiniBrowser.dfm | 39 ++++- demos/MiniBrowser/uMiniBrowser.pas | 65 ++++++++- demos/MiniBrowser/uTestExtension.pas | 21 --- source/CEF4Delphi.dproj | 22 +-- source/CEF4Delphi.dsk | 74 ++++++---- source/CEF4Delphi.identcache | Bin 12699 -> 12699 bytes source/CEF4Delphi.stat | 6 +- source/uCEFApplication.pas | 31 ++-- source/uCEFChromium.pas | 49 +------ source/uCEFChromiumEvents.pas | 1 - source/uCEFDomVisitor.pas | 25 ---- source/uCEFInterfaces.pas | 6 +- source/uCEFPDFPrintOptions.pas | 5 +- source/uCEFProcessMessage.pas | 11 +- source/uCEFRenderProcessHandler.pas | 110 ++++++++++---- source/uCEFResponseFilter.pas | 9 +- source/uCEFTask.pas | 35 ++--- source/uCEFTypes.pas | 10 +- 23 files changed, 456 insertions(+), 301 deletions(-) diff --git a/demos/MiniBrowser/MiniBrowser.dpr b/demos/MiniBrowser/MiniBrowser.dpr index a82fa321..64791996 100644 --- a/demos/MiniBrowser/MiniBrowser.dpr +++ b/demos/MiniBrowser/MiniBrowser.dpr @@ -49,6 +49,13 @@ uses uCEFApplication, uCEFMiscFunctions, uCEFSchemeRegistrar, + uCEFRenderProcessHandler, + uCEFv8Handler, + uCEFInterfaces, + uCEFDomVisitor, + uCEFConstants, + uCEFTypes, + uCEFTask, uMiniBrowser in 'uMiniBrowser.pas' {MiniBrowserFrm}, uTestExtension in 'uTestExtension.pas', uHelloScheme in 'uHelloScheme.pas', @@ -56,16 +63,58 @@ uses {$R *.res} +var + TempProcessHandler : TCefCustomRenderProcessHandler; + +procedure DOMVisitor_OnDocAvailable(const document: ICefDomDocument); +begin + // This function is called from a different process. + // document is only valid inside this function. + // As an example, this function only writes the document title to the 'debug.log' file. + CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'document.Title : ' + document.Title); +end; + +procedure ProcessHandler_OnCustomMessage(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage); +var + TempFrame : ICefFrame; + TempVisitor : TCefFastDomVisitor; +begin + if (browser <> nil) then + begin + TempFrame := browser.MainFrame; + + if (TempFrame <> nil) then + begin + TempVisitor := TCefFastDomVisitor.Create(DOMVisitor_OnDocAvailable); + TempFrame.VisitDom(TempVisitor); + end; + end; +end; + +procedure ProcessHandler_OnWebKitReady; +begin +{$IFDEF DELPHI14_UP} + TCefRTTIExtension.Register('app', TTestExtension); +{$ENDIF} +end; + procedure GlobalCEFApp_OnRegCustomSchemes(const registrar: TCefSchemeRegistrarRef); begin registrar.AddCustomScheme('hello', True, True, False, False, False); end; begin + TempProcessHandler := TCefCustomRenderProcessHandler.Create; + TempProcessHandler.MessageName := 'retrievedom'; // same message name than TMiniBrowserFrm.VisitDOMMsg + TempProcessHandler.OnCustomMessage := ProcessHandler_OnCustomMessage; + TempProcessHandler.OnWebKitReady := ProcessHandler_OnWebKitReady; + GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.RemoteDebuggingPort := 9000; - GlobalCEFApp.RenderProcessHandler := TCustomRenderProcessHandler.Create; + GlobalCEFApp.RenderProcessHandler := TempProcessHandler as ICefRenderProcessHandler; GlobalCEFApp.OnRegCustomSchemes := GlobalCEFApp_OnRegCustomSchemes; + GlobalCEFApp.LogFile := 'debug.log'; + GlobalCEFApp.LogSeverity := LOGSEVERITY_ERROR; // Examples of command line switches. // ********************************** diff --git a/demos/MiniBrowser/MiniBrowser.dproj b/demos/MiniBrowser/MiniBrowser.dproj index 8ad25d74..b123d902 100644 --- a/demos/MiniBrowser/MiniBrowser.dproj +++ b/demos/MiniBrowser/MiniBrowser.dproj @@ -105,7 +105,6 @@
PreferencesFrm
- dfm
Cfg_2 diff --git a/demos/MiniBrowser/MiniBrowser.dsk b/demos/MiniBrowser/MiniBrowser.dsk index 51b8a3a5..7ccd60c2 100644 --- a/demos/MiniBrowser/MiniBrowser.dsk +++ b/demos/MiniBrowser/MiniBrowser.dsk @@ -1,39 +1,46 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uTestExtension.pas',0,1,1,1,40,0,0,, -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uHelloScheme.pas',0,1,1,1,40,0,0,, -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,1,25,38,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uPreferences.pas',0,1,10,51,49,0,0,, -File_4=TSourceModule,'C:\Program Files\Embarcadero\Studio\17.0\source\vcl\Vcl.Dialogs.pas',0,1,6752,22,6771,0,0,, -File_5=TSourceModule,'C:\Program Files\Embarcadero\Studio\17.0\source\Property Editors\FmxAnimationEditors.pas',0,1,1882,37,1904,0,0,, -File_6=TSourceModule,'C:\Program Files\Embarcadero\Studio\17.0\source\Property Editors\Indy10\IdDsnPropEdBindingVCL.pas',0,1,789,25,811,0,0,, -File_7=TSourceModule,'C:\Program Files\Embarcadero\Studio\17.0\source\Experts\ExpertsUIWizard.pas',0,1,540,33,562,0,0,, -File_8=TSourceModule,'C:\Program Files\Embarcadero\Studio\17.0\source\DUnit\Contrib\DUnitWizard\Source\DelphiExperts\DUnitProject\XPDUnitTestModule.pas',0,1,135,32,157,0,0,, -File_9=TSourceModule,'C:\Program Files\Embarcadero\Studio\17.0\source\data\ems\desktopconsole\EMSManagementConsole.FrameAdd.pas',0,1,478,32,500,0,0,, +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,558,38,599,0,0,, +File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,62,19,86,0,0,, +File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,735,3,764,0,0,, +File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas',0,1,588,5,617,0,0,, +File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumEvents.pas',0,1,35,96,52,0,0,, +File_5=TSourceModule,'c:\program files\embarcadero\studio\17.0\source\rtl\common\System.Classes.pas',0,1,132,44,155,0,0,, +File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,222,65,245,0,0,, +File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFMiscFunctions.pas',0,1,265,1,288,0,0,, +File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBaseRefCounted.pas',0,1,121,1,146,0,0,, +File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uHelloScheme.pas',0,1,1,1,40,0,0,, [Modules] -Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dproj -Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas +Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas +Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dproj Module2=default.htm -Count=3 +Module3=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uTestExtension.pas +Count=4 EditWindowCount=1 -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dproj] -ModuleType=TBaseProject - [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas] ModuleType=TSourceModule FormState=1 FormOnTop=0 +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dproj] +ModuleType=TBaseProject + [default.htm] ModuleType=TURLModule +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uTestExtension.pas] +ModuleType=TSourceModule +FormState=0 +FormOnTop=0 + [EditWindow0] -ViewCount=3 -CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dpr +ViewCount=4 +CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas View0=0 View1=1 View2=2 +View3=3 PercentageSizes=1 Create=1 Visible=1 @@ -50,18 +57,17 @@ ClientHeight=9428 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=1898 -LeftPanelClients=PropertyInspector,DockSite3 -LeftPanelData=00000800010100000000AA19000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000A12300001100000050726F7065727479496E73706563746F72FFFFFFFF +LeftPanelSize=0 RightPanelSize=2000 RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000AA1900000000000001D00700000000000001000000004312000009000000446F636B53697465320100000000A123000009000000446F636B5369746534FFFFFFFF -BottomPanelSize=0 +RightPanelData=000008000101000000001E1500000000000001D00700000000000001000000004312000009000000446F636B53697465320100000000511D000009000000446F636B5369746534FFFFFFFF +BottomPanelSize=1551 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020100000009000000446F636B53697465313B36000000000000020F0600000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF +TabDockLeftClients=PropertyInspector=0,DockSite3=1 [View0] CustomEditViewType=TWelcomePageView @@ -69,25 +75,36 @@ WelcomePageURL=bds:/default.htm [View1] CustomEditViewType=TEditView +Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dpr +CursorX=70 +CursorY=95 +TopLine=74 +LeftCol=1 +Elisions= +Bookmarks= +EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dpr + +[View2] +CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas -CursorX=76 -CursorY=82 -TopLine=1 +CursorX=87 +CursorY=411 +TopLine=387 LeftCol=1 Elisions= Bookmarks= EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas -[View2] +[View3] CustomEditViewType=TEditView -Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dpr +Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uTestExtension.pas CursorX=1 -CursorY=41 -TopLine=22 +CursorY=68 +TopLine=38 LeftCol=1 Elisions= Bookmarks= -EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dpr +EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uTestExtension.pas [Watches] Count=0 @@ -103,18 +120,19 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1043 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1043 TBDockHeight=213 LRDockWidth=13602 Dockable=1 StayOnTop=0 [Breakpoints] -Count=0 +Count=1 +Breakpoint0='C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',2552,'',0,1,'',0,0,0,'doOnProcessMessageReceived',1,'','','',0,'' [EmbarcaderoWin32Debugger_AddressBreakpoints] Count=0 @@ -164,18 +182,18 @@ StayOnTop=0 [MessageView] PercentageSizes=1 Create=1 -Visible=0 +Visible=1 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=23 +Width=10000 +Height=1345 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1345 +TBDockHeight=1345 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -189,11 +207,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4339 +Height=2668 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4339 +ClientHeight=2668 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -243,8 +261,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-121 -Top=-74 +Left=-8 +Top=-30 Width=1844 Height=3139 MaxLeft=-1 @@ -297,18 +315,18 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=362 +Left=78 +Top=386 Width=1898 -Height=5370 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=5370 -TBDockHeight=7119 +ClientHeight=7164 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -383,11 +401,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1043 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1043 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -402,11 +420,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1043 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1043 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -425,11 +443,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1043 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1043 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -444,11 +462,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1043 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1043 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -566,11 +584,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1043 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1043 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -591,12 +609,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1898 -Height=3498 +Width=1773 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3498 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -678,12 +696,12 @@ State=0 Left=0 Top=23 Width=3820 -Height=1424 +Height=1345 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1345 +TBDockHeight=1345 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -716,22 +734,22 @@ ActiveTabID=ProjectManager TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm [DockSite3] -HostDockSite=DockLeftPanel +HostDockSite=LeftDockTabSet DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=23 +Top=0 Width=1898 -Height=3498 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3498 -TBDockHeight=7119 +ClientWidth=1773 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -750,11 +768,11 @@ State=0 Left=0 Top=454 Width=2000 -Height=4339 +Height=2668 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4339 +ClientHeight=2668 TBDockHeight=7119 LRDockWidth=2000 Dockable=1 diff --git a/demos/MiniBrowser/MiniBrowser.identcache b/demos/MiniBrowser/MiniBrowser.identcache index 1f8ccf66a66b9835005cd703866da11bf5eed831..239e7a34f9a3944f76940f760533715f3241c660 100644 GIT binary patch delta 33 pcmZ3?x`1`Uv&sI9#f*`Y0~nnqYcg_kIA;{)=Vq4XPTs`$5dgw73*`U+ delta 35 rcmZ3$x|nssGsc+72N<0u&tc@|b}T5!$xKcx$;{82c&&Nze#VCY@{|sb diff --git a/demos/MiniBrowser/MiniBrowser.stat b/demos/MiniBrowser/MiniBrowser.stat index b6bd1c88..9dca8bc2 100644 --- a/demos/MiniBrowser/MiniBrowser.stat +++ b/demos/MiniBrowser/MiniBrowser.stat @@ -1,10 +1,10 @@ [Stats] -EditorSecs=16035 -DesignerSecs=1777 -InspectorSecs=1204 -CompileSecs=764079 -OtherSecs=2346 +EditorSecs=20406 +DesignerSecs=1796 +InspectorSecs=1288 +CompileSecs=899865 +OtherSecs=2832 StartTime=11/02/2017 10:51:15 RealKeys=0 EffectiveKeys=0 -DebugSecs=8921 +DebugSecs=10091 diff --git a/demos/MiniBrowser/uMiniBrowser.dfm b/demos/MiniBrowser/uMiniBrowser.dfm index 16930083..aab0fc04 100644 --- a/demos/MiniBrowser/uMiniBrowser.dfm +++ b/demos/MiniBrowser/uMiniBrowser.dfm @@ -117,7 +117,6 @@ object MiniBrowserFrm: TMiniBrowserFrm Padding.Bottom = 8 ShowCaption = False TabOrder = 1 - ExplicitWidth = 915 object URLCbx: TComboBox Left = 0 Top = 9 @@ -133,7 +132,6 @@ object MiniBrowserFrm: TMiniBrowserFrm 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-b' + 'rowser-sending' 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close') - ExplicitWidth = 915 end end object ConfigPnl: TPanel @@ -144,7 +142,6 @@ object MiniBrowserFrm: TMiniBrowserFrm Align = alRight BevelOuter = bvNone TabOrder = 2 - ExplicitLeft = 1015 object ConfigBtn: TButton Left = 40 Top = 8 @@ -184,7 +181,6 @@ object MiniBrowserFrm: TMiniBrowserFrm Height = 656 Align = alClient TabOrder = 1 - ExplicitHeight = 621 end object DevTools: TCEFWindowParent Left = 1089 @@ -194,7 +190,6 @@ object MiniBrowserFrm: TMiniBrowserFrm Align = alRight TabOrder = 2 Visible = False - ExplicitHeight = 621 end object StatusBar1: TStatusBar Left = 0 @@ -205,7 +200,6 @@ object MiniBrowserFrm: TMiniBrowserFrm item Width = 50 end> - ExplicitTop = 662 end object Chromium1: TChromium OnTextResultAvailable = Chromium1TextResultAvailable @@ -228,6 +222,35 @@ object MiniBrowserFrm: TMiniBrowserFrm Caption = 'DevTools' OnClick = DevTools1Click end + object N2: TMenuItem + Caption = '-' + end + object Print1: TMenuItem + Caption = 'Print' + OnClick = Print1Click + end + object PrintinPDF1: TMenuItem + Caption = 'Print to PDF' + OnClick = PrintinPDF1Click + end + object N3: TMenuItem + Caption = '-' + end + object Zoom1: TMenuItem + Caption = 'Zoom' + object Inczoom1: TMenuItem + Caption = 'Inc zoom' + OnClick = Inczoom1Click + end + object Deczoom1: TMenuItem + Caption = 'Dec zoom' + OnClick = Deczoom1Click + end + object Resetzoom1: TMenuItem + Caption = 'Reset zoom' + OnClick = Resetzoom1Click + end + end object N1: TMenuItem Caption = '-' end @@ -236,4 +259,8 @@ object MiniBrowserFrm: TMiniBrowserFrm OnClick = Preferences1Click end end + object SaveDialog1: TSaveDialog + Left = 488 + Top = 232 + end end diff --git a/demos/MiniBrowser/uMiniBrowser.pas b/demos/MiniBrowser/uMiniBrowser.pas index 6ac97ff1..5e5d967d 100644 --- a/demos/MiniBrowser/uMiniBrowser.pas +++ b/demos/MiniBrowser/uMiniBrowser.pas @@ -56,6 +56,7 @@ const MINIBROWSER_SHOWDEVTOOLS = WM_APP + $101; MINIBROWSER_HIDEDEVTOOLS = WM_APP + $102; MINIBROWSER_COPYHTML = WM_APP + $103; + MINIBROWSER_VISITDOM = WM_APP + $104; MINIBROWSER_HOMEPAGE = 'https://www.google.com'; @@ -64,6 +65,7 @@ const MINIBROWSER_CONTEXTMENU_SHOWJSALERT = MENU_ID_USER_FIRST + 3; MINIBROWSER_CONTEXTMENU_SETJSEVENT = MENU_ID_USER_FIRST + 4; MINIBROWSER_CONTEXTMENU_COPYHTML = MENU_ID_USER_FIRST + 5; + MINIBROWSER_CONTEXTMENU_VISITDOM = MENU_ID_USER_FIRST + 6; type TMiniBrowserFrm = class(TForm) @@ -87,6 +89,15 @@ type N1: TMenuItem; Preferences1: TMenuItem; GoBtn: TButton; + N2: TMenuItem; + PrintinPDF1: TMenuItem; + Print1: TMenuItem; + N3: TMenuItem; + Zoom1: TMenuItem; + Inczoom1: TMenuItem; + Deczoom1: TMenuItem; + Resetzoom1: TMenuItem; + SaveDialog1: TSaveDialog; procedure FormShow(Sender: TObject); procedure BackBtnClick(Sender: TObject); procedure ForwardBtnClick(Sender: TObject); @@ -120,6 +131,11 @@ type procedure Preferences1Click(Sender: TObject); procedure ConfigBtnClick(Sender: TObject); procedure GoBtnClick(Sender: TObject); + procedure PrintinPDF1Click(Sender: TObject); + procedure Print1Click(Sender: TObject); + procedure Inczoom1Click(Sender: TObject); + procedure Deczoom1Click(Sender: TObject); + procedure Resetzoom1Click(Sender: TObject); protected procedure AddURL(const aURL : string); @@ -132,6 +148,7 @@ type procedure ShowDevToolsMsg(var aMessage : TMessage); message MINIBROWSER_SHOWDEVTOOLS; procedure HideDevToolsMsg(var aMessage : TMessage); message MINIBROWSER_HIDEDEVTOOLS; procedure CopyHTMLMsg(var aMessage : TMessage); message MINIBROWSER_COPYHTML; + procedure VisitDOMMsg(var aMessage : TMessage); message MINIBROWSER_VISITDOM; public end; @@ -144,7 +161,7 @@ implementation {$R *.dfm} uses - uPreferences; + uPreferences, uCEFProcessMessage; procedure TMiniBrowserFrm.BackBtnClick(Sender: TObject); begin @@ -166,6 +183,11 @@ begin Chromium1.Reload; end; +procedure TMiniBrowserFrm.Resetzoom1Click(Sender: TObject); +begin + Chromium1.ResetZoomStep; +end; + procedure TMiniBrowserFrm.Chromium1AddressChange(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); begin @@ -186,6 +208,7 @@ begin model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWJSALERT, 'Show JS Alert'); model.AddItem(MINIBROWSER_CONTEXTMENU_SETJSEVENT, 'Set mouseover event'); model.AddItem(MINIBROWSER_CONTEXTMENU_COPYHTML, 'Copy HTML to clipboard'); + model.AddItem(MINIBROWSER_CONTEXTMENU_VISITDOM, 'Visit DOM'); if DevTools.Visible then model.AddItem(MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS, 'Hide DevTools') @@ -230,6 +253,9 @@ begin MINIBROWSER_CONTEXTMENU_COPYHTML : PostMessage(Handle, MINIBROWSER_COPYHTML, 0, 0); + + MINIBROWSER_CONTEXTMENU_VISITDOM : + PostMessage(Handle, MINIBROWSER_VISITDOM, 0, 0); end; end; @@ -308,6 +334,11 @@ begin HideDevTools; end; +procedure TMiniBrowserFrm.Inczoom1Click(Sender: TObject); +begin + Chromium1.IncZoomStep; +end; + procedure TMiniBrowserFrm.PopupMenu1Popup(Sender: TObject); begin if DevTools.Visible then @@ -344,6 +375,20 @@ begin end; end; +procedure TMiniBrowserFrm.Print1Click(Sender: TObject); +begin + Chromium1.Print; +end; + +procedure TMiniBrowserFrm.PrintinPDF1Click(Sender: TObject); +begin + SaveDialog1.DefaultExt := 'pdf'; + SaveDialog1.Filter := 'PDF files (*.pdf)|*.PDF'; + + if SaveDialog1.Execute and (length(SaveDialog1.FileName) > 0) then + Chromium1.PrintToPDF(SaveDialog1.FileName, Chromium1.DocumentURL, Chromium1.DocumentURL); +end; + procedure TMiniBrowserFrm.ConfigBtnClick(Sender: TObject); var TempPoint : TPoint; @@ -360,6 +405,24 @@ begin Chromium1.RetrieveHTML; end; +procedure TMiniBrowserFrm.VisitDOMMsg(var aMessage : TMessage); +var + TempMsg : ICefProcessMessage; +begin + // Only works using a TCefCustomRenderProcessHandler. See MiniBrowser demo. + if Chromium1.Initialized then + begin + // Use the ArgumentList property if you need to pass some parameters. + TempMsg := TCefProcessMessageRef.New('retrievedom'); // Same name than TCefCustomRenderProcessHandler.MessageName + Chromium1.Browser.SendProcessMessage(PID_RENDERER, TempMsg); + end; +end; + +procedure TMiniBrowserFrm.Deczoom1Click(Sender: TObject); +begin + Chromium1.DecZoomStep; +end; + procedure TMiniBrowserFrm.DevTools1Click(Sender: TObject); begin if DevTools.Visible then diff --git a/demos/MiniBrowser/uTestExtension.pas b/demos/MiniBrowser/uTestExtension.pas index 5b2f2605..2cc7a470 100644 --- a/demos/MiniBrowser/uTestExtension.pas +++ b/demos/MiniBrowser/uTestExtension.pas @@ -51,11 +51,6 @@ uses uCEFv8Context, uCEFTypes, uCEFv8Handler; type - TCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn) - protected - procedure OnWebKitInitialized; override; - end; - TCustomBrowserProcessHandler = class(TCefBrowserProcessHandlerOwn) protected procedure OnScheduleMessagePumpWork(delayMs: Int64); override; @@ -71,22 +66,6 @@ implementation var pumpMessages: Integer = 0; -{ TCustomRenderProcessHandler } - -function getpath(const n: ICefDomNode): string; -begin - Result := '<' + n.Name + '>'; - if (n.Parent <> nil) then - Result := getpath(n.Parent) + Result; -end; - -procedure TCustomRenderProcessHandler.OnWebKitInitialized; -begin -{$IFDEF DELPHI14_UP} - TCefRTTIExtension.Register('app', TTestExtension); -{$ENDIF} -end; - { TTestExtension } class procedure TTestExtension.mouseover(const data: string); diff --git a/source/CEF4Delphi.dproj b/source/CEF4Delphi.dproj index 8fdb431d..5e6ea039 100644 --- a/source/CEF4Delphi.dproj +++ b/source/CEF4Delphi.dproj @@ -256,7 +256,16 @@ true - + + + 0 + .dll;.bpl + + + 1 + .dylib + + Contents\Resources @@ -570,16 +579,7 @@ 1 - - - 0 - .dll;.bpl - - - 1 - .dylib - - + diff --git a/source/CEF4Delphi.dsk b/source/CEF4Delphi.dsk index b562fe5d..03f3db62 100644 --- a/source/CEF4Delphi.dsk +++ b/source/CEF4Delphi.dsk @@ -1,27 +1,34 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,31,80,57,0,0,, -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,1995,70,2009,0,0,, -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFMiscFunctions.pas',0,1,53,30,76,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi_new\source\uCEFMiscFunctions.pas',0,1,1,1,1,0,0,, -File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFLibFunctions.pas',0,1,1,1,1,0,0,, -File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFResourceHandler.pas',0,1,1,1,1,0,0,, -File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFSchemeRegistrar.pas',0,1,1,1,1,0,0,, -File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi_new\source\uCEFLibFunctions.pas',0,1,1,1,1,0,0,, -File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi_new\source\uCEFResourceHandler.pas',0,1,1,1,1,0,0,, -File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi_new\source\uCEFSchemeRegistrar.pas',0,1,1,1,1,0,0,, +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFResponseFilter.pas',0,1,33,1,56,0,0,, +File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,1170,1,1202,0,0,, +File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas',0,1,1615,96,1640,0,0,, +File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,262,52,291,0,0,, +File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFDomVisitor.pas',0,1,37,1,108,0,0,, +File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,1,1,71,0,0,, +File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFProcessMessage.pas',0,1,22,66,53,0,0,, +File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTask.pas',0,1,44,1,145,0,0,, +File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumEvents.pas',0,1,32,1,61,0,0,, +File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFPDFPrintOptions.pas',0,3,65,25,93,0,0,, [Modules] -Module0=default.htm -Count=1 +Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas +Module1=default.htm +Count=2 EditWindowCount=1 +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas] +ModuleType=TSourceModule +FormState=0 +FormOnTop=0 + [default.htm] ModuleType=TURLModule [EditWindow0] -ViewCount=1 -CurrentView=0 +ViewCount=2 +CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas View0=0 +View1=1 PercentageSizes=1 Create=1 Visible=1 @@ -41,10 +48,10 @@ TopPanelSize=0 LeftPanelSize=0 RightPanelSize=2000 RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000AA1900000000000001D00700000000000001000000004312000009000000446F636B53697465320100000000A123000009000000446F636B5369746534FFFFFFFF -BottomPanelSize=0 +RightPanelData=000008000101000000001E1500000000000001D00700000000000001000000004312000009000000446F636B53697465320100000000511D000009000000446F636B5369746534FFFFFFFF +BottomPanelSize=1551 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020100000009000000446F636B53697465313B36000000000000020F0600000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF @@ -54,6 +61,17 @@ TabDockLeftClients=PropertyInspector=0,DockSite3=1 CustomEditViewType=TWelcomePageView WelcomePageURL=bds:/default.htm +[View1] +CustomEditViewType=TEditView +Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas +CursorX=19 +CursorY=397 +TopLine=385 +LeftCol=1 +Elisions= +Bookmarks= +EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas + [Watches] Count=0 @@ -129,18 +147,18 @@ StayOnTop=0 [MessageView] PercentageSizes=1 Create=1 -Visible=0 +Visible=1 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=23 +Width=10000 +Height=1345 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1345 +TBDockHeight=1345 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -154,11 +172,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4339 +Height=2668 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4339 +ClientHeight=2668 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -715,11 +733,11 @@ State=0 Left=0 Top=454 Width=2000 -Height=4339 +Height=2668 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4339 +ClientHeight=2668 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 diff --git a/source/CEF4Delphi.identcache b/source/CEF4Delphi.identcache index b222cbf272850ea7cc6bd72228f9f32235f28a98..6cf5eacd9450e6422ad005d2d7bc8c19715bd63c 100644 GIT binary patch delta 241 zcmbQ8JUe+qAIrphev_}M$xnWu<2U&ZiyVl%N=kn6Jw?CC2UPerhp{R$P3F}}n><_E zZ?c{)$7D+m>B;+){5A`5HZg+~$Lq^at{3;){D>!-1*B;6N5PM*lh3RBZJr}>fDvr$ ze@2eUXW7LjH}Lyy7MK3PI=N0ibnrc5@FV4wVflYR3i+~g(Dj?F!^p8&i%p#gEcl<1WAa8RvB`Wwev{{Oa7^aq zl%Bkv*>7^VzS8786~E18oK4J=>zMpDZ|03=nfzBfZ8M*cJsVi7FBkh{Cw1}7z7l*) z6Yu#=-pVRJnUCFXv#9hB*2$GX#!3!D5@Ic4)dU2aB@HEz7} WlX(?GC!f==2hv#}D<^XqP6Pn nil) and (FCustomCommandLineValues <> nil) and (FCustomCommandLines.Count = FCustomCommandLineValues.Count) then diff --git a/source/uCEFChromium.pas b/source/uCEFChromium.pas index a4d8ada3..7f84fb0d 100644 --- a/source/uCEFChromium.pas +++ b/source/uCEFChromium.pas @@ -64,7 +64,6 @@ type FVisitor : ICefStringVisitor; FPDFPrintcb : ICefPdfPrintCallback; FCookiDeletercb : ICefDeleteCookiesCallback; - FDOMVisitor : ICefDomVisitor; FClientHandler : TVCLClientHandler; FHandler : ICefClient; FBrowser : ICefBrowser; @@ -201,7 +200,6 @@ type FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; FOnPrefsAvailable : TNotifyEvent; FOnCookiesDeleted : TOnCookiesDeletedEvent; - FOnDocumentAvailable : TOnDocumentAvailableEvent; function GetIsLoading : boolean; function GetMultithreadApp : boolean; @@ -378,10 +376,8 @@ type // Internal procedures. // Only tasks, visitors or callbacks should use them in the right thread/process. - procedure Internal_DOMVisit(const document: ICefDomDocument); procedure Internal_CookiesDeleted(numDeleted : integer); procedure Internal_GetHTML; - procedure Internal_VisitDOM; procedure Internal_PdfPrintFinished(aResultOK : boolean); procedure Internal_TextResultAvailable(const aText : string); procedure Internal_UpdatePreferences; @@ -398,7 +394,6 @@ type procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer); procedure DeleteCookies; - procedure RetrieveDOMDocument; procedure RetrieveHTML; procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; aStartLine : integer = 0); procedure UpdatePreferences; @@ -494,7 +489,6 @@ type property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished; property OnPrefsAvailable : TNotifyEvent read FOnPrefsAvailable write FOnPrefsAvailable; property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted; - property OnDocumentAvailable : TOnDocumentAvailableEvent read FOnDocumentAvailable write FOnDocumentAvailable; // ICefClient property OnProcessMessageReceived : TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived; @@ -601,7 +595,7 @@ uses SysUtils, Math, {$ENDIF} uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFCookieManager, uCEFFrame, - uCEFApplication; + uCEFApplication, uCEFProcessMessage; constructor TChromium.Create(AOwner: TComponent); begin @@ -620,7 +614,6 @@ begin FVisitor := nil; FPDFPrintcb := nil; FCookiDeletercb := nil; - FDOMVisitor := nil; FPDFPrintOptions := nil; FUpdatePreferences := False; FCustomHeaderName := ''; @@ -683,7 +676,6 @@ begin FVisitor := nil; FPDFPrintcb := nil; FCookiDeletercb := nil; - FDOMVisitor := nil; if (FFontOptions <> nil) then FreeAndNil(FFontOptions); if (FOptions <> nil) then FreeAndNil(FOptions); @@ -834,7 +826,6 @@ begin FOnPdfPrintFinished := nil; FOnPrefsAvailable := nil; FOnCookiesDeleted := nil; - FOnDocumentAvailable := nil; end; function TChromium.CreateBrowser(const aBrowserParent : TWinControl; const aWindowName : string) : boolean; @@ -931,27 +922,6 @@ begin end; end; -procedure TChromium.Internal_VisitDOM; -var - TempFrame : ICefFrame; -begin - try - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - if (FDOMVisitor = nil) then FDOMVisitor := TCustomDomVisitor.Create(self); - TempFrame.VisitDom(FDOMVisitor); - end; - end; - except - on e : exception do - OutputDebugMessage('TChromium.Internal_VisitDOM error: ' + e.Message); - end; -end; - procedure TChromium.ClipboardCopy; var TempFrame : ICefFrame; @@ -1051,6 +1021,7 @@ begin aSettings.header_footer_url := CefString(aURL); aSettings.page_width := FPDFPrintOptions.page_width; aSettings.page_height := FPDFPrintOptions.page_height; + aSettings.scale_factor := FPDFPrintOptions.scale_factor; aSettings.margin_top := FPDFPrintOptions.margin_top; aSettings.margin_right := FPDFPrintOptions.margin_right; aSettings.margin_bottom := FPDFPrintOptions.margin_bottom; @@ -1536,17 +1507,6 @@ begin end; end; -procedure TChromium.RetrieveDOMDocument; -var - TempTask: ICefTask; -begin - if Initialized then - begin - TempTask := TCefGetDocumentTask.Create(self); - CefPostTask(TID_RENDERER, TempTask); - end; -end; - procedure TChromium.RetrieveHTML; var TempTask: ICefTask; @@ -2056,11 +2016,6 @@ begin if assigned(FOnCookiesDeleted) then FOnCookiesDeleted(self, numDeleted); end; -procedure TChromium.Internal_DOMVisit(const document: ICefDomDocument); -begin - if assigned(FOnDocumentAvailable) then FOnDocumentAvailable(self, document); -end; - procedure TChromium.Internal_PdfPrintFinished(aResultOK : boolean); begin if assigned(FOnPdfPrintFinished) then FOnPdfPrintFinished(self, aResultOK); diff --git a/source/uCEFChromiumEvents.pas b/source/uCEFChromiumEvents.pas index 1ee9ce1d..f1dac119 100644 --- a/source/uCEFChromiumEvents.pas +++ b/source/uCEFChromiumEvents.pas @@ -58,7 +58,6 @@ type TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : string) of object; TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object; - TOnDocumentAvailableEvent = procedure(Sender: TObject; const aDocument : ICefDomDocument) of object; TOnProcessMessageReceived = procedure(Sender: TObject; const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage; out Result: Boolean) of object; TOnLoadingStateChange = procedure(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean) of object; TOnLoadStart = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType) of object; diff --git a/source/uCEFDomVisitor.pas b/source/uCEFDomVisitor.pas index b8491804..2b62444a 100644 --- a/source/uCEFDomVisitor.pas +++ b/source/uCEFDomVisitor.pas @@ -68,16 +68,6 @@ type constructor Create(const proc: TCefDomVisitorProc); reintroduce; virtual; end; - TCustomDomVisitor = class(TCefDomVisitorOwn) - protected - FChromiumBrowser : TObject; - - procedure visit(const document: ICefDomDocument); override; - - public - constructor Create(const aChromiumBrowser : TObject); reintroduce; - end; - implementation uses @@ -115,19 +105,4 @@ begin FProc(document); end; -// TCustomDomVisitor - -constructor TCustomDomVisitor.Create(const aChromiumBrowser : TObject); -begin - inherited Create; - - FChromiumBrowser := aChromiumBrowser; -end; - -procedure TCustomDomVisitor.visit(const document: ICefDomDocument); -begin - if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then - TChromium(FChromiumBrowser).Internal_DOMVisit(document); -end; - end. diff --git a/source/uCEFInterfaces.pas b/source/uCEFInterfaces.pas index 371bca87..afaf2ca7 100644 --- a/source/uCEFInterfaces.pas +++ b/source/uCEFInterfaces.pas @@ -90,6 +90,7 @@ type ICefResourceBundleHandler = interface; ICefBrowserProcessHandler = interface; ICefRenderProcessHandler = interface; + ICefProcessMessage = interface; TCefv8ValueArray = array of ICefv8Value; TCefX509CertificateArray = array of ICefX509Certificate; @@ -103,6 +104,8 @@ type TOnGetBrowserProcessHandler = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(var aCefBrowserProcessHandler : ICefBrowserProcessHandler) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; TOnGetRenderProcessHandler = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(var aCefRenderProcessHandler : ICefRenderProcessHandler) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; TOnBeforeCommandLineProcessing = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const processType: ustring; const commandLine: ICefCommandLine) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; + TOnCustomMessage = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; + TOnWebKitReady = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}of object{$ENDIF}; TCefCompletionCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure; TCefSetCookieCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(success: Boolean); @@ -1196,8 +1199,7 @@ type ICefResponseFilter = interface(ICefBaseRefCounted) ['{5013BC3C-F1AE-407A-A571-A4C6B1D6831E}'] function InitFilter: Boolean; - function Filter(dataIn: Pointer; dataInSize, dataInRead: NativeUInt; - dataOut: Pointer; dataOutSize, dataOutWritten: NativeUInt): TCefResponseFilterStatus; + function Filter(dataIn: Pointer; dataInSize : NativeUInt; dataInRead: PNativeUInt; dataOut: Pointer; dataOutSize : NativeUInt; dataOutWritten: PNativeUInt): TCefResponseFilterStatus; end; ICefRequestHandler = interface(ICefBaseRefCounted) diff --git a/source/uCEFPDFPrintOptions.pas b/source/uCEFPDFPrintOptions.pas index 4e5b1931..c65da840 100644 --- a/source/uCEFPDFPrintOptions.pas +++ b/source/uCEFPDFPrintOptions.pas @@ -59,6 +59,7 @@ type protected Fpage_width : integer; Fpage_height : Integer; + Fscale_factor : integer; Fmargin_top : double; Fmargin_right : double; Fmargin_bottom : double; @@ -74,7 +75,8 @@ type published property page_width : integer read Fpage_width write Fpage_width default 0; - property page_height : Integer read Fpage_height write Fpage_height default 0; + property page_height : integer read Fpage_height write Fpage_height default 0; + property scale_factor : integer read Fscale_factor write Fscale_factor default 0; property margin_top : double read Fmargin_top write Fmargin_top; property margin_right : double read Fmargin_right write Fmargin_right; property margin_bottom : double read Fmargin_bottom write Fmargin_bottom; @@ -92,6 +94,7 @@ constructor TPDFPrintOptions.Create; begin Fpage_width := 0; Fpage_height := 0; + Fscale_factor := 100; Fmargin_top := 0; Fmargin_right := 0; Fmargin_bottom := 0; diff --git a/source/uCEFProcessMessage.pas b/source/uCEFProcessMessage.pas index 3d676464..33ec9bb5 100644 --- a/source/uCEFProcessMessage.pas +++ b/source/uCEFProcessMessage.pas @@ -95,16 +95,17 @@ end; class function TCefProcessMessageRef.New(const name: ustring): ICefProcessMessage; var - n: TCefString; + TempString : TCefString; begin - n := CefString(name); - Result := UnWrap(cef_process_message_create(@n)); + TempString := CefString(name); + Result := UnWrap(cef_process_message_create(@TempString)); end; class function TCefProcessMessageRef.UnWrap(data: Pointer): ICefProcessMessage; begin - if data <> nil then - Result := Create(data) as ICefProcessMessage else + if (data <> nil) then + Result := Create(data) as ICefProcessMessage + else Result := nil; end; diff --git a/source/uCEFRenderProcessHandler.pas b/source/uCEFRenderProcessHandler.pas index 07545acf..5bdbd15e 100644 --- a/source/uCEFRenderProcessHandler.pas +++ b/source/uCEFRenderProcessHandler.pas @@ -47,25 +47,47 @@ unit uCEFRenderProcessHandler; interface uses + {$IFDEF DELPHI16_UP} + System.Classes, + {$ELSE} + Classes, + {$ENDIF} uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFListValue, uCEFBrowser, uCEFFrame, uCEFRequest, uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage; type TCefRenderProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefRenderProcessHandler) - protected - procedure OnRenderThreadCreated(const extraInfo: ICefListValue); virtual; - procedure OnWebKitInitialized; virtual; - procedure OnBrowserCreated(const browser: ICefBrowser); virtual; - procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual; - function GetLoadHandler: PCefLoadHandler; virtual; - function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean; virtual; - procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; - procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; - procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual; - procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; virtual; - public - constructor Create; virtual; + protected + procedure OnRenderThreadCreated(const extraInfo: ICefListValue); virtual; + procedure OnWebKitInitialized; virtual; + procedure OnBrowserCreated(const browser: ICefBrowser); virtual; + procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual; + function GetLoadHandler: PCefLoadHandler; virtual; + function OnBeforeNavigation(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; navigationType: TCefNavigationType; isRedirect: Boolean): Boolean; virtual; + procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; + procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; + procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual; + procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual; + function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; virtual; + public + constructor Create; virtual; + end; + + TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn) + protected + FMessageName : ustring; + FOnCustomMessage : TOnCustomMessage; + FOnWebKitReady : TOnWebKitReady; + + procedure OnWebKitInitialized; override; + function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; override; + + public + constructor Create; override; + + property MessageName : ustring read FMessageName write FMessageName; + property OnCustomMessage : TOnCustomMessage read FOnCustomMessage write FOnCustomMessage; + property OnWebKitReady : TOnWebKitReady read FOnWebKitReady write FOnWebKitReady; end; implementation @@ -159,23 +181,27 @@ begin end; +// TCefRenderProcessHandlerOwn + + constructor TCefRenderProcessHandlerOwn.Create; begin inherited CreateData(SizeOf(TCefRenderProcessHandler)); + with PCefRenderProcessHandler(FData)^ do - begin - on_render_thread_created := cef_render_process_handler_on_render_thread_created; - on_web_kit_initialized := cef_render_process_handler_on_web_kit_initialized; - on_browser_created := cef_render_process_handler_on_browser_created; - on_browser_destroyed := cef_render_process_handler_on_browser_destroyed; - get_load_handler := cef_render_process_handler_get_load_handler; - on_before_navigation := cef_render_process_handler_on_before_navigation; - on_context_created := cef_render_process_handler_on_context_created; - on_context_released := cef_render_process_handler_on_context_released; - on_uncaught_exception := cef_render_process_handler_on_uncaught_exception; - on_focused_node_changed := cef_render_process_handler_on_focused_node_changed; - on_process_message_received := cef_render_process_handler_on_process_message_received; - end; + begin + on_render_thread_created := cef_render_process_handler_on_render_thread_created; + on_web_kit_initialized := cef_render_process_handler_on_web_kit_initialized; + on_browser_created := cef_render_process_handler_on_browser_created; + on_browser_destroyed := cef_render_process_handler_on_browser_destroyed; + get_load_handler := cef_render_process_handler_get_load_handler; + on_before_navigation := cef_render_process_handler_on_before_navigation; + on_context_created := cef_render_process_handler_on_context_created; + on_context_released := cef_render_process_handler_on_context_released; + on_uncaught_exception := cef_render_process_handler_on_uncaught_exception; + on_focused_node_changed := cef_render_process_handler_on_focused_node_changed; + on_process_message_received := cef_render_process_handler_on_process_message_received; + end; end; function TCefRenderProcessHandlerOwn.GetLoadHandler: PCefLoadHandler; @@ -248,4 +274,34 @@ begin end; + +// TCefCustomRenderProcessHandler + +constructor TCefCustomRenderProcessHandler.Create; +begin + inherited Create; + + FMessageName := ''; + FOnCustomMessage := nil; + FOnWebKitReady := nil; +end; + +procedure TCefCustomRenderProcessHandler.OnWebKitInitialized; +begin + if assigned(FOnWebKitReady) then FOnWebKitReady(); +end; + +function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser : ICefBrowser; + sourceProcess : TCefProcessId; + const message : ICefProcessMessage): Boolean; +begin + if assigned(FOnCustomMessage) and (message.Name = FMessageName) then + begin + FOnCustomMessage(browser, sourceProcess, message); + Result := True; + end + else + Result := inherited OnProcessMessageReceived(browser, sourceProcess, message); +end; + end. diff --git a/source/uCEFResponseFilter.pas b/source/uCEFResponseFilter.pas index 03cc960c..475122e6 100644 --- a/source/uCEFResponseFilter.pas +++ b/source/uCEFResponseFilter.pas @@ -53,8 +53,7 @@ type TCefResponseFilterOwn = class(TCefBaseRefCountedOwn, ICefResponseFilter) protected function InitFilter: Boolean; virtual; abstract; - function Filter(dataIn: Pointer; dataInSize, dataInRead: NativeUInt; dataOut: Pointer; - dataOutSize, dataOutWritten: NativeUInt): TCefResponseFilterStatus; virtual; abstract; + function Filter(dataIn: Pointer; dataInSize : NativeUInt; dataInRead: PNativeUInt; dataOut: Pointer; dataOutSize : NativeUInt; dataOutWritten: PNativeUInt): TCefResponseFilterStatus; virtual; abstract; public constructor Create; virtual; end; @@ -70,11 +69,11 @@ begin Result := Ord(InitFilter()); end; -function cef_response_filter_filter(self: PCefResponseFilter; data_in: Pointer; data_in_size, data_in_read: NativeUInt; - data_out: Pointer; data_out_size, data_out_written: NativeUInt): TCefResponseFilterStatus; stdcall; +function cef_response_filter_filter(self: PCefResponseFilter; data_in: Pointer; data_in_size : NativeUInt; var data_in_read: NativeUInt; + data_out: Pointer; data_out_size: NativeUInt; var data_out_written: NativeUInt): TCefResponseFilterStatus; stdcall; begin with TCefResponseFilterOwn(CefGetObject(self)) do - Result := Filter(data_in, data_in_size, data_in_read, data_out, data_out_size, data_out_written); + Result := Filter(data_in, data_in_size, @data_in_read, data_out, data_out_size, @data_out_written); end; constructor TCefResponseFilterOwn.Create; diff --git a/source/uCEFTask.pas b/source/uCEFTask.pas index e1d017be..f3789a12 100644 --- a/source/uCEFTask.pas +++ b/source/uCEFTask.pas @@ -90,16 +90,6 @@ type constructor Create(const aChromiumBrowser : TObject); reintroduce; end; - TCefGetDocumentTask = class(TCefTaskOwn) - protected - FChromiumBrowser : TObject; - - procedure Execute; override; - - public - constructor Create(const aChromiumBrowser : TObject); reintroduce; - end; - TCefDeleteCookiesTask = class(TCefTaskOwn) protected FCallBack : ICefDeleteCookiesCallback; @@ -152,8 +142,10 @@ begin // end; + // TCefTaskRef + procedure TCefTaskRef.Execute; begin PCefTask(FData).execute(FData); @@ -167,8 +159,10 @@ begin Result := nil; end; + // TCefFastTask + constructor TCefFastTask.Create(const method: TCefFastTaskProc); begin inherited Create; @@ -191,7 +185,10 @@ begin CefPostDelayedTask(threadId, Create(method), Delay); end; + // TCefGetHTMLTask + + constructor TCefGetHTMLTask.Create(const aChromiumBrowser : TObject); begin inherited Create; @@ -205,22 +202,10 @@ begin TChromium(FChromiumBrowser).Internal_GetHTML; end; -// TCefGetDocumentTask -constructor TCefGetDocumentTask.Create(const aChromiumBrowser : TObject); -begin - inherited Create; - - FChromiumBrowser := aChromiumBrowser; -end; - -procedure TCefGetDocumentTask.Execute; -begin - if (FChromiumBrowser <> nil) and (FChromiumBrowser is TChromium) then - TChromium(FChromiumBrowser).Internal_VisitDOM; -end; // TCefDeleteCookiesTask + constructor TCefDeleteCookiesTask.Create(const aCallBack : ICefDeleteCookiesCallback); begin inherited Create; @@ -236,8 +221,10 @@ begin CookieManager.DeleteCookies('', '', FCallBack); end; + // TCefUpdatePrefsTask + constructor TCefUpdatePrefsTask.Create(const aChromiumBrowser : TObject); begin inherited Create; @@ -251,8 +238,10 @@ begin TChromium(FChromiumBrowser).Internal_UpdatePreferences; end; + // TCefSavePrefsTask + constructor TCefSavePrefsTask.Create(const aChromiumBrowser : TObject); begin inherited Create; diff --git a/source/uCEFTypes.pas b/source/uCEFTypes.pas index 311dd4fb..602c6354 100644 --- a/source/uCEFTypes.pas +++ b/source/uCEFTypes.pas @@ -265,6 +265,13 @@ type instance: HINST; end; + TFileVersionInfo = record + MajorVer : uint16; + MinorVer : uint16; + Release : uint16; + Build : uint16; + end; + // /include/internal/cef_types.h (cef_rect_t) TCefRect = record x: Integer; @@ -1636,7 +1643,7 @@ type TCefResponseFilter = record base: TCefBaseRefCounted; init_filter: function(self: PCefResponseFilter): Integer; stdcall; - filter: function(self: PCefResponseFilter; data_in: Pointer; data_in_size, data_in_read: NativeUInt; data_out: Pointer; data_out_size, data_out_written: NativeUInt): TCefResponseFilterStatus; stdcall; + filter: function(self: PCefResponseFilter; data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt): TCefResponseFilterStatus; stdcall; end; // /include/capi/cef_auth_callback_capi.h (cef_auth_callback_t) @@ -1790,6 +1797,7 @@ type header_footer_url: TCefString; page_width: Integer; page_height: Integer; + scale_factor: Integer; margin_top: double; margin_right: double; margin_bottom: double;