From 383a1998ca79cd6bdbac49cf207b8541389edd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Fri, 1 Sep 2017 22:44:58 +0200 Subject: [PATCH] Update to CEF 3.3112.1658.g3d5ae83 - Update to CEF 3.3112.1658.g3d5ae83 - Added an example of binary paramenters in the JSEval demo. --- demos/CookieVisitor/CookieVisitor.dproj.local | 14 +- demos/DOMVisitor/DOMVisitor.dproj.local | 6 +- demos/DOMVisitor/DOMVisitor.dsk | 157 +- demos/DOMVisitor/DOMVisitor.stat | 4 +- demos/JSEval/JSEval.dpr | 5 +- demos/JSEval/JSEval.dproj.local | 6 +- demos/JSEval/JSEval.dsk | 187 +- demos/JSEval/JSEval.stat | 10 +- demos/JSEval/uJSEval.dfm | 1 - demos/JSEval/uJSEval.pas | 176 +- demos/JSExtension/JSExtension.dpr | 6 +- demos/JSExtension/JSExtension.dsk | 254 +- demos/JSExtension/JSExtension.stat | 10 +- demos/JSExtension/uJSExtension.pas | 2 +- demos/MiniBrowser/MiniBrowser.dsk | 162 +- demos/MiniBrowser/MiniBrowser.stat | 8 +- .../SchemeRegistrationBrowser.dproj.local | 6 +- .../SchemeRegistrationBrowser.dsk | 184 +- .../SimpleOSRBrowser.dproj.local | 6 +- source/CEF4Delphi.dsk | 180 +- source/CEF4Delphi.stat | 8 +- source/uCEFApplication.pas | 2 +- source/uCEFChromium.pas | 6053 +++++++++-------- source/uCEFRenderProcessHandler.pas | 19 +- 24 files changed, 3801 insertions(+), 3665 deletions(-) diff --git a/demos/CookieVisitor/CookieVisitor.dproj.local b/demos/CookieVisitor/CookieVisitor.dproj.local index a18d69ad..f3b25529 100644 --- a/demos/CookieVisitor/CookieVisitor.dproj.local +++ b/demos/CookieVisitor/CookieVisitor.dproj.local @@ -2,13 +2,13 @@ 2017/08/19 10:36:06.000.317,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/19 10:36:56.000.222,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.pas - 2017/08/19 10:36:56.000.222,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.dfm - 2017/08/19 10:37:04.000.708,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.dproj - 2017/08/19 10:37:17.000.131,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.dfm - 2017/08/19 10:37:17.000.131,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.pas - 2017/08/19 10:37:20.000.965,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\uCookieVisitor.dfm - 2017/08/19 10:37:20.000.965,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\uCookieVisitor.pas + 2017/08/19 10:36:56.000.222,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm + 2017/08/19 10:36:56.000.222,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas + 2017/08/19 10:37:04.000.708,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj + 2017/08/19 10:37:17.000.131,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.dfm + 2017/08/19 10:37:17.000.131,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\UCookieVisitor.pas + 2017/08/19 10:37:20.000.965,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\uCookieVisitor.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.dfm + 2017/08/19 10:37:20.000.965,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\uCookieVisitor.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\CookieVisitor.pas 2017/08/19 10:51:46.000.224,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\CookieVisitor\uSimpleTextViewer.pas diff --git a/demos/DOMVisitor/DOMVisitor.dproj.local b/demos/DOMVisitor/DOMVisitor.dproj.local index fa70fe1d..c739ec21 100644 --- a/demos/DOMVisitor/DOMVisitor.dproj.local +++ b/demos/DOMVisitor/DOMVisitor.dproj.local @@ -2,8 +2,8 @@ 2017/08/12 12:09:33.000.056,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/12 12:12:06.000.226,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitorBrowser\uDOMVisitor.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/12 12:12:06.000.226,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitorBrowser\uDOMVisitor.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm - 2017/08/12 12:12:14.000.517,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitorBrowser\DOMVisitor.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj + 2017/08/12 12:12:06.000.226,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitorBrowser\uDOMVisitor.pas + 2017/08/12 12:12:06.000.226,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitorBrowser\uDOMVisitor.dfm + 2017/08/12 12:12:14.000.517,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitorBrowser\DOMVisitor.dproj diff --git a/demos/DOMVisitor/DOMVisitor.dsk b/demos/DOMVisitor/DOMVisitor.dsk index 998cf641..f2d16a5a 100644 --- a/demos/DOMVisitor/DOMVisitor.dsk +++ b/demos/DOMVisitor/DOMVisitor.dsk @@ -11,24 +11,24 @@ File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uHelloScheme.pas',0,1,116,20,133,0,0,, [Modules] -Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\uDOMVisitor.pas +Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\DOMVisitor.dproj Module1=default.htm -Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\DOMVisitor.dproj +Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\uDOMVisitor.pas Count=3 EditWindowCount=1 -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\uDOMVisitor.pas] -ModuleType=TSourceModule - -[default.htm] -ModuleType=TURLModule - [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\DOMVisitor.dproj] ModuleType=TBaseProject +[default.htm] +ModuleType=TURLModule + +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\uDOMVisitor.pas] +ModuleType=TSourceModule + [EditWindow0] ViewCount=3 -CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\uDOMVisitor.pas +CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\DOMVisitor.dpr View0=0 View1=1 View2=2 @@ -49,16 +49,15 @@ DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 LeftPanelSize=0 -RightPanelSize=2000 -RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF +RightPanelSize=0 BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B3600000000000002E40500000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF TabDockLeftClients=PropertyInspector=0,DockSite3=1 +TabDockRightClients=DockSite4=0,DockSite2=1 [View0] CustomEditViewType=TWelcomePageView @@ -67,9 +66,9 @@ WelcomePageURL=bds:/default.htm [View1] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\DOMVisitor.dpr -CursorX=74 -CursorY=171 -TopLine=37 +CursorX=73 +CursorY=195 +TopLine=153 LeftCol=1 Elisions= Bookmarks= @@ -103,11 +102,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -151,11 +150,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4305 +Height=8857 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4305 +ClientHeight=8857 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -168,14 +167,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=18 +Width=10000 +Height=1357 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -188,12 +187,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=4383 +Width=1875 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -303,12 +302,12 @@ State=0 Left=78 Top=386 Width=1898 -Height=7220 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=7220 -TBDockHeight=7220 +ClientHeight=7164 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -322,12 +321,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -339,8 +338,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-946 -Top=5 +Left=-1210 +Top=-7 Width=2844 Height=6200 MaxLeft=-1 @@ -358,8 +357,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1152 -Top=247 +Left=-8 +Top=287 Width=273 Height=359 MaxLeft=-1 @@ -383,11 +382,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -402,11 +401,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -425,11 +424,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -444,11 +443,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -546,12 +545,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -585,11 +584,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -611,11 +610,11 @@ State=0 Left=0 Top=0 Width=1773 -Height=6794 +Height=6738 MaxLeft=-1 MaxTop=-1 ClientWidth=1773 -ClientHeight=6794 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -629,12 +628,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -697,12 +696,12 @@ State=0 Left=0 Top=18 Width=3820 -Height=1424 +Height=1357 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -711,21 +710,21 @@ ActiveTabID=DebugLogView TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow [DockSite2] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=18 +Left=4 +Top=24 Width=2000 -Height=4585 +Height=9137 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4585 +ClientHeight=9137 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 @@ -745,12 +744,12 @@ State=0 Left=0 Top=0 Width=1898 -Height=7220 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1773 -ClientHeight=6794 -TBDockHeight=7220 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -759,21 +758,21 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=449 +Top=0 Width=2000 -Height=4383 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 diff --git a/demos/DOMVisitor/DOMVisitor.stat b/demos/DOMVisitor/DOMVisitor.stat index fb3ad56c..b20b0b5d 100644 --- a/demos/DOMVisitor/DOMVisitor.stat +++ b/demos/DOMVisitor/DOMVisitor.stat @@ -1,9 +1,9 @@ [Stats] -EditorSecs=688 +EditorSecs=731 DesignerSecs=32 InspectorSecs=4 CompileSecs=17759 -OtherSecs=84 +OtherSecs=85 StartTime=12/08/2017 12:24:08 RealKeys=0 EffectiveKeys=0 diff --git a/demos/JSEval/JSEval.dpr b/demos/JSEval/JSEval.dpr index 2295884c..46d27954 100644 --- a/demos/JSEval/JSEval.dpr +++ b/demos/JSEval/JSEval.dpr @@ -50,6 +50,8 @@ uses uCEFApplication, uCEFRenderProcessHandler, uCEFInterfaces, + uCEFConstants, + uCEFTypes, uJSEval in 'uJSEval.pas' {JSEvalFrm}, uSimpleTextViewer in 'uSimpleTextViewer.pas' {SimpleTextViewerFrm}; @@ -63,7 +65,8 @@ var begin FProcessHandler := TCefCustomRenderProcessHandler.Create; - FProcessHandler.MessageName := EVAL_JS; + FProcessHandler.AddMessageName(EVAL_JS); + FProcessHandler.AddMessageName(BINARY_PARAM_JS); FProcessHandler.OnProcessMessageReceivedEvent := JSEvalFrm.RenderProcessHandler_OnProcessMessageReceivedEvent; GlobalCEFApp := TCefApplication.Create; diff --git a/demos/JSEval/JSEval.dproj.local b/demos/JSEval/JSEval.dproj.local index 57c6f554..d03434be 100644 --- a/demos/JSEval/JSEval.dproj.local +++ b/demos/JSEval/JSEval.dproj.local @@ -2,9 +2,9 @@ 2017/08/12 14:08:23.000.987,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/12 14:09:25.000.836,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm - 2017/08/12 14:09:25.000.836,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/12 14:09:30.000.669,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj + 2017/08/12 14:09:25.000.836,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas + 2017/08/12 14:09:25.000.836,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.dfm + 2017/08/12 14:09:30.000.669,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dproj 2017/08/12 14:43:05.000.727,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uSimpleTextViewer.pas diff --git a/demos/JSEval/JSEval.dsk b/demos/JSEval/JSEval.dsk index efc3b0e8..c3267988 100644 --- a/demos/JSEval/JSEval.dsk +++ b/demos/JSEval/JSEval.dsk @@ -1,34 +1,34 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,85,45,114,0,0,, -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\DOMVisitor\uDOMVisitor.pas',0,1,94,53,127,0,0,, -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uSimpleTextViewer.pas',0,1,1,1,1,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFSchemeRegistrar.pas',0,1,29,1,58,0,0,, -File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,83,1,112,0,0,, -File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas',0,1,220,1,329,0,0,, -File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uJSExtension.pas',0,1,154,79,172,0,0,, -File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,1075,38,1089,0,0,, -File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFPDFPrintCallback.pas',0,1,78,80,113,0,0,, -File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas',0,1,1704,3,1727,0,0,, +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,71,27,107,0,0,, +File_1=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\source\soap\Soap.EncdDecd.pas',0,1,1,64,48,0,0,, +File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas',0,1,1938,16,1960,0,0,, +File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,1087,3,1109,0,0,, +File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFListValue.pas',0,1,177,1,191,0,0,, +File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,3039,1,3061,0,0,, +File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFProcessMessage.pas',0,1,55,1,77,0,0,, +File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,72,76,102,0,0,, +File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas',0,1,249,1,275,0,0,, +File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBinaryValue.pas',0,1,38,68,56,0,0,, [Modules] -Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas +Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dproj Module1=default.htm -Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dproj +Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas Count=3 EditWindowCount=1 -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas] -ModuleType=TSourceModule - -[default.htm] -ModuleType=TURLModule - [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dproj] ModuleType=TBaseProject +[default.htm] +ModuleType=TURLModule + +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas] +ModuleType=TSourceModule + [EditWindow0] ViewCount=3 -CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas +CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dpr View0=0 View1=1 View2=2 @@ -49,16 +49,15 @@ DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 LeftPanelSize=0 -RightPanelSize=2000 -RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF +RightPanelSize=0 BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B3600000000000002E40500000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF TabDockLeftClients=PropertyInspector=0,DockSite3=1 +TabDockRightClients=DockSite4=0,DockSite2=1 [View0] CustomEditViewType=TWelcomePageView @@ -67,8 +66,8 @@ WelcomePageURL=bds:/default.htm [View1] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\JSEval.dpr -CursorX=49 -CursorY=65 +CursorX=60 +CursorY=82 TopLine=46 LeftCol=1 Elisions= @@ -78,12 +77,12 @@ EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\d [View2] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas -CursorX=31 -CursorY=169 -TopLine=167 +CursorX=1 +CursorY=155 +TopLine=116 LeftCol=1 Elisions= -Bookmarks= +Bookmarks={1,274,19}{2,300,34}{3,339,60}{4,422,1} EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas [UndockedDesigner] @@ -103,11 +102,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -151,11 +150,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4305 +Height=8857 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4305 +ClientHeight=8857 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -168,14 +167,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=18 +Width=10000 +Height=1357 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -188,12 +187,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=4383 +Width=1875 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -300,15 +299,15 @@ Create=1 Visible=0 Docked=1 State=0 -Left=1 -Top=24 +Left=78 +Top=386 Width=1898 -Height=9137 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=9137 -TBDockHeight=7220 +ClientHeight=7164 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -322,12 +321,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -339,8 +338,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-946 -Top=5 +Left=-1210 +Top=-7 Width=2844 Height=6200 MaxLeft=-1 @@ -358,8 +357,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1152 -Top=247 +Left=-8 +Top=287 Width=273 Height=359 MaxLeft=-1 @@ -383,11 +382,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -402,11 +401,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -425,11 +424,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -444,11 +443,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -546,12 +545,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -585,11 +584,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -611,11 +610,11 @@ State=0 Left=0 Top=0 Width=1773 -Height=6794 +Height=6738 MaxLeft=-1 MaxTop=-1 ClientWidth=1773 -ClientHeight=6794 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -629,12 +628,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -697,12 +696,12 @@ State=0 Left=0 Top=18 Width=3820 -Height=1424 +Height=1357 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -711,21 +710,21 @@ ActiveTabID=DebugLogView TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow [DockSite2] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=18 +Left=4 +Top=24 Width=2000 -Height=4585 +Height=9137 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4585 +ClientHeight=9137 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 @@ -745,12 +744,12 @@ State=0 Left=0 Top=0 Width=1898 -Height=7220 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1773 -ClientHeight=6794 -TBDockHeight=7220 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -759,21 +758,21 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=449 +Top=0 Width=2000 -Height=4383 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 diff --git a/demos/JSEval/JSEval.stat b/demos/JSEval/JSEval.stat index 74c2af64..953622bb 100644 --- a/demos/JSEval/JSEval.stat +++ b/demos/JSEval/JSEval.stat @@ -1,10 +1,10 @@ [Stats] -EditorSecs=3584 -DesignerSecs=5 +EditorSecs=10251 +DesignerSecs=14 InspectorSecs=2 -CompileSecs=31991 -OtherSecs=84 +CompileSecs=174161 +OtherSecs=281 StartTime=12/08/2017 14:17:43 RealKeys=0 EffectiveKeys=0 -DebugSecs=474 +DebugSecs=2045 diff --git a/demos/JSEval/uJSEval.dfm b/demos/JSEval/uJSEval.dfm index cd3ee8b8..b242973b 100644 --- a/demos/JSEval/uJSEval.dfm +++ b/demos/JSEval/uJSEval.dfm @@ -22,7 +22,6 @@ object JSEvalFrm: TJSEvalFrm Height = 541 Align = alClient TabOrder = 0 - ExplicitHeight = 530 end object AddressBarPnl: TPanel Left = 0 diff --git a/demos/JSEval/uJSEval.pas b/demos/JSEval/uJSEval.pas index fa7240ff..30c0c85e 100644 --- a/demos/JSEval/uJSEval.pas +++ b/demos/JSEval/uJSEval.pas @@ -45,10 +45,10 @@ uses {$IFDEF DELPHI16_UP} Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Menus, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, System.Types, Vcl.ComCtrls, Vcl.ClipBrd, - System.UITypes, + System.UITypes, Soap.EncdDecd, {$ELSE} Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus, - Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, + Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, EncdDecd, {$ENDIF} uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants; @@ -56,10 +56,13 @@ const MINIBROWSER_CREATED = WM_APP + $100; MINIBROWSER_SHOWTEXTVIEWER = WM_APP + $101; MINIBROWSER_EVALJSCODE = WM_APP + $102; + MINIBROWSER_EVALJSBINPARAM = WM_APP + $103; - MINIBROWSER_CONTEXTMENU_EVALJSCODE = MENU_ID_USER_FIRST + 1; + MINIBROWSER_CONTEXTMENU_EVALJSCODE = MENU_ID_USER_FIRST + 1; + MINIBROWSER_CONTEXTMENU_EVALJSBINPARAM = MENU_ID_USER_FIRST + 2; - EVAL_JS = 'JSContextEvalDemo'; + EVAL_JS = 'JSContextEvalDemo'; + BINARY_PARAM_JS = 'JSBinaryParameter'; type TJSEvalFrm = class(TForm) @@ -92,10 +95,12 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message MINIBROWSER_CREATED; procedure ShowTextViewerMsg(var aMessage : TMessage); message MINIBROWSER_SHOWTEXTVIEWER; procedure EvalJSCodeMsg(var aMessage : TMessage); message MINIBROWSER_EVALJSCODE; + procedure EvalJSBinParamMsg(var aMessage : TMessage); message MINIBROWSER_EVALJSBINPARAM; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; procedure ParseEvalJsAnswer(const pMessage: ICefProcessMessage; pBrowser: ICefBrowser; pReturnValue : ICefv8Value; pException : ICefV8Exception); + procedure ParseBinaryValue(const pBrowser : ICefBrowser; const aBinaryValue : ICefBinaryValue); public procedure RenderProcessHandler_OnProcessMessageReceivedEvent(const pBrowser: ICefBrowser; uSourceProcess: TCefProcessId; const pMessage: ICefProcessMessage); @@ -109,13 +114,13 @@ implementation {$R *.dfm} uses - uSimpleTextViewer, uCefProcessMessage; + uSimpleTextViewer, uCefProcessMessage, uCefBinaryValue, uCefMiscFunctions; // 99.9% of the code in this demo was created by xpert13 and shared in the CEF4Delphi forum. // Steps to evaluate some JavaScript code using the V8Context // ---------------------------------------------------------- -// 1. Create a TCefCustomRenderProcessHandler in the DPR file, set a message name and the OnCustomMessage event. +// 1. Create a TCefCustomRenderProcessHandler in the DPR file, adds a message name and sets the OnCustomMessage event. // 2. Set the TCefCustomRenderProcessHandler in the GlobalCEFApp.RenderProcessHandler property. // 3. To get the Javascript code in this demo we use a context menu that sends a MINIBROWSER_EVALJSCODE to the form. // 4. The EvalJSCodeMsg asks for the Javascript code and sends it to the renderer using a process message. @@ -125,6 +130,30 @@ uses // message to the form. // 8. ShowTextViewerMsg shows the results safely using a SimpleTextViewer. + + +// This demo also has an example of binary parameters in process messages +// ---------------------------------------------------------------------- +// 1. Create a TCefCustomRenderProcessHandler in the DPR file, adds a message name and sets the OnCustomMessage event. +// 2. Set the TCefCustomRenderProcessHandler in the GlobalCEFApp.RenderProcessHandler property. +// 3. The context menu has a 'Send JPEG image' option that sends a MINIBROWSER_EVALJSBINPARAM message to the form. +// 4. EvalJSBinParamMsg asks for a JPEG image and sends a process message with a ICefBinaryValue parameter to the renderer process. +// 5. The renderer process parses the binary parameter in the ParseBinaryValue function and sends back the image size and encoded image data to the browser process. +// 6. Chromium1ProcessMessageReceived receives the message, stores the results and sends a MINIBROWSER_SHOWTEXTVIEWER +// message to the form. +// 7. ShowTextViewerMsg shows the results safely using a SimpleTextViewer. + + +// About binary parameters +// ----------------------- +// There is a size limit in the binary parameters of only a few kilobytes. +// For more info and alternatives, read this thread in the official CEF3 forum : +// http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10590 +// +// Compress the binary data if necessary! + + + procedure TJSEvalFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); begin PostMessage(Handle, MINIBROWSER_CREATED, 0, 0); @@ -136,7 +165,8 @@ procedure TJSEvalFrm.Chromium1BeforeContextMenu(Sender : TObject; const params : ICefContextMenuParams; const model : ICefMenuModel); begin - model.AddItem(MINIBROWSER_CONTEXTMENU_EVALJSCODE, 'Evaluate JavaScript code...'); + model.AddItem(MINIBROWSER_CONTEXTMENU_EVALJSCODE, 'Evaluate JavaScript code...'); + model.AddItem(MINIBROWSER_CONTEXTMENU_EVALJSBINPARAM, 'Send JPEG image...'); end; procedure TJSEvalFrm.Chromium1ContextMenuCommand(Sender : TObject; @@ -150,7 +180,8 @@ begin Result := False; case commandId of - MINIBROWSER_CONTEXTMENU_EVALJSCODE : PostMessage(Handle, MINIBROWSER_EVALJSCODE, 0, 0); + MINIBROWSER_CONTEXTMENU_EVALJSCODE : PostMessage(Handle, MINIBROWSER_EVALJSCODE, 0, 0); + MINIBROWSER_CONTEXTMENU_EVALJSBINPARAM : PostMessage(Handle, MINIBROWSER_EVALJSBINPARAM, 0, 0); end; end; @@ -201,11 +232,63 @@ begin if (length(TempScript) > 0) then begin TempMsg := TCefProcessMessageRef.New(EVAL_JS); - TempMsg.ArgumentList.SetString(0, TempScript); - Chromium1.SendProcessMessage(PID_RENDERER, TempMsg); + + if TempMsg.ArgumentList.SetString(0, TempScript) then + Chromium1.SendProcessMessage(PID_RENDERER, TempMsg); end; end; +procedure TJSEvalFrm.EvalJSBinParamMsg(var aMessage : TMessage); +var + TempMsg : ICefProcessMessage; + TempOpenDialog : TOpenDialog; + TempStream : TFileStream; + TempBinValue : ICefBinaryValue; + TempBuffer : TBytes; + TempSize : NativeUInt; + TempPointer : pointer; +begin + TempOpenDialog := nil; + TempStream := nil; + + try + try + TempOpenDialog := TOpenDialog.Create(nil); + TempOpenDialog.Filter := 'JPEG files (*.jpg)|*.JPG'; + + if TempOpenDialog.Execute then + begin + TempStream := TFileStream.Create(TempOpenDialog.FileName, fmOpenRead); + TempSize := TempStream.Size; + + if (TempSize > 0) then + begin + SetLength(TempBuffer, TempSize); + TempSize := TempStream.Read(TempBuffer, TempSize); + + if (TempSize > 0) then + begin + TempPointer := @TempBuffer[0]; + TempBinValue := TCefBinaryValueRef.New(TempPointer, TempSize); + + TempMsg := TCefProcessMessageRef.New(BINARY_PARAM_JS); + + if TempMsg.ArgumentList.SetBinary(0, TempBinValue) then + Chromium1.SendProcessMessage(PID_RENDERER, TempMsg); + end; + end; + end; + except + on e : exception do + if CustomExceptionHandler('TJSEvalFrm.EvalJSBinParamMsg', e) then raise; + end; + finally + if (TempOpenDialog <> nil) then FreeAndNil(TempOpenDialog); + if (TempStream <> nil) then FreeAndNil(TempStream); + SetLength(TempBuffer, 0); + end; +end; + procedure TJSEvalFrm.RenderProcessHandler_OnProcessMessageReceivedEvent(const pBrowser : ICefBrowser; uSourceProcess : TCefProcessId; const pMessage : ICefProcessMessage); @@ -214,25 +297,32 @@ var pReturnValue : ICefv8Value; pException : ICefV8Exception; TempScript : string; + TempBinValue : ICefBinaryValue; begin if (pMessage = nil) or (pMessage.ArgumentList = nil) then exit; if (pMessage.Name = EVAL_JS) then - begin - TempScript := pMessage.ArgumentList.GetString(0); + begin + TempScript := pMessage.ArgumentList.GetString(0); - if (length(TempScript) > 0) then + if (length(TempScript) > 0) then + begin + pV8Context := pBrowser.MainFrame.GetV8Context; + + if pV8Context.Enter then + begin + pV8Context.Eval(TempScript, '', 1, pReturnValue, pException); + ParseEvalJsAnswer(pMessage, pBrowser, pReturnValue, pException); + pV8Context.Exit; + end; + end; + end + else + if (pMessage.Name = BINARY_PARAM_JS) then begin - pV8Context := pBrowser.MainFrame.GetV8Context; - - if pV8Context.Enter then - begin - pV8Context.Eval(TempScript, '', 1, pReturnValue, pException); - ParseEvalJsAnswer(pMessage, pBrowser, pReturnValue, pException); - pV8Context.Exit; - end; + TempBinValue := pMessage.ArgumentList.GetBinary(0); + ParseBinaryValue(pBrowser, TempBinValue); end; - end; end; procedure TJSEvalFrm.ParseEvalJsAnswer(const pMessage : ICefProcessMessage; @@ -277,6 +367,39 @@ begin pBrowser.SendProcessMessage(PID_BROWSER, pAnswer); end; +procedure TJSEvalFrm.ParseBinaryValue(const pBrowser : ICefBrowser; const aBinaryValue : ICefBinaryValue); +var + pAnswer : ICefProcessMessage; + TempBuffer : TBytes; + TempPointer : pointer; + TempSize : NativeUInt; + TempString : string; +begin + if (aBinaryValue = nil) then exit; + + pAnswer := TCefProcessMessageRef.New(BINARY_PARAM_JS); + TempSize := aBinaryValue.GetSize; + + if (TempSize > 0) then + begin + SetLength(TempBuffer, TempSize); + TempPointer := @TempBuffer[0]; + TempSize := aBinaryValue.GetData(TempPointer, TempSize, 0); + + if (TempSize > 0) then + begin + TempString := EncodeBase64(TempPointer, TempSize); + TempString := 'Image size : ' + inttostr(TempSize) + #13 + #10 + + 'Encoded image : ' + TempString; + + pAnswer.ArgumentList.SetString(0, TempString); + pBrowser.SendProcessMessage(PID_BROWSER, pAnswer); + end; + + SetLength(TempBuffer, 0); + end; +end; + procedure TJSEvalFrm.Chromium1ProcessMessageReceived(Sender : TObject; const browser : ICefBrowser; sourceProcess : TCefProcessId; @@ -292,7 +415,14 @@ begin Result := True; end else - Result := False; + if (message.Name = BINARY_PARAM_JS) then + begin + FText := message.ArgumentList.GetString(0); + PostMessage(Handle, MINIBROWSER_SHOWTEXTVIEWER, 0, 0); + Result := True; + end + else + Result := False; end; end. diff --git a/demos/JSExtension/JSExtension.dpr b/demos/JSExtension/JSExtension.dpr index 31ca6349..b934681b 100644 --- a/demos/JSExtension/JSExtension.dpr +++ b/demos/JSExtension/JSExtension.dpr @@ -50,6 +50,8 @@ uses SysUtils, {$ENDIF } uCEFApplication, + uCEFMiscFunctions, + uCEFConstants, uCEFRenderProcessHandler, uCEFInterfaces, uCEFv8Handler, @@ -84,14 +86,14 @@ begin GlobalCEFApp.RenderProcessHandler := TempProcessHandler as ICefRenderProcessHandler; // The directories are optional. - { +{ GlobalCEFApp.FrameworkDirPath := 'cef'; GlobalCEFApp.ResourcesDirPath := 'cef'; GlobalCEFApp.LocalesDirPath := 'cef\locales'; GlobalCEFApp.cache := 'cef\cache'; GlobalCEFApp.cookies := 'cef\cookies'; GlobalCEFApp.UserDataPath := 'cef\User Data'; - } +} if GlobalCEFApp.StartMainProcess then begin diff --git a/demos/JSExtension/JSExtension.dsk b/demos/JSExtension/JSExtension.dsk index 1d3cd34f..9311a687 100644 --- a/demos/JSExtension/JSExtension.dsk +++ b/demos/JSExtension/JSExtension.dsk @@ -1,46 +1,41 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,70,33,76,0,0,, -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFSchemeRegistrar.pas',0,1,16,3037,58,0,0,, -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFListValue.pas',0,1,53,21,82,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uTestExtension.pas',0,1,46,48,81,0,0,, -File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uSimpleTextViewer.pas',0,1,1,22,25,0,0,, -File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas',0,1,496,16,519,0,0,, -File_6=TSourceModule,'c:\program files\embarcadero\studio\17.0\source\rtl\common\System.Generics.Collections.pas',0,1,1121,1,1143,0,0,, -File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,1403,1,1425,0,0,, -File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\Unit1.pas',0,1,1,1,1,0,0,, +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas',0,1,244,39,272,0,0,, +File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,792,3,821,0,0,, +File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,636,30,664,0,0,, +File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,70,33,76,0,0,, +File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFSchemeRegistrar.pas',0,1,16,3037,58,0,0,, +File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFListValue.pas',0,1,53,21,82,0,0,, +File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uSimpleTextViewer.pas',0,1,1,22,25,0,0,, +File_7=TSourceModule,'c:\program files\embarcadero\studio\17.0\source\rtl\common\System.Generics.Collections.pas',0,1,1121,1,1143,0,0,, +File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,1403,1,1425,0,0,, [Modules] -Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas -Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas -Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\JSExtension.dproj -Module3=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uJSExtension.pas -Module4=default.htm -Count=5 +Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\JSExtension.dproj +Module1=default.htm +Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uJSExtension.pas +Module3=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uTestExtension.pas +Count=4 EditWindowCount=1 -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas] -ModuleType=TSourceModule - -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas] -ModuleType=TSourceModule - [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\JSExtension.dproj] ModuleType=TBaseProject -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uJSExtension.pas] -ModuleType=TSourceModule - [default.htm] ModuleType=TURLModule +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uJSExtension.pas] +ModuleType=TSourceModule + +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uTestExtension.pas] +ModuleType=TSourceModule + [EditWindow0] -ViewCount=5 -CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas +ViewCount=4 +CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\JSExtension.dpr View0=0 View1=1 View2=2 View3=3 -View4=4 PercentageSizes=1 Create=1 Visible=1 @@ -57,18 +52,16 @@ ClientHeight=9417 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=1898 -LeftPanelClients=PropertyInspector,DockSite3 -LeftPanelData=00000800010100000000A219000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000972300001100000050726F7065727479496E73706563746F72FFFFFFFF -RightPanelSize=2000 -RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF +LeftPanelSize=0 +RightPanelSize=0 BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B3600000000000002E40500000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF +TabDockLeftClients=PropertyInspector=0,DockSite3=1 +TabDockRightClients=DockSite4=0,DockSite2=1 [View0] CustomEditViewType=TWelcomePageView @@ -77,8 +70,8 @@ WelcomePageURL=bds:/default.htm [View1] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\JSExtension.dpr -CursorX=45 -CursorY=83 +CursorX=1 +CursorY=97 TopLine=60 LeftCol=1 Elisions= @@ -87,32 +80,21 @@ EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\d [View2] CustomEditViewType=TEditView -Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas -CursorX=30 -CursorY=664 -TopLine=636 +Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uTestExtension.pas +CursorX=1 +CursorY=72 +TopLine=49 LeftCol=1 Elisions= Bookmarks= -EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas +EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uTestExtension.pas [View3] CustomEditViewType=TEditView -Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas -CursorX=3 -CursorY=821 -TopLine=792 -LeftCol=1 -Elisions= -Bookmarks= -EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas - -[View4] -CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSExtension\uJSExtension.pas -CursorX=31 -CursorY=234 -TopLine=182 +CursorX=79 +CursorY=165 +TopLine=152 LeftCol=1 Elisions= Bookmarks= @@ -135,11 +117,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -183,11 +165,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4305 +Height=8857 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4305 +ClientHeight=8857 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -200,14 +182,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=18 +Width=10000 +Height=1357 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -220,12 +202,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=4383 +Width=1875 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -275,8 +257,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-148 -Top=-132 +Left=-8 +Top=-30 Width=1844 Height=3139 MaxLeft=-1 @@ -329,18 +311,18 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=357 +Left=78 +Top=386 Width=1898 -Height=5415 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=5415 -TBDockHeight=7220 +ClientHeight=7164 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -354,12 +336,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6939 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6939 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -371,8 +353,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-898 -Top=-132 +Left=-1210 +Top=-7 Width=2844 Height=6200 MaxLeft=-1 @@ -390,8 +372,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1026 -Top=-132 +Left=-8 +Top=287 Width=273 Height=359 MaxLeft=-1 @@ -415,11 +397,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -434,11 +416,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -457,11 +439,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -476,11 +458,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -514,11 +496,11 @@ State=0 Left=0 Top=0 Width=2336 -Height=1200 +Height=964 MaxLeft=-1 MaxTop=-1 ClientWidth=2336 -ClientHeight=1200 +ClientHeight=964 TBDockHeight=2321 LRDockWidth=2820 Dockable=1 @@ -578,12 +560,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6939 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6939 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -595,8 +577,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=0 -Top=0 +Left=249 +Top=709 Width=2859 Height=3206 MaxLeft=-1 @@ -617,11 +599,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -642,12 +624,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1898 -Height=3554 +Width=1773 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -661,12 +643,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6939 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6939 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -727,14 +709,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 +Top=18 Width=3820 -Height=1424 +Height=1357 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -743,22 +725,22 @@ ActiveTabID=DebugLogView TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow [DockSite2] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=18 +Left=4 +Top=24 Width=2000 -Height=4585 +Height=9137 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4585 -TBDockHeight=7220 +ClientHeight=9137 +TBDockHeight=7164 LRDockWidth=2000 Dockable=1 StayOnTop=0 @@ -767,22 +749,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=18 +Top=0 Width=1898 -Height=3554 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 -TBDockHeight=7220 +ClientWidth=1773 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -791,22 +773,22 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=449 +Top=0 Width=2000 -Height=4383 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 -TBDockHeight=7220 +ClientWidth=1875 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=2000 Dockable=1 StayOnTop=0 diff --git a/demos/JSExtension/JSExtension.stat b/demos/JSExtension/JSExtension.stat index a3d6cad8..482ae0a6 100644 --- a/demos/JSExtension/JSExtension.stat +++ b/demos/JSExtension/JSExtension.stat @@ -1,10 +1,10 @@ [Stats] -EditorSecs=3339 -DesignerSecs=25 +EditorSecs=4233 +DesignerSecs=28 InspectorSecs=43 -CompileSecs=114312 -OtherSecs=222 +CompileSecs=181721 +OtherSecs=462 StartTime=25/07/2017 22:09:15 RealKeys=0 EffectiveKeys=0 -DebugSecs=760 +DebugSecs=1042 diff --git a/demos/JSExtension/uJSExtension.pas b/demos/JSExtension/uJSExtension.pas index 5718d456..7607bcae 100644 --- a/demos/JSExtension/uJSExtension.pas +++ b/demos/JSExtension/uJSExtension.pas @@ -99,7 +99,7 @@ implementation {$R *.dfm} uses - uSimpleTextViewer; + uSimpleTextViewer, uCEFMiscFunctions; // The CEF3 document describing extensions is here : // https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md diff --git a/demos/MiniBrowser/MiniBrowser.dsk b/demos/MiniBrowser/MiniBrowser.dsk index 9d3b202d..df0e410a 100644 --- a/demos/MiniBrowser/MiniBrowser.dsk +++ b/demos/MiniBrowser/MiniBrowser.dsk @@ -1,5 +1,5 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas',0,1,134,80,161,0,0,,{1,231,1} +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\uMiniBrowser.pas',0,1,134,80,161,0,0,,{1 File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,2968,47,2983,0,0,, File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumWindow.pas',0,1,70,37,58,0,0,, File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFWindowParent.pas',0,1,65,27,66,0,0,, @@ -43,18 +43,16 @@ ClientHeight=9417 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=1898 -LeftPanelClients=PropertyInspector,DockSite3 -LeftPanelData=00000800010100000000A219000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000972300001100000050726F7065727479496E73706563746F72FFFFFFFF -RightPanelSize=2000 -RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF +LeftPanelSize=0 +RightPanelSize=0 BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B3600000000000002E40500000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF +TabDockLeftClients=PropertyInspector=0,DockSite3=1 +TabDockRightClients=DockSite4=0,DockSite2=1 [View0] CustomEditViewType=TWelcomePageView @@ -63,8 +61,8 @@ WelcomePageURL=bds:/default.htm [View1] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\MiniBrowser\MiniBrowser.dpr -CursorX=53 -CursorY=76 +CursorX=2 +CursorY=73 TopLine=43 LeftCol=1 Elisions= @@ -88,11 +86,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -136,11 +134,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4305 +Height=8857 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4305 +ClientHeight=8857 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -153,14 +151,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=18 +Width=10000 +Height=1357 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -173,12 +171,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=4383 +Width=1875 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -228,8 +226,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-121 -Top=-70 +Left=-8 +Top=-30 Width=1844 Height=3139 MaxLeft=-1 @@ -282,17 +280,17 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=357 +Left=78 +Top=386 Width=1898 -Height=5415 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=5415 +ClientHeight=7164 TBDockHeight=7164 LRDockWidth=1898 Dockable=1 @@ -307,12 +305,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -324,8 +322,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-946 -Top=5 +Left=-1210 +Top=-7 Width=2844 Height=6200 MaxLeft=-1 @@ -343,8 +341,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1152 -Top=247 +Left=-8 +Top=287 Width=273 Height=359 MaxLeft=-1 @@ -368,11 +366,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -387,11 +385,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -410,11 +408,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -429,11 +427,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -531,12 +529,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -570,11 +568,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -595,12 +593,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1898 -Height=3554 +Width=1773 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -614,12 +612,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -682,12 +680,12 @@ State=0 Left=0 Top=18 Width=3820 -Height=1424 +Height=1357 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -696,21 +694,21 @@ ActiveTabID=DebugLogView TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow [DockSite2] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=18 +Left=4 +Top=24 Width=2000 -Height=4585 +Height=9137 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4585 +ClientHeight=9137 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 @@ -720,21 +718,21 @@ 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=18 +Top=0 Width=1898 -Height=3554 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=7164 LRDockWidth=1898 Dockable=1 @@ -744,21 +742,21 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=449 +Top=0 Width=2000 -Height=4383 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 diff --git a/demos/MiniBrowser/MiniBrowser.stat b/demos/MiniBrowser/MiniBrowser.stat index f8c364d0..ba4ff591 100644 --- a/demos/MiniBrowser/MiniBrowser.stat +++ b/demos/MiniBrowser/MiniBrowser.stat @@ -1,10 +1,10 @@ [Stats] -EditorSecs=46609 +EditorSecs=46531 DesignerSecs=2443 InspectorSecs=1781 -CompileSecs=2487971 -OtherSecs=7304 +CompileSecs=2516644 +OtherSecs=7360 StartTime=11/02/2017 10:51:15 RealKeys=0 EffectiveKeys=0 -DebugSecs=36087 +DebugSecs=37790 diff --git a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj.local b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj.local index 128194ac..187cb5db 100644 --- a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj.local +++ b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj.local @@ -2,9 +2,9 @@ 2017/08/12 11:25:15.000.051,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/12 11:26:00.000.707,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/08/12 11:26:00.000.707,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm - 2017/08/12 11:26:06.000.294,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\SchemeRegistrationBrowser.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj + 2017/08/12 11:26:00.000.707,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.pas + 2017/08/12 11:26:00.000.707,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.dfm + 2017/08/12 11:26:06.000.294,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\SchemeRegistrationBrowser.dproj 2017/08/12 11:27:56.000.909,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uHelloScheme.pas diff --git a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dsk b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dsk index a57dacab..98349959 100644 --- a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dsk +++ b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dsk @@ -10,8 +10,8 @@ File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF [Modules] Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\SchemeRegistrationBrowser.dproj -Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.pas -Module2=default.htm +Module1=default.htm +Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.pas Module3=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uHelloScheme.pas Count=4 EditWindowCount=1 @@ -19,12 +19,12 @@ EditWindowCount=1 [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\SchemeRegistrationBrowser.dproj] ModuleType=TBaseProject -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.pas] -ModuleType=TSourceModule - [default.htm] ModuleType=TURLModule +[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uSchemeRegistrationBrowser.pas] +ModuleType=TSourceModule + [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SchemeRegistrationBrowser\uHelloScheme.pas] ModuleType=TSourceModule @@ -51,18 +51,16 @@ ClientHeight=9417 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=1898 -LeftPanelClients=PropertyInspector,DockSite3 -LeftPanelData=00000800010100000000A219000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000972300001100000050726F7065727479496E73706563746F72FFFFFFFF -RightPanelSize=2000 -RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF +LeftPanelSize=0 +RightPanelSize=0 BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B3600000000000002E40500000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF +TabDockLeftClients=PropertyInspector=0,DockSite3=1 +TabDockRightClients=DockSite4=0,DockSite2=1 [View0] CustomEditViewType=TWelcomePageView @@ -118,11 +116,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -166,11 +164,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4305 +Height=8857 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4305 +ClientHeight=8857 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -183,14 +181,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 -Width=2773 -Height=1424 +Top=18 +Width=10000 +Height=1357 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -203,12 +201,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=4383 +Width=1875 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -258,8 +256,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-148 -Top=-132 +Left=-8 +Top=-30 Width=1844 Height=3139 MaxLeft=-1 @@ -312,18 +310,18 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=357 +Left=78 +Top=386 Width=1898 -Height=5415 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=5415 -TBDockHeight=7220 +ClientHeight=7164 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -337,12 +335,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6939 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6939 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -354,8 +352,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-898 -Top=-132 +Left=-1210 +Top=-7 Width=2844 Height=6200 MaxLeft=-1 @@ -373,8 +371,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1026 -Top=-132 +Left=-8 +Top=287 Width=273 Height=359 MaxLeft=-1 @@ -398,11 +396,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -417,11 +415,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -440,11 +438,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -459,11 +457,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -497,11 +495,11 @@ State=0 Left=0 Top=0 Width=2336 -Height=1200 +Height=964 MaxLeft=-1 MaxTop=-1 ClientWidth=2336 -ClientHeight=1200 +ClientHeight=964 TBDockHeight=2321 LRDockWidth=2820 Dockable=1 @@ -561,12 +559,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6939 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6939 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -578,8 +576,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=0 -Top=0 +Left=249 +Top=709 Width=2859 Height=3206 MaxLeft=-1 @@ -600,11 +598,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -625,12 +623,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1898 -Height=3554 +Width=1773 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -644,12 +642,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6939 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6939 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -710,14 +708,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=0 +Top=18 Width=3820 -Height=1424 +Height=1357 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -726,22 +724,22 @@ ActiveTabID=DebugLogView TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow [DockSite2] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=18 +Left=4 +Top=24 Width=2000 -Height=4585 +Height=9137 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4585 -TBDockHeight=7220 +ClientHeight=9137 +TBDockHeight=7164 LRDockWidth=2000 Dockable=1 StayOnTop=0 @@ -750,22 +748,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=18 +Top=0 Width=1898 -Height=3554 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 -TBDockHeight=7220 +ClientWidth=1773 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -774,22 +772,22 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=449 +Top=0 Width=2000 -Height=4383 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 -TBDockHeight=7220 +ClientWidth=1875 +ClientHeight=6738 +TBDockHeight=7164 LRDockWidth=2000 Dockable=1 StayOnTop=0 diff --git a/demos/SimpleOSRBrowser/SimpleOSRBrowser.dproj.local b/demos/SimpleOSRBrowser/SimpleOSRBrowser.dproj.local index 6f99c976..f14fdcf0 100644 --- a/demos/SimpleOSRBrowser/SimpleOSRBrowser.dproj.local +++ b/demos/SimpleOSRBrowser/SimpleOSRBrowser.dproj.local @@ -2,8 +2,8 @@ 2017/01/22 17:26:58.000.836,=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/01/22 17:28:20.000.762,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi demos\SimpleOSRBrowser\uSimpleOSRBrowser.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas - 2017/01/22 17:28:20.000.762,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi demos\SimpleOSRBrowser\uSimpleOSRBrowser.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm - 2017/01/22 17:28:25.000.780,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi demos\SimpleOSRBrowser\SimpleOSRBrowser.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj + 2017/01/22 17:28:20.000.762,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi demos\SimpleOSRBrowser\uSimpleOSRBrowser.pas + 2017/01/22 17:28:20.000.762,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi demos\SimpleOSRBrowser\uSimpleOSRBrowser.dfm + 2017/01/22 17:28:25.000.780,C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi demos\SimpleOSRBrowser\SimpleOSRBrowser.dproj diff --git a/source/CEF4Delphi.dsk b/source/CEF4Delphi.dsk index 1f10e570..7e8d7027 100644 --- a/source/CEF4Delphi.dsk +++ b/source/CEF4Delphi.dsk @@ -1,14 +1,14 @@ [Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,22,53,62,0,0,, -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,127,56,176,0,0,, -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumEvents.pas',0,1,80,112,109,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas',0,1,641,3,670,0,0,, -File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFClient.pas',0,1,254,9,277,0,0,, -File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,124,80,245,119,0,0,, -File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderProcessHandler.pas',0,1,63,101,366,0,0,, -File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRenderHandler.pas',0,1,44,85,73,0,0,, -File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBrowser.pas',0,1,1,1,1,0,0,, -File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFRequest.pas',0,1,91,62,126,0,0,, +File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,22,39,60,0,0,, +File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFListValue.pas',0,1,34,19,53,0,0,, +File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBinaryValue.pas',0,1,20,78,58,0,0,, +File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromium.pas',0,1,1755,24,1765,0,0,, +File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFValue.pas',0,1,34,3,53,0,0,, +File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas',0,1,1137,76,1167,0,0,, +File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFBrowser.pas',0,1,52,89,80,0,0,, +File_7=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\JSEval\uJSEval.pas',0,1,238,103,281,0,0,, +File_8=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFX509Certificate.pas',0,1,111,36,149,0,0,, +File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFChromiumEvents.pas',0,1,80,112,109,0,0,, [Modules] Module0=default.htm @@ -38,18 +38,16 @@ ClientHeight=9417 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=1898 -LeftPanelClients=PropertyInspector,DockSite3 -LeftPanelData=00000800010100000000A219000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000972300001100000050726F7065727479496E73706563746F72FFFFFFFF -RightPanelSize=2000 -RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF -BottomPanelSize=0 +LeftPanelSize=0 +RightPanelSize=0 +BottomPanelSize=1508 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022506000000000000FFFFFFFF +BottomPanelData=0000080001020100000009000000446F636B53697465313B3600000000000002E40500000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF +TabDockLeftClients=PropertyInspector=0,DockSite3=1 +TabDockRightClients=DockSite4=0,DockSite2=1 [View0] CustomEditViewType=TWelcomePageView @@ -72,11 +70,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -120,11 +118,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=4305 +Height=7231 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4305 +ClientHeight=7231 TBDockHeight=5897 LRDockWidth=2352 Dockable=1 @@ -133,18 +131,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=18 +Width=10000 +Height=1357 MaxLeft=-1 MaxTop=-1 -ClientWidth=2773 -ClientHeight=1424 -TBDockHeight=1424 +ClientWidth=10000 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=2773 Dockable=1 StayOnTop=0 @@ -157,12 +155,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=4383 +Width=1875 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -212,8 +210,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-121 -Top=-70 +Left=-8 +Top=-30 Width=1844 Height=3139 MaxLeft=-1 @@ -266,17 +264,17 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=357 +Left=78 +Top=386 Width=1898 -Height=5415 +Height=7164 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=5415 +ClientHeight=7164 TBDockHeight=7164 LRDockWidth=1898 Dockable=1 @@ -291,12 +289,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -308,8 +306,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-946 -Top=5 +Left=-1210 +Top=-7 Width=2844 Height=6200 MaxLeft=-1 @@ -327,8 +325,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1152 -Top=247 +Left=-8 +Top=287 Width=273 Height=359 MaxLeft=-1 @@ -352,11 +350,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -371,11 +369,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -394,11 +392,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -413,11 +411,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -515,12 +513,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -554,11 +552,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1143 +Height=1076 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1143 +ClientHeight=1076 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -579,12 +577,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=1898 -Height=3554 +Width=1773 +Height=6738 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -598,12 +596,12 @@ Docked=1 State=0 Left=0 Top=0 -Width=2000 -Height=6883 +Width=1875 +Height=6457 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=6883 +ClientWidth=1875 +ClientHeight=6457 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -666,12 +664,12 @@ State=0 Left=0 Top=18 Width=3820 -Height=1424 +Height=1357 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1424 -TBDockHeight=1424 +ClientHeight=1357 +TBDockHeight=1357 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -680,21 +678,21 @@ ActiveTabID=DebugLogView TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow [DockSite2] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 -Left=0 -Top=18 +Left=4 +Top=24 Width=2000 -Height=4585 +Height=7511 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=4585 +ClientHeight=7511 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 @@ -704,21 +702,21 @@ 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=18 +Top=0 Width=1898 -Height=3554 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=1898 -ClientHeight=3554 +ClientWidth=1773 +ClientHeight=6738 TBDockHeight=7164 LRDockWidth=1898 Dockable=1 @@ -728,21 +726,21 @@ ActiveTabID=StructureView TabDockClients=StructureView,ClassBrowserTool [DockSite4] -HostDockSite=DockRightPanel +HostDockSite=RightTabDock DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 -Top=449 +Top=0 Width=2000 -Height=4383 +Height=7164 MaxLeft=-1 MaxTop=-1 -ClientWidth=2000 -ClientHeight=4383 +ClientWidth=1875 +ClientHeight=6738 TBDockHeight=7164 LRDockWidth=2000 Dockable=1 diff --git a/source/CEF4Delphi.stat b/source/CEF4Delphi.stat index 39771239..ecf9ef44 100644 --- a/source/CEF4Delphi.stat +++ b/source/CEF4Delphi.stat @@ -1,9 +1,9 @@ [Stats] -EditorSecs=155598 -DesignerSecs=97 +EditorSecs=156216 +DesignerSecs=98 InspectorSecs=326 -CompileSecs=5004540 -OtherSecs=16462 +CompileSecs=5065676 +OtherSecs=16679 StartTime=22/01/2017 10:49:52 RealKeys=0 EffectiveKeys=0 diff --git a/source/uCEFApplication.pas b/source/uCEFApplication.pas index d25b5ead..ea56d1e1 100644 --- a/source/uCEFApplication.pas +++ b/source/uCEFApplication.pas @@ -57,7 +57,7 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 3; CEF_SUPPORTED_VERSION_MINOR = 3112; - CEF_SUPPORTED_VERSION_RELEASE = 1657; + CEF_SUPPORTED_VERSION_RELEASE = 1658; CEF_SUPPORTED_VERSION_BUILD = 0; CEF_CHROMEELF_VERSION_MAJOR = 60; diff --git a/source/uCEFChromium.pas b/source/uCEFChromium.pas index d11b05e2..e1384743 100644 --- a/source/uCEFChromium.pas +++ b/source/uCEFChromium.pas @@ -1,941 +1,941 @@ -// ************************************************************************ -// ***************************** CEF4Delphi ******************************* -// ************************************************************************ -// -// CEF4Delphi is based on DCEF3 which uses CEF3 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 © 2017 Salvador Díaz 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 uCEFChromium; - -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} - -{$I cef.inc} - -interface - -uses - {$IFDEF DELPHI16_UP} - WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, WinApi.ActiveX, - {$ELSE} - Windows, Messages, Classes, Controls, Graphics, Forms, ActiveX, - {$ENDIF} - uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient, - uCEFPDFPrintCallback, uCEFStringVisitor, uCEFConstants, uCEFTask, - uCEFDeleteCookiesCallback, uCEFDomVisitor, uCEFChromiumEvents, - uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions, - uCEFDragAndDropMgr; - -type - TChromium = class(TComponent, IChromiumEvents) - protected - FCompHandle : HWND; - FVisitor : ICefStringVisitor; - FPDFPrintcb : ICefPdfPrintCallback; - FCookiDeletercb : ICefDeleteCookiesCallback; - FHandler : ICefClient; - FBrowser : ICefBrowser; - FBrowserId : Integer; - FDefaultUrl : ustring; - FOptions : TChromiumOptions; - FFontOptions : TChromiumFontOptions; - FPDFPrintOptions : TPDFPrintOptions; - FDefaultEncoding : ustring; - FProxyType : integer; - FProxyServer : string; - FProxyPort : integer; - FProxyUsername : string; - FProxyPassword : string; - FProxyScriptURL : string; - FProxyByPassList : string; - FUpdatePreferences : boolean; - FCustomHeaderName : string; - FCustomHeaderValue : string; - FAddCustomHeader : boolean; - FDoNotTrack : boolean; - FSendReferrer : boolean; - FHyperlinkAuditing : boolean; - FCookiePrefs : integer; - FImagesPrefs : integer; - FCMStoragePath : ustring; - FZoomStep : byte; - FWindowName : string; - FPrefsFileName : string; - FIsOSR : boolean; - FInitialized : boolean; - FClosing : boolean; - FWindowInfo : TCefWindowInfo; - FBrowserSettings : TCefBrowserSettings; - FDevWindowInfo : TCefWindowInfo; - FDevBrowserSettings : TCefBrowserSettings; - FDragOperations : TCefDragOperations; - FDragDropManager : TCEFDragAndDropMgr; - FDropTargetCtrl : TWinControl; - FDragAndDropInitialized : boolean; - - // ICefClient - FOnProcessMessageReceived : TOnProcessMessageReceived; - - // ICefLoadHandler - FOnLoadStart : TOnLoadStart; - FOnLoadEnd : TOnLoadEnd; - FOnLoadError : TOnLoadError; - FOnLoadingStateChange : TOnLoadingStateChange; - - // ICefFocusHandler - FOnTakeFocus : TOnTakeFocus; - FOnSetFocus : TOnSetFocus; - FOnGotFocus : TOnGotFocus; - - // ICefContextMenuHandler - FOnBeforeContextMenu : TOnBeforeContextMenu; - FOnContextMenuCommand : TOnContextMenuCommand; - FOnContextMenuDismissed : TOnContextMenuDismissed; - - // ICefKeyboardHandler - FOnPreKeyEvent : TOnPreKeyEvent; - FOnKeyEvent : TOnKeyEvent; - - // ICefDisplayHandler - FOnAddressChange : TOnAddressChange; - FOnTitleChange : TOnTitleChange; - FOnFavIconUrlChange : TOnFavIconUrlChange; - FOnFullScreenModeChange : TOnFullScreenModeChange; - FOnTooltip : TOnTooltip; - FOnStatusMessage : TOnStatusMessage; - FOnConsoleMessage : TOnConsoleMessage; - - // ICefDownloadHandler - FOnBeforeDownload : TOnBeforeDownload; - FOnDownloadUpdated : TOnDownloadUpdated; - - // ICefGeolocationHandler - FOnRequestGeolocationPermission : TOnRequestGeolocationPermission; - FOnCancelGeolocationPermission : TOnCancelGeolocationPermission; - - // ICefJsDialogHandler - FOnJsdialog : TOnJsdialog; - FOnBeforeUnloadDialog : TOnBeforeUnloadDialog; - FOnResetDialogState : TOnResetDialogState; - FOnDialogClosed : TOnDialogClosed; - - // ICefLifeSpanHandler - FOnBeforePopup : TOnBeforePopup; - FOnAfterCreated : TOnAfterCreated; - FOnBeforeClose : TOnBeforeClose; - FOnClose : TOnClose; - - // ICefRequestHandler - FOnBeforeBrowse : TOnBeforeBrowse; - FOnOpenUrlFromTab : TOnOpenUrlFromTab; - FOnBeforeResourceLoad : TOnBeforeResourceLoad; - FOnGetResourceHandler : TOnGetResourceHandler; - FOnResourceRedirect : TOnResourceRedirect; - FOnResourceResponse : TOnResourceResponse; - FOnGetResourceResponseFilter : TOnGetResourceResponseFilter; - FOnResourceLoadComplete : TOnResourceLoadComplete; - FOnGetAuthCredentials : TOnGetAuthCredentials; - FOnQuotaRequest : TOnQuotaRequest; - FOnProtocolExecution : TOnProtocolExecution; - FOnCertificateError : TOnCertificateError; - FOnSelectClientCertificate : TOnSelectClientCertificate; - FOnPluginCrashed : TOnPluginCrashed; - FOnRenderViewReady : TOnRenderViewReady; - FOnRenderProcessTerminated : TOnRenderProcessTerminated; - - // ICefDialogHandler - FOnFileDialog : TOnFileDialog; - - // ICefRenderHandler - FOnGetAccessibilityHandler : TOnGetAccessibilityHandler; - FOnGetRootScreenRect : TOnGetRootScreenRect; - FOnGetViewRect : TOnGetViewRect; - FOnGetScreenPoint : TOnGetScreenPoint; - FOnGetScreenInfo : TOnGetScreenInfo; - FOnPopupShow : TOnPopupShow; - FOnPopupSize : TOnPopupSize; - FOnPaint : TOnPaint; - FOnCursorChange : TOnCursorChange; - FOnStartDragging : TOnStartDragging; - FOnUpdateDragCursor : TOnUpdateDragCursor; - FOnScrollOffsetChanged : TOnScrollOffsetChanged; - FOnIMECompositionRangeChanged : TOnIMECompositionRangeChanged; - - // ICefDragHandler - FOnDragEnter : TOnDragEnter; - FOnDraggableRegionsChanged : TOnDraggableRegionsChanged; - - // ICefFindHandler - FOnFindResult : TOnFindResult; - - // Custom - FOnTextResultAvailable : TOnTextResultAvailableEvent; - FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; - FOnPrefsAvailable : TNotifyEvent; - FOnCookiesDeleted : TOnCookiesDeletedEvent; - - function GetIsLoading : boolean; - function GetMultithreadApp : boolean; - function GetHasDocument : boolean; - function GetHasView : boolean; - function GetHasDevTools : boolean; - function GetHasClientHandler : boolean; - function GetHasBrowser : boolean; - function GetCanGoBack : boolean; - function GetCanGoForward : boolean; - function GetDocumentURL : string; - function GetZoomLevel : double; - function GetZoomPct : double; - function GetIsPopUp : boolean; - function GetWindowHandle : THandle; - function GetWindowlessFrameRate : integer; - function GetFrameIsFocused : boolean; - function GetInitialized : boolean; - function GetVisibleNavigationEntry : ICefNavigationEntry; - function GetHasValidMainFrame : boolean; - - procedure SetDoNotTrack(aValue : boolean); - procedure SetSendReferrer(aValue : boolean); - procedure SetHyperlinkAuditing(aValue : boolean); - procedure SetCookiePrefs(aValue : integer); - procedure SetImagesPrefs(aValue : integer); - procedure SetProxyType(aValue : integer); - procedure SetProxyServer(const aValue : string); - procedure SetProxyPort(aValue : integer); - procedure SetProxyUsername(const aValue : string); - procedure SetProxyPassword(const aValue : string); - procedure SetProxyScriptURL(const aValue : string); - procedure SetProxyByPassList(const aValue : string); - procedure SetCustomHeaderName(const aValue : string); - procedure SetCustomHeaderValue(const aValue : string); - procedure SetCMStoragePath(const aValue : ustring); - procedure SetZoomLevel(const aValue : double); - procedure SetZoomPct(const aValue : double); - procedure SetZoomStep(aValue : byte); - procedure SetWindowlessFrameRate(aValue : integer); - - - function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): Boolean; - function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): ICefBrowser; - - procedure InitializeEvents; - procedure InitializeSettings(var aSettings : TCefBrowserSettings); - - procedure GetSettings(var aSettings : TCefBrowserSettings); - procedure GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : string); - - function UpdateProxyPrefs : boolean; - function UpdatePreference(const aName : string; aValue : boolean) : boolean; overload; - function UpdatePreference(const aName : string; aValue : integer) : boolean; overload; - function UpdatePreference(const aName : string; const aValue : double) : boolean; overload; - function UpdatePreference(const aName, aValue : string) : boolean; overload; - - procedure HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); - procedure HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - - procedure PrefsAvailableMsg(var aMessage : TMessage); - function GetParentForm : TCustomForm; - procedure ApplyZoomStep; - procedure DelayedDragging; - function SendCompMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean; - procedure ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); - procedure WndProc(var aMessage: TMessage); - - procedure DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 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 © 2017 Salvador Díaz 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 uCEFChromium; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + WinApi.Windows, WinApi.Messages, System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, WinApi.ActiveX, + {$ELSE} + Windows, Messages, Classes, Controls, Graphics, Forms, ActiveX, + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient, + uCEFPDFPrintCallback, uCEFStringVisitor, uCEFConstants, uCEFTask, + uCEFDeleteCookiesCallback, uCEFDomVisitor, uCEFChromiumEvents, + uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions, + uCEFDragAndDropMgr; + +type + TChromium = class(TComponent, IChromiumEvents) + protected + FCompHandle : HWND; + FVisitor : ICefStringVisitor; + FPDFPrintcb : ICefPdfPrintCallback; + FCookiDeletercb : ICefDeleteCookiesCallback; + FHandler : ICefClient; + FBrowser : ICefBrowser; + FBrowserId : Integer; + FDefaultUrl : ustring; + FOptions : TChromiumOptions; + FFontOptions : TChromiumFontOptions; + FPDFPrintOptions : TPDFPrintOptions; + FDefaultEncoding : ustring; + FProxyType : integer; + FProxyServer : string; + FProxyPort : integer; + FProxyUsername : string; + FProxyPassword : string; + FProxyScriptURL : string; + FProxyByPassList : string; + FUpdatePreferences : boolean; + FCustomHeaderName : string; + FCustomHeaderValue : string; + FAddCustomHeader : boolean; + FDoNotTrack : boolean; + FSendReferrer : boolean; + FHyperlinkAuditing : boolean; + FCookiePrefs : integer; + FImagesPrefs : integer; + FCMStoragePath : ustring; + FZoomStep : byte; + FWindowName : string; + FPrefsFileName : string; + FIsOSR : boolean; + FInitialized : boolean; + FClosing : boolean; + FWindowInfo : TCefWindowInfo; + FBrowserSettings : TCefBrowserSettings; + FDevWindowInfo : TCefWindowInfo; + FDevBrowserSettings : TCefBrowserSettings; + FDragOperations : TCefDragOperations; + FDragDropManager : TCEFDragAndDropMgr; + FDropTargetCtrl : TWinControl; + FDragAndDropInitialized : boolean; + + // ICefClient + FOnProcessMessageReceived : TOnProcessMessageReceived; + + // ICefLoadHandler + FOnLoadStart : TOnLoadStart; + FOnLoadEnd : TOnLoadEnd; + FOnLoadError : TOnLoadError; + FOnLoadingStateChange : TOnLoadingStateChange; + + // ICefFocusHandler + FOnTakeFocus : TOnTakeFocus; + FOnSetFocus : TOnSetFocus; + FOnGotFocus : TOnGotFocus; + + // ICefContextMenuHandler + FOnBeforeContextMenu : TOnBeforeContextMenu; + FOnContextMenuCommand : TOnContextMenuCommand; + FOnContextMenuDismissed : TOnContextMenuDismissed; + + // ICefKeyboardHandler + FOnPreKeyEvent : TOnPreKeyEvent; + FOnKeyEvent : TOnKeyEvent; + + // ICefDisplayHandler + FOnAddressChange : TOnAddressChange; + FOnTitleChange : TOnTitleChange; + FOnFavIconUrlChange : TOnFavIconUrlChange; + FOnFullScreenModeChange : TOnFullScreenModeChange; + FOnTooltip : TOnTooltip; + FOnStatusMessage : TOnStatusMessage; + FOnConsoleMessage : TOnConsoleMessage; + + // ICefDownloadHandler + FOnBeforeDownload : TOnBeforeDownload; + FOnDownloadUpdated : TOnDownloadUpdated; + + // ICefGeolocationHandler + FOnRequestGeolocationPermission : TOnRequestGeolocationPermission; + FOnCancelGeolocationPermission : TOnCancelGeolocationPermission; + + // ICefJsDialogHandler + FOnJsdialog : TOnJsdialog; + FOnBeforeUnloadDialog : TOnBeforeUnloadDialog; + FOnResetDialogState : TOnResetDialogState; + FOnDialogClosed : TOnDialogClosed; + + // ICefLifeSpanHandler + FOnBeforePopup : TOnBeforePopup; + FOnAfterCreated : TOnAfterCreated; + FOnBeforeClose : TOnBeforeClose; + FOnClose : TOnClose; + + // ICefRequestHandler + FOnBeforeBrowse : TOnBeforeBrowse; + FOnOpenUrlFromTab : TOnOpenUrlFromTab; + FOnBeforeResourceLoad : TOnBeforeResourceLoad; + FOnGetResourceHandler : TOnGetResourceHandler; + FOnResourceRedirect : TOnResourceRedirect; + FOnResourceResponse : TOnResourceResponse; + FOnGetResourceResponseFilter : TOnGetResourceResponseFilter; + FOnResourceLoadComplete : TOnResourceLoadComplete; + FOnGetAuthCredentials : TOnGetAuthCredentials; + FOnQuotaRequest : TOnQuotaRequest; + FOnProtocolExecution : TOnProtocolExecution; + FOnCertificateError : TOnCertificateError; + FOnSelectClientCertificate : TOnSelectClientCertificate; + FOnPluginCrashed : TOnPluginCrashed; + FOnRenderViewReady : TOnRenderViewReady; + FOnRenderProcessTerminated : TOnRenderProcessTerminated; + + // ICefDialogHandler + FOnFileDialog : TOnFileDialog; + + // ICefRenderHandler + FOnGetAccessibilityHandler : TOnGetAccessibilityHandler; + FOnGetRootScreenRect : TOnGetRootScreenRect; + FOnGetViewRect : TOnGetViewRect; + FOnGetScreenPoint : TOnGetScreenPoint; + FOnGetScreenInfo : TOnGetScreenInfo; + FOnPopupShow : TOnPopupShow; + FOnPopupSize : TOnPopupSize; + FOnPaint : TOnPaint; + FOnCursorChange : TOnCursorChange; + FOnStartDragging : TOnStartDragging; + FOnUpdateDragCursor : TOnUpdateDragCursor; + FOnScrollOffsetChanged : TOnScrollOffsetChanged; + FOnIMECompositionRangeChanged : TOnIMECompositionRangeChanged; + + // ICefDragHandler + FOnDragEnter : TOnDragEnter; + FOnDraggableRegionsChanged : TOnDraggableRegionsChanged; + + // ICefFindHandler + FOnFindResult : TOnFindResult; + + // Custom + FOnTextResultAvailable : TOnTextResultAvailableEvent; + FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; + FOnPrefsAvailable : TNotifyEvent; + FOnCookiesDeleted : TOnCookiesDeletedEvent; + + function GetIsLoading : boolean; + function GetMultithreadApp : boolean; + function GetHasDocument : boolean; + function GetHasView : boolean; + function GetHasDevTools : boolean; + function GetHasClientHandler : boolean; + function GetHasBrowser : boolean; + function GetCanGoBack : boolean; + function GetCanGoForward : boolean; + function GetDocumentURL : string; + function GetZoomLevel : double; + function GetZoomPct : double; + function GetIsPopUp : boolean; + function GetWindowHandle : THandle; + function GetWindowlessFrameRate : integer; + function GetFrameIsFocused : boolean; + function GetInitialized : boolean; + function GetVisibleNavigationEntry : ICefNavigationEntry; + function GetHasValidMainFrame : boolean; + + procedure SetDoNotTrack(aValue : boolean); + procedure SetSendReferrer(aValue : boolean); + procedure SetHyperlinkAuditing(aValue : boolean); + procedure SetCookiePrefs(aValue : integer); + procedure SetImagesPrefs(aValue : integer); + procedure SetProxyType(aValue : integer); + procedure SetProxyServer(const aValue : string); + procedure SetProxyPort(aValue : integer); + procedure SetProxyUsername(const aValue : string); + procedure SetProxyPassword(const aValue : string); + procedure SetProxyScriptURL(const aValue : string); + procedure SetProxyByPassList(const aValue : string); + procedure SetCustomHeaderName(const aValue : string); + procedure SetCustomHeaderValue(const aValue : string); + procedure SetCMStoragePath(const aValue : ustring); + procedure SetZoomLevel(const aValue : double); + procedure SetZoomPct(const aValue : double); + procedure SetZoomStep(aValue : byte); + procedure SetWindowlessFrameRate(aValue : integer); + + + function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): Boolean; + function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): ICefBrowser; + + procedure InitializeEvents; + procedure InitializeSettings(var aSettings : TCefBrowserSettings); + + procedure GetSettings(var aSettings : TCefBrowserSettings); + procedure GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : string); + + function UpdateProxyPrefs : boolean; + function UpdatePreference(const aName : string; aValue : boolean) : boolean; overload; + function UpdatePreference(const aName : string; aValue : integer) : boolean; overload; + function UpdatePreference(const aName : string; const aValue : double) : boolean; overload; + function UpdatePreference(const aName, aValue : string) : boolean; overload; + + procedure HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); + procedure HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + procedure HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + + procedure PrefsAvailableMsg(var aMessage : TMessage); + function GetParentForm : TCustomForm; + procedure ApplyZoomStep; + procedure DelayedDragging; + function SendCompMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean; + procedure ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); + procedure WndProc(var aMessage: TMessage); + + procedure DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); procedure DragDropManager_OnDragOver(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); procedure DragDropManager_OnDragLeave(Sender: TObject); - procedure DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); - - // ICefClient - function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; - - // ICefLoadHandler - procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); virtual; - procedure doOnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); virtual; - procedure doOnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); virtual; - procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual; - - // ICefFocusHandler - procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); virtual; - function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; virtual; - procedure doOnGotFocus(const browser: ICefBrowser); virtual; - - // ICefContextMenuHandler - procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); virtual; - function doOnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: TCefEventFlags): Boolean; virtual; - procedure doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); virtual; - - // ICefKeyboardHandler - function doOnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; virtual; - function doOnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; virtual; - - // ICefDisplayHandler - procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual; - procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); virtual; - procedure doOnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); virtual; - procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual; - function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual; - procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual; - function doOnConsoleMessage(const browser: ICefBrowser; const aMessage, source: ustring; line: Integer): Boolean; virtual; - - // ICefDownloadHandler - 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; - - // ICefGeolocationHandler - function doOnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; virtual; - procedure doOnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); virtual; - - // ICefJsDialogHandler - function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; virtual; - function doOnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; virtual; - procedure doOnResetDialogState(const browser: ICefBrowser); virtual; - procedure doOnDialogClosed(const browser: ICefBrowser); virtual; - - // ICefLifeSpanHandler - function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; virtual; - procedure doOnAfterCreated(const browser: ICefBrowser); virtual; - procedure doOnBeforeClose(const browser: ICefBrowser); virtual; - function doOnClose(const browser: ICefBrowser): Boolean; virtual; - - // ICefRequestHandler - function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean): Boolean; virtual; - function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; - function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; - function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; virtual; - procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; - function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; - function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; virtual; - procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); virtual; - function doOnGetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; - function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual; - procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); virtual; - function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; - function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; - procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; - procedure doOnRenderViewReady(const browser: ICefBrowser); virtual; - procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; - - // ICefDialogHandler - function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; virtual; - - // ICefRenderHandler - procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); virtual; - function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; virtual; - function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; virtual; - procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); virtual; - procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual; - procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; - procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); virtual; - function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; - procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; - procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; - procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; - - // ICefDragHandler - function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; - procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); virtual; - - // ICefFindHandler - procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; - - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure AfterConstruction; override; - function CreateClientHandler(aIsOSR : boolean) : boolean; overload; - function CreateClientHandler(var aClient : ICefClient) : boolean; overload; - procedure CloseBrowser(aForceClose : boolean); - function CreateBrowser(const aBrowserParent : TWinControl = nil; const aWindowName : string = '') : boolean; overload; - function CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : string = '') : boolean; overload; - procedure InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); - procedure ShutdownDragAndDrop; - - // Internal procedures. - // Only tasks, visitors or callbacks should use them in the right thread/process. - procedure Internal_CookiesDeleted(numDeleted : integer); - procedure Internal_GetHTML; - procedure Internal_PdfPrintFinished(aResultOK : boolean); - procedure Internal_TextResultAvailable(const aText : string); - procedure Internal_UpdatePreferences; - procedure Internal_SavePreferences; - - procedure LoadURL(const aURL : ustring); - procedure LoadString(const aString : ustring; const aURL : ustring = ''); - procedure LoadRequest(const aRequest: ICefRequest); - - procedure GoBack; - procedure GoForward; - procedure Reload; - procedure ReloadIgnoreCache; - procedure StopLoad; - procedure StartDownload(const aURL : ustring); - - procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer); - procedure DeleteCookies; - procedure RetrieveHTML; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; aStartLine : integer = 0); - procedure UpdatePreferences; - procedure SavePreferences(const aFileName : string); - function SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; - - procedure ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); - procedure CloseDevTools(const aDevTools : TWinControl = nil); - - procedure Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); - procedure StopFinding(aClearSelection : Boolean); - - procedure Print; - procedure PrintToPDF(const aFilePath, aTitle, aURL : ustring); - - procedure ClipboardCopy; - procedure ClipboardPaste; - procedure ClipboardCut; - procedure ClipboardUndo; - procedure ClipboardRedo; - procedure ClipboardDel; - procedure SelectAll; - - procedure IncZoomStep; - procedure DecZoomStep; - procedure ResetZoomStep; - - procedure MoveFormTo(const x, y: Integer); - procedure MoveFormBy(const x, y: Integer); - procedure ResizeFormWidthTo(const x : Integer); - procedure ResizeFormHeightTo(const y : Integer); - procedure SetFormLeftTo(const x : Integer); - procedure SetFormTopTo(const y : Integer); - - procedure WasResized; - procedure WasHidden(hidden: Boolean); - procedure NotifyScreenInfoChanged; - procedure NotifyMoveOrResizeStarted; - procedure Invalidate(kind: TCefPaintElementType); - procedure SendKeyEvent(const event: PCefKeyEvent); - procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); - procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); - procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); - procedure SendFocusEvent(setFocus: Boolean); - procedure SendCaptureLostEvent; - function SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; - procedure SetFocus(focus: Boolean); - procedure SetAccessibilityState(accessibilityState: TCefState); - - procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); - procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); - procedure DragTargetDragLeave; - procedure DragTargetDrop(event: PCefMouseEvent); - procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); - procedure DragSourceSystemDragEnded; - - - property DefaultUrl : ustring read FDefaultUrl write FDefaultUrl; - property Options : TChromiumOptions read FOptions write FOptions; - property FontOptions : TChromiumFontOptions read FFontOptions write FFontOptions; - property PDFPrintOptions : TPDFPrintOptions read FPDFPrintOptions write FPDFPrintOptions; - property DefaultEncoding : ustring read FDefaultEncoding write FDefaultEncoding; - property BrowserId : integer read FBrowserId; - property Browser : ICefBrowser read FBrowser; - property CefClient : ICefClient read FHandler; - property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; - property MultithreadApp : boolean read GetMultithreadApp; - property IsLoading : boolean read GetIsLoading; - property HasDocument : boolean read GetHasDocument; - property HasView : boolean read GetHasView; - property HasDevTools : boolean read GetHasDevTools; - property HasClientHandler : boolean read GetHasClientHandler; - property HasBrowser : boolean read GetHasBrowser; - property CanGoBack : boolean read GetCanGoBack; - property CanGoForward : boolean read GetCanGoForward; - property IsPopUp : boolean read GetIsPopUp; - property WindowHandle : THandle read GetWindowHandle; - property FrameIsFocused : boolean read GetFrameIsFocused; - property Initialized : boolean read GetInitialized; - property CookiePrefs : integer read FCookiePrefs write SetCookiePrefs; - property ImagesPrefs : integer read FImagesPrefs write SetImagesPrefs; - property CMStoragePath : ustring read FCMStoragePath write SetCMStoragePath; - property DocumentURL : string read GetDocumentURL; - property WindowName : string read FWindowName write FWindowName; - property ZoomLevel : double read GetZoomLevel write SetZoomLevel; - property ZoomPct : double read GetZoomPct write SetZoomPct; - property ZoomStep : byte read FZoomStep write SetZoomStep; - property WindowlessFrameRate : integer read GetWindowlessFrameRate write SetWindowlessFrameRate; - property CustomHeaderName : string read FCustomHeaderName write SetCustomHeaderName; - property CustomHeaderValue : string read FCustomHeaderValue write SetCustomHeaderValue; - property DoNotTrack : boolean read FDoNotTrack write SetDoNotTrack; - property SendReferrer : boolean read FSendReferrer write SetSendReferrer; - property HyperlinkAuditing : boolean read FHyperlinkAuditing write SetHyperlinkAuditing; - property HasValidMainFrame : boolean read GetHasValidMainFrame; - property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; - - property ProxyType : integer read FProxyType write SetProxyType; - property ProxyServer : string read FProxyServer write SetProxyServer; - property ProxyPort : integer read FProxyPort write SetProxyPort; - property ProxyUsername : string read FProxyUsername write SetProxyUsername; - property ProxyPassword : string read FProxyPassword write SetProxyPassword; - property ProxyScriptURL : string read FProxyScriptURL write SetProxyScriptURL; - property ProxyByPassList : string read FProxyByPassList write SetProxyByPassList; - - published - property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable; - property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished; - property OnPrefsAvailable : TNotifyEvent read FOnPrefsAvailable write FOnPrefsAvailable; - property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted; - - // ICefClient - property OnProcessMessageReceived : TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived; - - // ICefLoadHandler - property OnLoadStart : TOnLoadStart read FOnLoadStart write FOnLoadStart; - property OnLoadEnd : TOnLoadEnd read FOnLoadEnd write FOnLoadEnd; - property OnLoadError : TOnLoadError read FOnLoadError write FOnLoadError; - property OnLoadingStateChange : TOnLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange; - - // ICefFocusHandler - property OnTakeFocus : TOnTakeFocus read FOnTakeFocus write FOnTakeFocus; - property OnSetFocus : TOnSetFocus read FOnSetFocus write FOnSetFocus; - property OnGotFocus : TOnGotFocus read FOnGotFocus write FOnGotFocus; - - // ICefContextMenuHandler - property OnBeforeContextMenu : TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu; - property OnContextMenuCommand : TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand; - property OnContextMenuDismissed : TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed; - - // ICefKeyboardHandler - property OnPreKeyEvent : TOnPreKeyEvent read FOnPreKeyEvent write FOnPreKeyEvent; - property OnKeyEvent : TOnKeyEvent read FOnKeyEvent write FOnKeyEvent; - - // ICefDisplayHandler - property OnAddressChange : TOnAddressChange read FOnAddressChange write FOnAddressChange; - property OnTitleChange : TOnTitleChange read FOnTitleChange write FOnTitleChange; - property OnFavIconUrlChange : TOnFavIconUrlChange read FOnFavIconUrlChange write FOnFavIconUrlChange; - property OnFullScreenModeChange : TOnFullScreenModeChange read FOnFullScreenModeChange write FOnFullScreenModeChange; - property OnTooltip : TOnTooltip read FOnTooltip write FOnTooltip; - property OnStatusMessage : TOnStatusMessage read FOnStatusMessage write FOnStatusMessage; - property OnConsoleMessage : TOnConsoleMessage read FOnConsoleMessage write FOnConsoleMessage; - - // ICefDownloadHandler - property OnBeforeDownload : TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload; - property OnDownloadUpdated : TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated; - - // ICefGeolocationHandler - property OnRequestGeolocationPermission : TOnRequestGeolocationPermission read FOnRequestGeolocationPermission write FOnRequestGeolocationPermission; - property OnCancelGeolocationPermission : TOnCancelGeolocationPermission read FOnCancelGeolocationPermission write FOnCancelGeolocationPermission; - - // ICefJsDialogHandler - property OnJsdialog : TOnJsdialog read FOnJsdialog write FOnJsdialog; - property OnBeforeUnloadDialog : TOnBeforeUnloadDialog read FOnBeforeUnloadDialog write FOnBeforeUnloadDialog; - property OnResetDialogState : TOnResetDialogState read FOnResetDialogState write FOnResetDialogState; - property OnDialogClosed : TOnDialogClosed read FOnDialogClosed write FOnDialogClosed; - - // ICefLifeSpanHandler - property OnBeforePopup : TOnBeforePopup read FOnBeforePopup write FOnBeforePopup; - property OnAfterCreated : TOnAfterCreated read FOnAfterCreated write FOnAfterCreated; - property OnBeforeClose : TOnBeforeClose read FOnBeforeClose write FOnBeforeClose; - property OnClose : TOnClose read FOnClose write FOnClose; - - // ICefRequestHandler - property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse; - property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab; - property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad; - property OnGetResourceHandler : TOnGetResourceHandler read FOnGetResourceHandler write FOnGetResourceHandler; - property OnResourceRedirect : TOnResourceRedirect read FOnResourceRedirect write FOnResourceRedirect; - property OnResourceResponse : TOnResourceResponse read FOnResourceResponse write FOnResourceResponse; - property OnGetResourceResponseFilter : TOnGetResourceResponseFilter read FOnGetResourceResponseFilter write FOnGetResourceResponseFilter; - property OnResourceLoadComplete : TOnResourceLoadComplete read FOnResourceLoadComplete write FOnResourceLoadComplete; - property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials; - property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest; - property OnProtocolExecution : TOnProtocolExecution read FOnProtocolExecution write FOnProtocolExecution; - property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError; - property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate; - property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed; - property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady; - property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated; - - // ICefDialogHandler - property OnFileDialog : TOnFileDialog read FOnFileDialog write FOnFileDialog; - - // ICefRenderHandler - property OnGetAccessibilityHandler : TOnGetAccessibilityHandler read FOnGetAccessibilityHandler write FOnGetAccessibilityHandler; - property OnGetRootScreenRect : TOnGetRootScreenRect read FOnGetRootScreenRect write FOnGetRootScreenRect; - property OnGetViewRect : TOnGetViewRect read FOnGetViewRect write FOnGetViewRect; - property OnGetScreenPoint : TOnGetScreenPoint read FOnGetScreenPoint write FOnGetScreenPoint; - property OnGetScreenInfo : TOnGetScreenInfo read FOnGetScreenInfo write FOnGetScreenInfo; - property OnPopupShow : TOnPopupShow read FOnPopupShow write FOnPopupShow; - property OnPopupSize : TOnPopupSize read FOnPopupSize write FOnPopupSize; - property OnPaint : TOnPaint read FOnPaint write FOnPaint; - property OnCursorChange : TOnCursorChange read FOnCursorChange write FOnCursorChange; - property OnStartDragging : TOnStartDragging read FOnStartDragging write FOnStartDragging; - property OnUpdateDragCursor : TOnUpdateDragCursor read FOnUpdateDragCursor write FOnUpdateDragCursor; - property OnScrollOffsetChanged : TOnScrollOffsetChanged read FOnScrollOffsetChanged write FOnScrollOffsetChanged; - property OnIMECompositionRangeChanged : TOnIMECompositionRangeChanged read FOnIMECompositionRangeChanged write FOnIMECompositionRangeChanged; - - // ICefDragHandler - property OnDragEnter : TOnDragEnter read FOnDragEnter write FOnDragEnter; - property OnDraggableRegionsChanged : TOnDraggableRegionsChanged read FOnDraggableRegionsChanged write FOnDraggableRegionsChanged; - - // ICefFindHandler - property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; - - end; - -implementation - -uses - {$IFDEF DELPHI16_UP} - System.SysUtils, System.Math, - {$ELSE} - SysUtils, Math, - {$ENDIF} - uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFCookieManager, uCEFFrame, - uCEFApplication, uCEFProcessMessage, uOLEDragAndDrop; - -constructor TChromium.Create(AOwner: TComponent); -begin - FBrowser := nil; - FBrowserId := 0; - FCompHandle := 0; - FClosing := False; - FInitialized := False; - FIsOSR := False; - FDefaultUrl := 'about:blank'; - FHandler := nil; - FOptions := nil; - FFontOptions := nil; - FDefaultEncoding := ''; - FVisitor := nil; - FPDFPrintcb := nil; - FCookiDeletercb := nil; - FPDFPrintOptions := nil; - FUpdatePreferences := False; - FCustomHeaderName := ''; - FCustomHeaderValue := ''; - FPrefsFileName := ''; - FAddCustomHeader := False; - FDoNotTrack := True; - FSendReferrer := True; - FHyperlinkAuditing := False; - FCookiePrefs := CEF_CONTENT_SETTING_ALLOW; - FImagesPrefs := CEF_CONTENT_SETTING_ALLOW; - FZoomStep := ZOOM_STEP_DEF; - FWindowName := ''; - FDragOperations := DRAG_OPERATION_NONE; - FDragDropManager := nil; - FDropTargetCtrl := nil; - FDragAndDropInitialized := False; - - FProxyType := CEF_PROXYTYPE_DIRECT; - FProxyServer := ''; - FProxyPort := 80; - FProxyUsername := ''; - FProxyPassword := ''; - FProxyScriptURL := ''; - FProxyByPassList := ''; - - FillChar(FWindowInfo, SizeOf(TCefWindowInfo), 0); - FillChar(FDevWindowInfo, SizeOf(TCefWindowInfo), 0); - - InitializeSettings(FBrowserSettings); - InitializeSettings(FDevBrowserSettings); - - InitializeEvents; - - inherited Create(AOwner); -end; - -destructor TChromium.Destroy; -begin - try - try - if (FDragDropManager <> nil) then FreeAndNil(FDragDropManager); - - if (FCompHandle <> 0) then - begin - DeallocateHWnd(FCompHandle); - FCompHandle := 0; - end; - - FBrowser := nil; - FBrowserId := 0; - FHandler := nil; - FVisitor := nil; - FPDFPrintcb := nil; - FCookiDeletercb := nil; - - if (FFontOptions <> nil) then FreeAndNil(FFontOptions); - if (FOptions <> nil) then FreeAndNil(FOptions); - if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions); - except - on e : exception do - if CustomExceptionHandler('TChromium.Destroy', e) then raise; - end; - finally - inherited Destroy; - end; -end; - -procedure TChromium.AfterConstruction; -begin - inherited AfterConstruction; - - try - if not(csDesigning in ComponentState) then - begin - FCompHandle := AllocateHWnd(WndProc); - FOptions := TChromiumOptions.Create; - FFontOptions := TChromiumFontOptions.Create; - FPDFPrintOptions := TPDFPrintOptions.Create; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.AfterConstruction', e) then raise; - end; -end; - -function TChromium.CreateClientHandler(aIsOSR : boolean) : boolean; -begin - Result := False; - - try - if (FHandler = nil) then - begin - FIsOSR := aIsOsr; - FHandler := TVCLClientHandler.Create(Self, FIsOSR); - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.CreateClientHandler', e) then raise; - end; -end; - -function TChromium.CreateClientHandler(var aClient : ICefClient) : boolean; -begin - if CreateClientHandler(True) then - begin - aClient := FHandler; - Result := True; - end - else - Result := False; -end; - -procedure TChromium.InitializeEvents; -begin - // ICefClient - FOnProcessMessageReceived := nil; - - // ICefLoadHandler - FOnLoadStart := nil; - FOnLoadEnd := nil; - FOnLoadError := nil; - FOnLoadingStateChange := nil; - - // ICefFocusHandler - FOnTakeFocus := nil; - FOnSetFocus := nil; - FOnGotFocus := nil; - - // ICefContextMenuHandler - FOnBeforeContextMenu := nil; - FOnContextMenuCommand := nil; - FOnContextMenuDismissed := nil; - - // ICefKeyboardHandler - FOnPreKeyEvent := nil; - FOnKeyEvent := nil; - - // ICefDisplayHandler - FOnAddressChange := nil; - FOnTitleChange := nil; - FOnFavIconUrlChange := nil; - FOnFullScreenModeChange := nil; - FOnTooltip := nil; - FOnStatusMessage := nil; - FOnConsoleMessage := nil; - - // ICefDownloadHandler - FOnBeforeDownload := nil; - FOnDownloadUpdated := nil; - - // ICefGeolocationHandler - FOnRequestGeolocationPermission := nil; - FOnCancelGeolocationPermission := nil; - - // ICefJsDialogHandler - FOnJsdialog := nil; - FOnBeforeUnloadDialog := nil; - FOnResetDialogState := nil; - FOnDialogClosed := nil; - - // ICefLifeSpanHandler - FOnBeforePopup := nil; - FOnAfterCreated := nil; - FOnBeforeClose := nil; - FOnClose := nil; - - // ICefRequestHandler - FOnBeforeBrowse := nil; - FOnOpenUrlFromTab := nil; - FOnBeforeResourceLoad := nil; - FOnGetResourceHandler := nil; - FOnResourceRedirect := nil; - FOnResourceResponse := nil; - FOnGetResourceResponseFilter := nil; - FOnResourceLoadComplete := nil; - FOnGetAuthCredentials := nil; - FOnQuotaRequest := nil; - FOnProtocolExecution := nil; - FOnCertificateError := nil; - FOnSelectClientCertificate := nil; - FOnPluginCrashed := nil; - FOnRenderViewReady := nil; - FOnRenderProcessTerminated := nil; - - // ICefDialogHandler - FOnFileDialog := nil; - - // ICefRenderHandler - FOnGetAccessibilityHandler := nil; - FOnGetRootScreenRect := nil; - FOnGetViewRect := nil; - FOnGetScreenPoint := nil; - FOnGetScreenInfo := nil; - FOnPopupShow := nil; - FOnPopupSize := nil; - FOnPaint := nil; - FOnCursorChange := nil; - FOnStartDragging := nil; - FOnUpdateDragCursor := nil; - FOnScrollOffsetChanged := nil; - FOnIMECompositionRangeChanged := nil; - - // ICefDragHandler - FOnDragEnter := nil; - FOnDraggableRegionsChanged := nil; - - // ICefFindHandler - FOnFindResult := nil; - - // Custom - FOnTextResultAvailable := nil; - FOnPdfPrintFinished := nil; - FOnPrefsAvailable := nil; - FOnCookiesDeleted := nil; -end; - -function TChromium.CreateBrowser(const aBrowserParent : TWinControl; const aWindowName : string) : boolean; -var - TempHandle : HWND; - TempRect : TRect; -begin - if (aBrowserParent <> nil) then - begin - TempHandle := aBrowserParent.Handle; - TempRect := aBrowserParent.ClientRect; - end - else - begin - TempHandle := 0; - TempRect := rect(0, 0, 0, 0); - end; - - Result := CreateBrowser(TempHandle, TempRect, aWindowName); -end; - -function TChromium.CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : string = '') : boolean; -begin - Result := False; - - try - if not(csDesigning in ComponentState) and - not(FClosing) and - (FBrowser = nil) and - (FBrowserId = 0) and - (GlobalCEFApp <> nil) and - CreateClientHandler(aParentHandle = 0) then - begin - GetSettings(FBrowserSettings); - - if FIsOSR then - WindowInfoAsWindowless(FWindowInfo, FCompHandle, aWindowName) - else - WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect, aWindowName); - - - if MultithreadApp then - Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, nil) - else - begin - FBrowser := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, nil); - - if (FBrowser <> nil) then - begin - FBrowserId := FBrowser.Identifier; - FInitialized := (FBrowserId <> 0); - Result := True; - end; - end; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.CreateBrowser', e) then raise; - end; -end; - -procedure TChromium.InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); -var - TempDropTarget : IDropTarget; -begin - if FIsOSR and - not(FDragAndDropInitialized) and - (FDragDropManager = nil) and - (aDropTargetCtrl <> nil) then - begin - FDropTargetCtrl := aDropTargetCtrl; - + procedure DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); + + // ICefClient + function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; + + // ICefLoadHandler + procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); virtual; + procedure doOnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); virtual; + procedure doOnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); virtual; + procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual; + + // ICefFocusHandler + procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); virtual; + function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; virtual; + procedure doOnGotFocus(const browser: ICefBrowser); virtual; + + // ICefContextMenuHandler + procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); virtual; + function doOnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: TCefEventFlags): Boolean; virtual; + procedure doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); virtual; + + // ICefKeyboardHandler + function doOnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; virtual; + function doOnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; virtual; + + // ICefDisplayHandler + procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual; + procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); virtual; + procedure doOnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); virtual; + procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual; + function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual; + procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual; + function doOnConsoleMessage(const browser: ICefBrowser; const aMessage, source: ustring; line: Integer): Boolean; virtual; + + // ICefDownloadHandler + 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; + + // ICefGeolocationHandler + function doOnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; virtual; + procedure doOnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); virtual; + + // ICefJsDialogHandler + function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; virtual; + function doOnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; virtual; + procedure doOnResetDialogState(const browser: ICefBrowser); virtual; + procedure doOnDialogClosed(const browser: ICefBrowser); virtual; + + // ICefLifeSpanHandler + function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; virtual; + procedure doOnAfterCreated(const browser: ICefBrowser); virtual; + procedure doOnBeforeClose(const browser: ICefBrowser); virtual; + function doOnClose(const browser: ICefBrowser): Boolean; virtual; + + // ICefRequestHandler + function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean): Boolean; virtual; + function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; + function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; + function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; virtual; + procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; + function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; + function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; virtual; + procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); virtual; + function doOnGetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; + function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual; + procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); virtual; + function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; + function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; + procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; + procedure doOnRenderViewReady(const browser: ICefBrowser); virtual; + procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; + + // ICefDialogHandler + function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; virtual; + + // ICefRenderHandler + procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); virtual; + function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; + function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; + function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; virtual; + function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; virtual; + procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); virtual; + procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual; + procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; + procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); virtual; + function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; + procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; + procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; + procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; + + // ICefDragHandler + function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; + procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); virtual; + + // ICefFindHandler + procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure AfterConstruction; override; + function CreateClientHandler(aIsOSR : boolean) : boolean; overload; + function CreateClientHandler(var aClient : ICefClient) : boolean; overload; + procedure CloseBrowser(aForceClose : boolean); + function CreateBrowser(const aBrowserParent : TWinControl = nil; const aWindowName : string = '') : boolean; overload; + function CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : string = '') : boolean; overload; + procedure InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); + procedure ShutdownDragAndDrop; + + // Internal procedures. + // Only tasks, visitors or callbacks should use them in the right thread/process. + procedure Internal_CookiesDeleted(numDeleted : integer); + procedure Internal_GetHTML; + procedure Internal_PdfPrintFinished(aResultOK : boolean); + procedure Internal_TextResultAvailable(const aText : string); + procedure Internal_UpdatePreferences; + procedure Internal_SavePreferences; + + procedure LoadURL(const aURL : ustring); + procedure LoadString(const aString : ustring; const aURL : ustring = ''); + procedure LoadRequest(const aRequest: ICefRequest); + + procedure GoBack; + procedure GoForward; + procedure Reload; + procedure ReloadIgnoreCache; + procedure StopLoad; + procedure StartDownload(const aURL : ustring); + + procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer); + procedure DeleteCookies; + procedure RetrieveHTML; + procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; aStartLine : integer = 0); + procedure UpdatePreferences; + procedure SavePreferences(const aFileName : string); + function SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; + + procedure ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); + procedure CloseDevTools(const aDevTools : TWinControl = nil); + + procedure Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); + procedure StopFinding(aClearSelection : Boolean); + + procedure Print; + procedure PrintToPDF(const aFilePath, aTitle, aURL : ustring); + + procedure ClipboardCopy; + procedure ClipboardPaste; + procedure ClipboardCut; + procedure ClipboardUndo; + procedure ClipboardRedo; + procedure ClipboardDel; + procedure SelectAll; + + procedure IncZoomStep; + procedure DecZoomStep; + procedure ResetZoomStep; + + procedure MoveFormTo(const x, y: Integer); + procedure MoveFormBy(const x, y: Integer); + procedure ResizeFormWidthTo(const x : Integer); + procedure ResizeFormHeightTo(const y : Integer); + procedure SetFormLeftTo(const x : Integer); + procedure SetFormTopTo(const y : Integer); + + procedure WasResized; + procedure WasHidden(hidden: Boolean); + procedure NotifyScreenInfoChanged; + procedure NotifyMoveOrResizeStarted; + procedure Invalidate(kind: TCefPaintElementType); + procedure SendKeyEvent(const event: PCefKeyEvent); + procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); + procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); + procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); + procedure SendFocusEvent(setFocus: Boolean); + procedure SendCaptureLostEvent; + function SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; + procedure SetFocus(focus: Boolean); + procedure SetAccessibilityState(accessibilityState: TCefState); + + procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); + procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); + procedure DragTargetDragLeave; + procedure DragTargetDrop(event: PCefMouseEvent); + procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); + procedure DragSourceSystemDragEnded; + + + property DefaultUrl : ustring read FDefaultUrl write FDefaultUrl; + property Options : TChromiumOptions read FOptions write FOptions; + property FontOptions : TChromiumFontOptions read FFontOptions write FFontOptions; + property PDFPrintOptions : TPDFPrintOptions read FPDFPrintOptions write FPDFPrintOptions; + property DefaultEncoding : ustring read FDefaultEncoding write FDefaultEncoding; + property BrowserId : integer read FBrowserId; + property Browser : ICefBrowser read FBrowser; + property CefClient : ICefClient read FHandler; + property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; + property MultithreadApp : boolean read GetMultithreadApp; + property IsLoading : boolean read GetIsLoading; + property HasDocument : boolean read GetHasDocument; + property HasView : boolean read GetHasView; + property HasDevTools : boolean read GetHasDevTools; + property HasClientHandler : boolean read GetHasClientHandler; + property HasBrowser : boolean read GetHasBrowser; + property CanGoBack : boolean read GetCanGoBack; + property CanGoForward : boolean read GetCanGoForward; + property IsPopUp : boolean read GetIsPopUp; + property WindowHandle : THandle read GetWindowHandle; + property FrameIsFocused : boolean read GetFrameIsFocused; + property Initialized : boolean read GetInitialized; + property CookiePrefs : integer read FCookiePrefs write SetCookiePrefs; + property ImagesPrefs : integer read FImagesPrefs write SetImagesPrefs; + property CMStoragePath : ustring read FCMStoragePath write SetCMStoragePath; + property DocumentURL : string read GetDocumentURL; + property WindowName : string read FWindowName write FWindowName; + property ZoomLevel : double read GetZoomLevel write SetZoomLevel; + property ZoomPct : double read GetZoomPct write SetZoomPct; + property ZoomStep : byte read FZoomStep write SetZoomStep; + property WindowlessFrameRate : integer read GetWindowlessFrameRate write SetWindowlessFrameRate; + property CustomHeaderName : string read FCustomHeaderName write SetCustomHeaderName; + property CustomHeaderValue : string read FCustomHeaderValue write SetCustomHeaderValue; + property DoNotTrack : boolean read FDoNotTrack write SetDoNotTrack; + property SendReferrer : boolean read FSendReferrer write SetSendReferrer; + property HyperlinkAuditing : boolean read FHyperlinkAuditing write SetHyperlinkAuditing; + property HasValidMainFrame : boolean read GetHasValidMainFrame; + property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; + + property ProxyType : integer read FProxyType write SetProxyType; + property ProxyServer : string read FProxyServer write SetProxyServer; + property ProxyPort : integer read FProxyPort write SetProxyPort; + property ProxyUsername : string read FProxyUsername write SetProxyUsername; + property ProxyPassword : string read FProxyPassword write SetProxyPassword; + property ProxyScriptURL : string read FProxyScriptURL write SetProxyScriptURL; + property ProxyByPassList : string read FProxyByPassList write SetProxyByPassList; + + published + property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable; + property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished; + property OnPrefsAvailable : TNotifyEvent read FOnPrefsAvailable write FOnPrefsAvailable; + property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted; + + // ICefClient + property OnProcessMessageReceived : TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived; + + // ICefLoadHandler + property OnLoadStart : TOnLoadStart read FOnLoadStart write FOnLoadStart; + property OnLoadEnd : TOnLoadEnd read FOnLoadEnd write FOnLoadEnd; + property OnLoadError : TOnLoadError read FOnLoadError write FOnLoadError; + property OnLoadingStateChange : TOnLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange; + + // ICefFocusHandler + property OnTakeFocus : TOnTakeFocus read FOnTakeFocus write FOnTakeFocus; + property OnSetFocus : TOnSetFocus read FOnSetFocus write FOnSetFocus; + property OnGotFocus : TOnGotFocus read FOnGotFocus write FOnGotFocus; + + // ICefContextMenuHandler + property OnBeforeContextMenu : TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu; + property OnContextMenuCommand : TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand; + property OnContextMenuDismissed : TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed; + + // ICefKeyboardHandler + property OnPreKeyEvent : TOnPreKeyEvent read FOnPreKeyEvent write FOnPreKeyEvent; + property OnKeyEvent : TOnKeyEvent read FOnKeyEvent write FOnKeyEvent; + + // ICefDisplayHandler + property OnAddressChange : TOnAddressChange read FOnAddressChange write FOnAddressChange; + property OnTitleChange : TOnTitleChange read FOnTitleChange write FOnTitleChange; + property OnFavIconUrlChange : TOnFavIconUrlChange read FOnFavIconUrlChange write FOnFavIconUrlChange; + property OnFullScreenModeChange : TOnFullScreenModeChange read FOnFullScreenModeChange write FOnFullScreenModeChange; + property OnTooltip : TOnTooltip read FOnTooltip write FOnTooltip; + property OnStatusMessage : TOnStatusMessage read FOnStatusMessage write FOnStatusMessage; + property OnConsoleMessage : TOnConsoleMessage read FOnConsoleMessage write FOnConsoleMessage; + + // ICefDownloadHandler + property OnBeforeDownload : TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload; + property OnDownloadUpdated : TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated; + + // ICefGeolocationHandler + property OnRequestGeolocationPermission : TOnRequestGeolocationPermission read FOnRequestGeolocationPermission write FOnRequestGeolocationPermission; + property OnCancelGeolocationPermission : TOnCancelGeolocationPermission read FOnCancelGeolocationPermission write FOnCancelGeolocationPermission; + + // ICefJsDialogHandler + property OnJsdialog : TOnJsdialog read FOnJsdialog write FOnJsdialog; + property OnBeforeUnloadDialog : TOnBeforeUnloadDialog read FOnBeforeUnloadDialog write FOnBeforeUnloadDialog; + property OnResetDialogState : TOnResetDialogState read FOnResetDialogState write FOnResetDialogState; + property OnDialogClosed : TOnDialogClosed read FOnDialogClosed write FOnDialogClosed; + + // ICefLifeSpanHandler + property OnBeforePopup : TOnBeforePopup read FOnBeforePopup write FOnBeforePopup; + property OnAfterCreated : TOnAfterCreated read FOnAfterCreated write FOnAfterCreated; + property OnBeforeClose : TOnBeforeClose read FOnBeforeClose write FOnBeforeClose; + property OnClose : TOnClose read FOnClose write FOnClose; + + // ICefRequestHandler + property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse; + property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab; + property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad; + property OnGetResourceHandler : TOnGetResourceHandler read FOnGetResourceHandler write FOnGetResourceHandler; + property OnResourceRedirect : TOnResourceRedirect read FOnResourceRedirect write FOnResourceRedirect; + property OnResourceResponse : TOnResourceResponse read FOnResourceResponse write FOnResourceResponse; + property OnGetResourceResponseFilter : TOnGetResourceResponseFilter read FOnGetResourceResponseFilter write FOnGetResourceResponseFilter; + property OnResourceLoadComplete : TOnResourceLoadComplete read FOnResourceLoadComplete write FOnResourceLoadComplete; + property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials; + property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest; + property OnProtocolExecution : TOnProtocolExecution read FOnProtocolExecution write FOnProtocolExecution; + property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError; + property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate; + property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed; + property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady; + property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated; + + // ICefDialogHandler + property OnFileDialog : TOnFileDialog read FOnFileDialog write FOnFileDialog; + + // ICefRenderHandler + property OnGetAccessibilityHandler : TOnGetAccessibilityHandler read FOnGetAccessibilityHandler write FOnGetAccessibilityHandler; + property OnGetRootScreenRect : TOnGetRootScreenRect read FOnGetRootScreenRect write FOnGetRootScreenRect; + property OnGetViewRect : TOnGetViewRect read FOnGetViewRect write FOnGetViewRect; + property OnGetScreenPoint : TOnGetScreenPoint read FOnGetScreenPoint write FOnGetScreenPoint; + property OnGetScreenInfo : TOnGetScreenInfo read FOnGetScreenInfo write FOnGetScreenInfo; + property OnPopupShow : TOnPopupShow read FOnPopupShow write FOnPopupShow; + property OnPopupSize : TOnPopupSize read FOnPopupSize write FOnPopupSize; + property OnPaint : TOnPaint read FOnPaint write FOnPaint; + property OnCursorChange : TOnCursorChange read FOnCursorChange write FOnCursorChange; + property OnStartDragging : TOnStartDragging read FOnStartDragging write FOnStartDragging; + property OnUpdateDragCursor : TOnUpdateDragCursor read FOnUpdateDragCursor write FOnUpdateDragCursor; + property OnScrollOffsetChanged : TOnScrollOffsetChanged read FOnScrollOffsetChanged write FOnScrollOffsetChanged; + property OnIMECompositionRangeChanged : TOnIMECompositionRangeChanged read FOnIMECompositionRangeChanged write FOnIMECompositionRangeChanged; + + // ICefDragHandler + property OnDragEnter : TOnDragEnter read FOnDragEnter write FOnDragEnter; + property OnDraggableRegionsChanged : TOnDraggableRegionsChanged read FOnDraggableRegionsChanged write FOnDraggableRegionsChanged; + + // ICefFindHandler + property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; + + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, System.Math, + {$ELSE} + SysUtils, Math, + {$ENDIF} + uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFCookieManager, uCEFFrame, + uCEFApplication, uCEFProcessMessage, uOLEDragAndDrop; + +constructor TChromium.Create(AOwner: TComponent); +begin + FBrowser := nil; + FBrowserId := 0; + FCompHandle := 0; + FClosing := False; + FInitialized := False; + FIsOSR := False; + FDefaultUrl := 'about:blank'; + FHandler := nil; + FOptions := nil; + FFontOptions := nil; + FDefaultEncoding := ''; + FVisitor := nil; + FPDFPrintcb := nil; + FCookiDeletercb := nil; + FPDFPrintOptions := nil; + FUpdatePreferences := False; + FCustomHeaderName := ''; + FCustomHeaderValue := ''; + FPrefsFileName := ''; + FAddCustomHeader := False; + FDoNotTrack := True; + FSendReferrer := True; + FHyperlinkAuditing := False; + FCookiePrefs := CEF_CONTENT_SETTING_ALLOW; + FImagesPrefs := CEF_CONTENT_SETTING_ALLOW; + FZoomStep := ZOOM_STEP_DEF; + FWindowName := ''; + FDragOperations := DRAG_OPERATION_NONE; + FDragDropManager := nil; + FDropTargetCtrl := nil; + FDragAndDropInitialized := False; + + FProxyType := CEF_PROXYTYPE_DIRECT; + FProxyServer := ''; + FProxyPort := 80; + FProxyUsername := ''; + FProxyPassword := ''; + FProxyScriptURL := ''; + FProxyByPassList := ''; + + FillChar(FWindowInfo, SizeOf(TCefWindowInfo), 0); + FillChar(FDevWindowInfo, SizeOf(TCefWindowInfo), 0); + + InitializeSettings(FBrowserSettings); + InitializeSettings(FDevBrowserSettings); + + InitializeEvents; + + inherited Create(AOwner); +end; + +destructor TChromium.Destroy; +begin + try + try + if (FDragDropManager <> nil) then FreeAndNil(FDragDropManager); + + if (FCompHandle <> 0) then + begin + DeallocateHWnd(FCompHandle); + FCompHandle := 0; + end; + + FBrowser := nil; + FBrowserId := 0; + FHandler := nil; + FVisitor := nil; + FPDFPrintcb := nil; + FCookiDeletercb := nil; + + if (FFontOptions <> nil) then FreeAndNil(FFontOptions); + if (FOptions <> nil) then FreeAndNil(FOptions); + if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions); + except + on e : exception do + if CustomExceptionHandler('TChromium.Destroy', e) then raise; + end; + finally + inherited Destroy; + end; +end; + +procedure TChromium.AfterConstruction; +begin + inherited AfterConstruction; + + try + if not(csDesigning in ComponentState) then + begin + FCompHandle := AllocateHWnd(WndProc); + FOptions := TChromiumOptions.Create; + FFontOptions := TChromiumFontOptions.Create; + FPDFPrintOptions := TPDFPrintOptions.Create; + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.AfterConstruction', e) then raise; + end; +end; + +function TChromium.CreateClientHandler(aIsOSR : boolean) : boolean; +begin + Result := False; + + try + if (FHandler = nil) then + begin + FIsOSR := aIsOsr; + FHandler := TVCLClientHandler.Create(Self, FIsOSR); + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.CreateClientHandler', e) then raise; + end; +end; + +function TChromium.CreateClientHandler(var aClient : ICefClient) : boolean; +begin + if CreateClientHandler(True) then + begin + aClient := FHandler; + Result := True; + end + else + Result := False; +end; + +procedure TChromium.InitializeEvents; +begin + // ICefClient + FOnProcessMessageReceived := nil; + + // ICefLoadHandler + FOnLoadStart := nil; + FOnLoadEnd := nil; + FOnLoadError := nil; + FOnLoadingStateChange := nil; + + // ICefFocusHandler + FOnTakeFocus := nil; + FOnSetFocus := nil; + FOnGotFocus := nil; + + // ICefContextMenuHandler + FOnBeforeContextMenu := nil; + FOnContextMenuCommand := nil; + FOnContextMenuDismissed := nil; + + // ICefKeyboardHandler + FOnPreKeyEvent := nil; + FOnKeyEvent := nil; + + // ICefDisplayHandler + FOnAddressChange := nil; + FOnTitleChange := nil; + FOnFavIconUrlChange := nil; + FOnFullScreenModeChange := nil; + FOnTooltip := nil; + FOnStatusMessage := nil; + FOnConsoleMessage := nil; + + // ICefDownloadHandler + FOnBeforeDownload := nil; + FOnDownloadUpdated := nil; + + // ICefGeolocationHandler + FOnRequestGeolocationPermission := nil; + FOnCancelGeolocationPermission := nil; + + // ICefJsDialogHandler + FOnJsdialog := nil; + FOnBeforeUnloadDialog := nil; + FOnResetDialogState := nil; + FOnDialogClosed := nil; + + // ICefLifeSpanHandler + FOnBeforePopup := nil; + FOnAfterCreated := nil; + FOnBeforeClose := nil; + FOnClose := nil; + + // ICefRequestHandler + FOnBeforeBrowse := nil; + FOnOpenUrlFromTab := nil; + FOnBeforeResourceLoad := nil; + FOnGetResourceHandler := nil; + FOnResourceRedirect := nil; + FOnResourceResponse := nil; + FOnGetResourceResponseFilter := nil; + FOnResourceLoadComplete := nil; + FOnGetAuthCredentials := nil; + FOnQuotaRequest := nil; + FOnProtocolExecution := nil; + FOnCertificateError := nil; + FOnSelectClientCertificate := nil; + FOnPluginCrashed := nil; + FOnRenderViewReady := nil; + FOnRenderProcessTerminated := nil; + + // ICefDialogHandler + FOnFileDialog := nil; + + // ICefRenderHandler + FOnGetAccessibilityHandler := nil; + FOnGetRootScreenRect := nil; + FOnGetViewRect := nil; + FOnGetScreenPoint := nil; + FOnGetScreenInfo := nil; + FOnPopupShow := nil; + FOnPopupSize := nil; + FOnPaint := nil; + FOnCursorChange := nil; + FOnStartDragging := nil; + FOnUpdateDragCursor := nil; + FOnScrollOffsetChanged := nil; + FOnIMECompositionRangeChanged := nil; + + // ICefDragHandler + FOnDragEnter := nil; + FOnDraggableRegionsChanged := nil; + + // ICefFindHandler + FOnFindResult := nil; + + // Custom + FOnTextResultAvailable := nil; + FOnPdfPrintFinished := nil; + FOnPrefsAvailable := nil; + FOnCookiesDeleted := nil; +end; + +function TChromium.CreateBrowser(const aBrowserParent : TWinControl; const aWindowName : string) : boolean; +var + TempHandle : HWND; + TempRect : TRect; +begin + if (aBrowserParent <> nil) then + begin + TempHandle := aBrowserParent.Handle; + TempRect := aBrowserParent.ClientRect; + end + else + begin + TempHandle := 0; + TempRect := rect(0, 0, 0, 0); + end; + + Result := CreateBrowser(TempHandle, TempRect, aWindowName); +end; + +function TChromium.CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : string = '') : boolean; +begin + Result := False; + + try + if not(csDesigning in ComponentState) and + not(FClosing) and + (FBrowser = nil) and + (FBrowserId = 0) and + (GlobalCEFApp <> nil) and + CreateClientHandler(aParentHandle = 0) then + begin + GetSettings(FBrowserSettings); + + if FIsOSR then + WindowInfoAsWindowless(FWindowInfo, FCompHandle, aWindowName) + else + WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect, aWindowName); + + + if MultithreadApp then + Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, nil) + else + begin + FBrowser := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, nil); + + if (FBrowser <> nil) then + begin + FBrowserId := FBrowser.Identifier; + FInitialized := (FBrowserId <> 0); + Result := True; + end; + end; + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.CreateBrowser', e) then raise; + end; +end; + +procedure TChromium.InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); +var + TempDropTarget : IDropTarget; +begin + if FIsOSR and + not(FDragAndDropInitialized) and + (FDragDropManager = nil) and + (aDropTargetCtrl <> nil) then + begin + FDropTargetCtrl := aDropTargetCtrl; + FDragDropManager := TCEFDragAndDropMgr.Create; FDragDropManager.OnDragEnter := DragDropManager_OnDragEnter; FDragDropManager.OnDragOver := DragDropManager_OnDragOver; @@ -948,17 +948,17 @@ begin FDragAndDropInitialized := True; end; -end; +end; + +procedure TChromium.ShutdownDragAndDrop; +begin + if FDragAndDropInitialized and (FDropTargetCtrl <> nil) then + begin + RevokeDragDrop(FDropTargetCtrl.Handle); + FDragAndDropInitialized := False; + end; +end; -procedure TChromium.ShutdownDragAndDrop; -begin - if FDragAndDropInitialized and (FDropTargetCtrl <> nil) then - begin - RevokeDragDrop(FDropTargetCtrl.Handle); - FDragAndDropInitialized := False; - end; -end; - procedure TChromium.ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); begin if (FDropTargetCtrl <> nil) then @@ -971,13 +971,13 @@ begin end; procedure TChromium.DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); -var +var TempMouseEvent : TCefMouseEvent; - TempAllowedOps : TCefDragOperations; -begin - if (GlobalCEFApp <> nil) then - begin - ToMouseEvent(grfKeyState, pt, TempMouseEvent); + TempAllowedOps : TCefDragOperations; +begin + if (GlobalCEFApp <> nil) then + begin + ToMouseEvent(grfKeyState, pt, TempMouseEvent); DropEffectToDragOperation(dwEffect, TempAllowedOps); DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); @@ -986,1853 +986,1864 @@ begin DragOperationToDropEffect(FDragOperations, dwEffect); end; -end; - +end; + procedure TChromium.DragDropManager_OnDragOver(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); -var - TempMouseEvent : TCefMouseEvent; - TempAllowedOps : TCefDragOperations; - begin - if (GlobalCEFApp <> nil) then - begin - ToMouseEvent(grfKeyState, pt, TempMouseEvent); +var + + TempMouseEvent : TCefMouseEvent; + TempAllowedOps : TCefDragOperations; + +begin + + if (GlobalCEFApp <> nil) then + + begin + + ToMouseEvent(grfKeyState, pt, TempMouseEvent); DropEffectToDragOperation(dwEffect, TempAllowedOps); DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); DragTargetDragOver(@TempMouseEvent, TempAllowedOps); - DragOperationToDropEffect(FDragOperations, dwEffect); - end; -end; + DragOperationToDropEffect(FDragOperations, dwEffect); + end; +end; procedure TChromium.DragDropManager_OnDragLeave(Sender: TObject); -begin - DragTargetDragLeave; -end; +begin -procedure TChromium.DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); -var - TempMouseEvent : TCefMouseEvent; - TempAllowedOps : TCefDragOperations; - begin - if (GlobalCEFApp <> nil) then - begin - ToMouseEvent(grfKeyState, pt, TempMouseEvent); + DragTargetDragLeave; +end; + +procedure TChromium.DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); +var + + TempMouseEvent : TCefMouseEvent; + TempAllowedOps : TCefDragOperations; + +begin + + if (GlobalCEFApp <> nil) then + + begin + + ToMouseEvent(grfKeyState, pt, TempMouseEvent); DropEffectToDragOperation(dwEffect, TempAllowedOps); DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); DragTargetDragOver(@TempMouseEvent, TempAllowedOps); DragTargetDrop(@TempMouseEvent); - DragOperationToDropEffect(FDragOperations, dwEffect); - end; -end; - -procedure TChromium.CloseBrowser(aForceClose : boolean); -begin - if Initialized then FBrowser.Host.CloseBrowser(aForceClose); -end; - -function TChromium.CreateBrowserHost(aWindowInfo : PCefWindowInfo; - const aURL : ustring; - const aSettings : PCefBrowserSettings; - const aContext : ICefRequestContext): Boolean; -var - TempURL : TCefString; -begin - TempURL := CefString(aURL); - Result := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext)) <> 0; -end; - -function TChromium.CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; - const aURL : ustring; - const aSettings : PCefBrowserSettings; - const aContext : ICefRequestContext): ICefBrowser; -var - TempURL : TCefString; - TempBrowser : PCefBrowser; -begin - TempURL := CefString(aURL); - TempBrowser := cef_browser_host_create_browser_sync(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext)); - Result := TCefBrowserRef.UnWrap(TempBrowser); -end; - -procedure TChromium.Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); -begin - if Initialized then FBrowser.Host.Find(aIdentifier, aSearchText, aForward, aMatchCase, aFindNext); -end; - -procedure TChromium.StopFinding(aClearSelection : Boolean); -begin - if Initialized then FBrowser.Host.StopFinding(aClearSelection); -end; - -procedure TChromium.Print; -begin - if Initialized then FBrowser.Host.Print; -end; - -procedure TChromium.PrintToPDF(const aFilePath, aTitle, aURL : ustring); -var - TempSettings : TCefPdfPrintSettings; -begin - if Initialized then - begin - GetPrintPDFSettings(TempSettings, aTitle, aURL); - if (FPDFPrintcb = nil) then FPDFPrintcb := TCefPDFPrintCallBack.Create(self); - FBrowser.Host.PrintToPdf(aFilePath, @TempSettings, FPDFPrintcb); - end; -end; - -procedure TChromium.ClipboardCopy; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Copy; - end; -end; - -procedure TChromium.ClipboardPaste; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Paste; - end; -end; - -procedure TChromium.ClipboardCut; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Cut; - end; -end; - -procedure TChromium.ClipboardUndo; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Undo; - end; -end; - -procedure TChromium.ClipboardRedo; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Redo; - end; -end; - -procedure TChromium.ClipboardDel; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Del; - end; -end; - -procedure TChromium.SelectAll; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.SelectAll; - end; -end; - -procedure TChromium.GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : string); -begin - if (FPDFPrintOptions <> nil) then - begin - aSettings.header_footer_title := CefString(aTitle); - 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; - aSettings.margin_left := FPDFPrintOptions.margin_left; - aSettings.margin_type := FPDFPrintOptions.margin_type; - aSettings.header_footer_enabled := FPDFPrintOptions.header_footer_enabled; - aSettings.selection_only := FPDFPrintOptions.selection_only; - aSettings.landscape := FPDFPrintOptions.landscape; - aSettings.backgrounds_enabled := FPDFPrintOptions.backgrounds_enabled; - end; -end; - -procedure TChromium.GetSettings(var aSettings : TCefBrowserSettings); -begin - if (FFontOptions <> nil) and (FOptions <> nil) then - begin - aSettings.size := SizeOf(TCefBrowserSettings); - aSettings.windowless_frame_rate := FOptions.WindowlessFrameRate; - aSettings.standard_font_family := CefString(FFontOptions.StandardFontFamily); - aSettings.fixed_font_family := CefString(FFontOptions.FixedFontFamily); - aSettings.serif_font_family := CefString(FFontOptions.SerifFontFamily); - aSettings.sans_serif_font_family := CefString(FFontOptions.SansSerifFontFamily); - aSettings.cursive_font_family := CefString(FFontOptions.CursiveFontFamily); - aSettings.fantasy_font_family := CefString(FFontOptions.FantasyFontFamily); - aSettings.default_font_size := FFontOptions.DefaultFontSize; - aSettings.default_fixed_font_size := FFontOptions.DefaultFixedFontSize; - aSettings.minimum_font_size := FFontOptions.MinimumFontSize; - aSettings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize; - aSettings.remote_fonts := FFontOptions.RemoteFonts; - aSettings.default_encoding := CefString(DefaultEncoding); - aSettings.javascript := FOptions.Javascript; - aSettings.javascript_close_windows := FOptions.JavascriptCloseWindows; - aSettings.javascript_access_clipboard := FOptions.JavascriptAccessClipboard; - aSettings.javascript_dom_paste := FOptions.JavascriptDomPaste; - aSettings.plugins := FOptions.Plugins; - aSettings.universal_access_from_file_urls := FOptions.UniversalAccessFromFileUrls; - aSettings.file_access_from_file_urls := FOptions.FileAccessFromFileUrls; - aSettings.web_security := FOptions.WebSecurity; - aSettings.image_loading := FOptions.ImageLoading; - aSettings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit; - aSettings.text_area_resize := FOptions.TextAreaResize; - aSettings.tab_to_links := FOptions.TabToLinks; - aSettings.local_storage := FOptions.LocalStorage; - aSettings.databases := FOptions.Databases; - aSettings.application_cache := FOptions.ApplicationCache; - aSettings.webgl := FOptions.Webgl; - aSettings.background_color := FOptions.BackgroundColor; - aSettings.accept_language_list := CefString(FOptions.AcceptLanguageList); - end; -end; - -procedure TChromium.InitializeSettings(var aSettings : TCefBrowserSettings); -begin - aSettings.size := SizeOf(TCefBrowserSettings); - aSettings.windowless_frame_rate := 30; - aSettings.standard_font_family := CefString(''); - aSettings.fixed_font_family := CefString(''); - aSettings.serif_font_family := CefString(''); - aSettings.sans_serif_font_family := CefString(''); - aSettings.cursive_font_family := CefString(''); - aSettings.fantasy_font_family := CefString(''); - aSettings.default_font_size := 0; - aSettings.default_fixed_font_size := 0; - aSettings.minimum_font_size := 0; - aSettings.minimum_logical_font_size := 0; - aSettings.remote_fonts := STATE_DEFAULT; - aSettings.default_encoding := CefString(''); - aSettings.javascript := STATE_DEFAULT; - aSettings.javascript_close_windows := STATE_DEFAULT; - aSettings.javascript_access_clipboard := STATE_DEFAULT; - aSettings.javascript_dom_paste := STATE_DEFAULT; - aSettings.plugins := STATE_DEFAULT; - aSettings.universal_access_from_file_urls := STATE_DEFAULT; - aSettings.file_access_from_file_urls := STATE_DEFAULT; - aSettings.web_security := STATE_DEFAULT; - aSettings.image_loading := STATE_DEFAULT; - aSettings.image_shrink_standalone_to_fit := STATE_DEFAULT; - aSettings.text_area_resize := STATE_DEFAULT; - aSettings.tab_to_links := STATE_DEFAULT; - aSettings.local_storage := STATE_DEFAULT; - aSettings.databases := STATE_DEFAULT; - aSettings.application_cache := STATE_DEFAULT; - aSettings.webgl := STATE_DEFAULT; - aSettings.background_color := 0; - aSettings.accept_language_list := CefString(''); -end; - -procedure TChromium.LoadURL(const aURL : ustring); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadUrl(aURL); - end; -end; - -procedure TChromium.LoadString(const aString : ustring; const aURL : ustring); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadString(aString, aURL); - end; -end; - -procedure TChromium.LoadRequest(const aRequest: ICefRequest); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadRequest(aRequest); - end; -end; - -procedure TChromium.GoBack; -begin - if Initialized and CanGoBack then FBrowser.GoBack; -end; - -procedure TChromium.GoForward; -begin - if Initialized and CanGoForward then FBrowser.GoForward; -end; - -procedure TChromium.Reload; -begin - if Initialized then FBrowser.Reload; -end; - -procedure TChromium.ReloadIgnoreCache; -begin - if Initialized then FBrowser.ReloadIgnoreCache; -end; - -procedure TChromium.StopLoad; -begin - if Initialized then FBrowser.StopLoad; -end; - -procedure TChromium.StartDownload(const aURL : ustring); -begin - if Initialized then FBrowser.Host.StartDownload(aURL); -end; - -function TChromium.GetIsLoading : boolean; -begin - Result := Initialized and FBrowser.IsLoading; -end; - -function TChromium.GetMultithreadApp : boolean; -begin - Result := True; - - try - if (GlobalCEFApp <> nil) then Result := GlobalCEFApp.MultiThreadedMessageLoop; - except - on e : exception do - if CustomExceptionHandler('TChromium.GetMultithreadApp', e) then raise; - end; -end; - -function TChromium.GetHasDocument : boolean; -begin - Result := Initialized and FBrowser.HasDocument; -end; - -function TChromium.GetHasView : boolean; -begin - Result := Initialized and FBrowser.Host.HasView; -end; - -function TChromium.GetHasDevTools : boolean; -begin - Result := Initialized and FBrowser.Host.HasDevTools; -end; - -function TChromium.GetHasClientHandler : boolean; -begin - Result := (FHandler <> nil); -end; - -function TChromium.GetHasBrowser : boolean; -begin - Result := (FBrowser <> nil); -end; - -function TChromium.GetWindowHandle : THandle; -begin - if Initialized then - Result := FBrowser.Host.WindowHandle - else - Result := 0; -end; - -function TChromium.GetFrameIsFocused : boolean; -begin - Result := Initialized and (FBrowser.FocusedFrame <> nil); -end; - -function TChromium.GetWindowlessFrameRate : integer; -begin - if Initialized then - Result := FBrowser.Host.GetWindowlessFrameRate - else - Result := 0; -end; - -function TChromium.GetVisibleNavigationEntry : ICefNavigationEntry; -begin - if Initialized then - Result := FBrowser.Host.VisibleNavigationEntry - else - Result := nil; -end; - -function TChromium.GetHasValidMainFrame : boolean; -begin - Result := Initialized and (FBrowser.MainFrame <> nil) and FBrowser.MainFrame.IsValid; -end; - -procedure TChromium.SetWindowlessFrameRate(aValue : integer); -begin - if Initialized then FBrowser.Host.SetWindowlessFrameRate(aValue); -end; - -function TChromium.GetCanGoBack : boolean; -begin - Result := Initialized and FBrowser.CanGoBack; -end; - -function TChromium.GetCanGoForward : boolean; -begin - Result := Initialized and FBrowser.CanGoForward; -end; - -function TChromium.GetIsPopUp : boolean; -begin - Result := Initialized and FBrowser.IsPopUp; -end; - -function TChromium.GetInitialized : boolean; -begin - Result := FInitialized and not(FClosing) and (FBrowser <> nil); -end; - -function TChromium.GetDocumentURL : string; -var - TempFrame : ICefFrame; -begin - Result := ''; - - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then Result := TempFrame.URL; - end; -end; - -function TChromium.GetZoomLevel : double; -begin - Result := 0; - - if Initialized then Result := FBrowser.Host.ZoomLevel; -end; - -procedure TChromium.SetZoomLevel(const aValue : double); -begin - if Initialized then FBrowser.Host.ZoomLevel := aValue; -end; - -function TChromium.GetZoomPct : double; -begin - Result := power(1.2, ZoomLevel) * 100; -end; - -procedure TChromium.SetZoomPct(const aValue : double); -begin - if Initialized and (aValue > 0) then ZoomLevel := LogN(1.2, aValue / 100); -end; - -procedure TChromium.ApplyZoomStep; -begin - case FZoomStep of - ZOOM_STEP_25 : ZoomPct := 25; - ZOOM_STEP_33 : ZoomPct := 33; - ZOOM_STEP_50 : ZoomPct := 50; - ZOOM_STEP_67 : ZoomPct := 67; - ZOOM_STEP_75 : ZoomPct := 75; - ZOOM_STEP_90 : ZoomPct := 90; - ZOOM_STEP_100 : ZoomPct := 100; - ZOOM_STEP_110 : ZoomPct := 110; - ZOOM_STEP_125 : ZoomPct := 125; - ZOOM_STEP_150 : ZoomPct := 150; - ZOOM_STEP_175 : ZoomPct := 175; - ZOOM_STEP_200 : ZoomPct := 200; - ZOOM_STEP_250 : ZoomPct := 250; - ZOOM_STEP_300 : ZoomPct := 300; - ZOOM_STEP_400 : ZoomPct := 400; - ZOOM_STEP_500 : ZoomPct := 500; - end; -end; - -procedure TChromium.SetZoomStep(aValue : byte); -begin - if Initialized and (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then - begin - FZoomStep := aValue; - ApplyZoomStep; - end; -end; - -procedure TChromium.IncZoomStep; -begin - if Initialized and (FZoomStep < ZOOM_STEP_MAX) then - begin - inc(FZoomStep); - ApplyZoomStep; - end; -end; - -procedure TChromium.DecZoomStep; -begin - if Initialized and (FZoomStep > ZOOM_STEP_MIN) then - begin - dec(FZoomStep); - ApplyZoomStep; - end; -end; - -procedure TChromium.ResetZoomStep; -begin - ZoomStep := ZOOM_STEP_DEF; -end; - -procedure TChromium.SetDoNotTrack(aValue : boolean); -begin - if (FDoNotTrack <> aValue) then - begin - FDoNotTrack := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetSendReferrer(aValue : boolean); -begin - if (FSendReferrer <> aValue) then - begin - FSendReferrer := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetHyperlinkAuditing(aValue : boolean); -begin - if (FHyperlinkAuditing <> aValue) then - begin - FHyperlinkAuditing := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetCookiePrefs(aValue : integer); -begin - if (FCookiePrefs <> aValue) then - begin - FCookiePrefs := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetImagesPrefs(aValue : integer); -begin - if (FImagesPrefs <> aValue) then - begin - FImagesPrefs := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyType(aValue : integer); -begin - if (FProxyType <> aValue) then - begin - FProxyType := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyServer(const aValue : string); -begin - if (FProxyServer <> aValue) then - begin - FProxyServer := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyPort(aValue : integer); -begin - if (FProxyPort <> aValue) then - begin - FProxyPort := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyUsername(const aValue : string); -begin - if (FProxyUsername <> aValue) then - begin - FProxyUsername := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyPassword(const aValue : string); -begin - if (FProxyPassword <> aValue) then - begin - FProxyPassword := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyScriptURL(const aValue : string); -begin - if (FProxyScriptURL <> aValue) then - begin - FProxyScriptURL := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyByPassList(const aValue : string); -begin - if (FProxyByPassList <> aValue) then - begin - FProxyByPassList := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetCustomHeaderName(const aValue : string); -begin - if (FCustomHeaderName <> aValue) then - begin - FCustomHeaderName := aValue; - FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); - end; -end; - -procedure TChromium.SetCustomHeaderValue(const aValue : string); -begin - if (FCustomHeaderValue <> aValue) then - begin - FCustomHeaderValue := aValue; - FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); - end; -end; - -procedure TChromium.SetCMStoragePath(const aValue : ustring); -var - CookieManager : ICefCookieManager; -begin - FCMStoragePath := aValue; - CookieManager := TCefCookieManagerRef.Global(nil); - - if (CookieManager <> nil) then - CookieManager.SetStoragePath(FCMStoragePath, False, nil); -end; - -procedure TChromium.Internal_GetHTML; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then - begin - if (FVisitor = nil) then FVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetSource(FVisitor); - end; - end; -end; - -procedure TChromium.DeleteCookies; -var - TempTask: ICefTask; -begin - if Initialized then - begin - if (FCookiDeletercb = nil) then FCookiDeletercb := TCefCustomDeleteCookiesCallback.Create(self); - TempTask := TCefDeleteCookiesTask.Create(FCookiDeletercb); - CefPostTask(TID_IO, TempTask); - end; -end; - -procedure TChromium.RetrieveHTML; -var - TempTask: ICefTask; -begin - if Initialized then - begin - TempTask := TCefGetHTMLTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -procedure TChromium.UpdatePreferences; -var - TempTask: ICefTask; -begin - if Initialized then - begin - TempTask := TCefUpdatePrefsTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -procedure TChromium.SavePreferences(const aFileName : string); -var - TempTask: ICefTask; -begin - if Initialized and (length(aFileName) > 0) then - begin - FPrefsFileName := aFileName; - TempTask := TCefSavePrefsTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -function TChromium.SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; -var - TempHandle : HWND; -begin - Result := False; - - if Initialized then - begin - TempHandle := FBrowser.Host.WindowHandle; - Result := (TempHandle <> 0) and (SetParent(TempHandle, aNewParentHwnd) <> 0); - end; -end; - -procedure TChromium.SimulateMouseWheel(aDeltaX, aDeltaY : integer); -var - TempEvent : TCefMouseEvent; -begin - if Initialized then - begin - TempEvent.x := 0; - TempEvent.y := 0; - TempEvent.modifiers := EVENTFLAG_NONE; - FBrowser.Host.SendMouseWheelEvent(@TempEvent, aDeltaX, aDeltaY); - end; -end; - -procedure TChromium.Internal_UpdatePreferences; -begin - FUpdatePreferences := False; - - UpdateProxyPrefs; - UpdatePreference('enable_do_not_track', FDoNotTrack); - UpdatePreference('enable_referrers', FSendReferrer); - UpdatePreference('enable_a_ping', FHyperlinkAuditing); -end; - -function TChromium.UpdateProxyPrefs : boolean; -var - TempError : ustring; - TempProxy : ICefValue; - TempValue : ICefValue; - TempDict : ICefDictionaryValue; -begin - Result := False; - - try - if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference('proxy') then - begin - TempProxy := TCefValueRef.New; - TempValue := TCefValueRef.New; - TempDict := TCefDictionaryValueRef.New; - - case FProxyType of - CEF_PROXYTYPE_AUTODETECT : - begin - TempValue.SetString('auto_detect'); - TempDict.SetValue('mode', TempValue); - end; - - CEF_PROXYTYPE_SYSTEM : - begin - TempValue.SetString('system'); - TempDict.SetValue('mode', TempValue); - end; - - CEF_PROXYTYPE_FIXED_SERVERS : - begin - TempValue.SetString('fixed_servers'); - TempDict.SetValue('mode', TempValue); - TempDict.SetString('server', FProxyServer + ':' + inttostr(FProxyPort)); - if (length(FProxyByPassList) > 0) then TempDict.SetString('bypass_list', FProxyByPassList); - end; - - CEF_PROXYTYPE_PAC_SCRIPT : - begin - TempValue.SetString('pac_script'); - TempDict.SetValue('mode', TempValue); - TempDict.SetString('pac_url', FProxyScriptURL); - end; - - else // CEF_PROXYTYPE_DIRECT - begin - TempValue.SetString('direct'); - TempDict.SetValue('mode', TempValue); - end; - end; - - Result := TempProxy.SetDictionary(TempDict) and - FBrowser.Host.RequestContext.SetPreference('proxy', TempProxy, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdateProxyPrefs error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdateProxyPrefs', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aName : string; aValue : boolean) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - - if aValue then - TempValue.SetBool(1) - else - TempValue.SetBool(0); - - Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aName : string; aValue : integer) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetInt(aValue); - Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aName : string; const aValue : double) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetDouble(aValue); - Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aName, aValue : string) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetString(aValue); - Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -procedure TChromium.HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -null-') - else - aResultSL.Add('-null-'); -end; - -procedure TChromium.HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + BoolToStr(aValue.GetBool, true)) - else - aResultSL.Add(BoolToStr(aValue.GetBool, true)); -end; - -procedure TChromium.HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + IntToStr(aValue.GetInt)) - else - aResultSL.Add(IntToStr(aValue.GetInt)); -end; - -procedure TChromium.HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + FloatToStr(aValue.GetDouble)) - else - aResultSL.Add(FloatToStr(aValue.GetDouble)); -end; - -procedure TChromium.HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + aValue.GetString) - else - aResultSL.Add(aValue.GetString); -end; - -procedure TChromium.HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -binary-') - else - aResultSL.Add('-binary-'); -end; - -procedure TChromium.HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey, TempResult : string; - i, j : integer; - TempList : ICefListValue; - TempValue : ICefValue; - TempSL : TStringList; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - TempList := aValue.GetList; - TempSL := TStringList.Create; - - i := 0; - j := TempList.GetSize; - - TempResult := '(' + inttostr(j) + '){'; - - while (i < j) do - begin - TempValue := TempList.GetValue(i); - - case TempValue.GetType of - VTYPE_NULL : TempResult := TempResult + '-null-,'; - VTYPE_BOOL : TempResult := TempResult + BoolToStr(aValue.GetBool, true) + ','; - VTYPE_INT : TempResult := TempResult + IntToStr(aValue.GetInt) + ','; - VTYPE_DOUBLE : TempResult := TempResult + FloatToStr(aValue.GetDouble) + ','; - VTYPE_STRING : TempResult := TempResult + aValue.GetString + ','; - VTYPE_BINARY : TempResult := TempResult + '-binary-,'; - VTYPE_DICTIONARY : - begin - TempSL.Clear; - HandleDictionary(TempValue.GetDictionary, TempSL, ''); - TempResult := TempResult + TempSL.CommaText + ','; - end; - - VTYPE_LIST : - begin - TempSL.Clear; - HandleList(TempValue, TempSL, '', ''); - TempResult := TempResult + TempSL.CommaText + ','; - end; - - else TempResult := TempResult + '-invalid-,'; - end; - - inc(i); - end; - - i := length(TempResult); - if (i > 0) and (TempResult[i] = ',') then TempResult := copy(TempResult, 1, pred(i)); - TempResult := TempResult + '}'; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + TempResult) - else - aResultSL.Add(TempResult); - - TempSL.Free; -end; - -procedure TChromium.HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -invalid-') - else - aResultSL.Add('-invalid-'); -end; - -procedure TChromium.HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); -var - TempKeys : TStringList; - i, j : integer; - TempValue : ICefValue; - TempNewKey : string; -begin - TempKeys := nil; - - try - try - if (aDict <> nil) then - begin - TempKeys := TStringList.Create; - aDict.GetKeys(TempKeys); - - i := 0; - j := TempKeys.Count; - - while (i < j) do - begin - TempValue := aDict.GetValue(TempKeys[i]); - - case TempValue.GetType of - VTYPE_NULL : HandleNull(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_BOOL : HandleBool(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_INT : HandleInteger(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_DOUBLE : HandleDouble(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_STRING : HandleString(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_BINARY : HandleBinary(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_LIST : HandleList(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_DICTIONARY : - begin - if (length(aRoot) > 0) then - TempNewKey := aRoot + '.' + TempKeys[i] - else - TempNewKey := TempKeys[i]; - - HandleDictionary(TempValue.GetDictionary, aResultSL, TempNewKey); - end; - - else - HandleInvalid(TempValue, aResultSL, aRoot, TempKeys[i]); - end; - - inc(i); - end; - - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.HandleDictionary', e) then raise; - end; - finally - if (TempKeys <> nil) then TempKeys.Free; - end; -end; - -procedure TChromium.Internal_SavePreferences; -var - TempDict : ICefDictionaryValue; - TempPrefs : TStringList; -begin - TempPrefs := nil; - - try - try - if Initialized then - begin - TempPrefs := TStringList.Create; - TempDict := FBrowser.Host.RequestContext.GetAllPreferences(True); - HandleDictionary(TempDict, TempPrefs, ''); - TempPrefs.SaveToFile(FPrefsFileName); - SendCompMessage(CEF_PREFERENCES_SAVED); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.Internal_SavePreferences', e) then raise; - end; - finally - if (TempPrefs <> nil) then FreeAndNil(TempPrefs); - end; -end; - -procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage); -begin - if assigned(FOnPrefsAvailable) then FOnPrefsAvailable(self); -end; - -function TChromium.SendCompMessage(aMsg : cardinal; wParam : cardinal; lParam : integer) : boolean; -begin - Result := (FCompHandle <> 0) and PostMessage(FCompHandle, aMsg, wParam, lParam); -end; - -procedure TChromium.Internal_TextResultAvailable(const aText : string); -begin - if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText); -end; - -procedure TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; aStartLine : integer); -var - TempFrame : ICefFrame; -begin - try - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TChromium.Internal_CookiesDeleted(numDeleted : integer); -begin - if assigned(FOnCookiesDeleted) then FOnCookiesDeleted(self, numDeleted); -end; - -procedure TChromium.Internal_PdfPrintFinished(aResultOK : boolean); -begin - if assigned(FOnPdfPrintFinished) then FOnPdfPrintFinished(self, aResultOK); -end; - -procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); -var - TempPoint : TCefPoint; -begin - if not(Initialized) or HasDevTools then Exit; - - InitializeSettings(FDevBrowserSettings); - - if (aDevTools <> nil) then - WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name) - else - WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME); - - - if (inspectElementAt.x <> low(integer)) and - (inspectElementAt.y <> low(integer)) then - begin - TempPoint.x := inspectElementAt.x; - TempPoint.y := inspectElementAt.y; - - FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, @TempPoint); - end - else - FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, nil); -end; - -procedure TChromium.CloseDevTools(const aDevTools : TWinControl); -begin - if Initialized then - begin - if (aDevTools <> nil) then - begin - {$IFDEF DELPHI16_UP} - WinApi.Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0); - {$ELSE} - Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0); - {$ENDIF} - end; - - if (FBrowser <> nil) then FBrowser.Host.CloseDevTools; - end; -end; - -procedure TChromium.WndProc(var aMessage: TMessage); -begin - case aMessage.Msg of - CEF_PREFERENCES_SAVED : PrefsAvailableMsg(aMessage); - CEF_STARTDRAGGING : DelayedDragging; - - else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam); - end; -end; - -function TChromium.doOnClose(const browser: ICefBrowser): Boolean; -begin - Result := False; - - if (browser <> nil) and (FBrowserId = browser.Identifier) then FClosing := True; - - if Assigned(FOnClose) then FOnClose(Self, browser, Result); -end; - -procedure TChromium.doOnBeforeClose(const browser: ICefBrowser); -begin - if (browser <> nil) and (FBrowserId = browser.Identifier) then - begin - FInitialized := False; - FBrowser := nil; - FBrowserId := 0; - FHandler := nil; - end; - - if Assigned(FOnBeforeClose) then FOnBeforeClose(Self, browser); -end; - -procedure TChromium.doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); -begin - if Assigned(FOnAddressChange) then FOnAddressChange(Self, browser, frame, url); -end; - -procedure TChromium.doOnAfterCreated(const browser: ICefBrowser); -begin - if MultithreadApp and (FBrowser = nil) then - begin - FBrowser := browser; - if (FBrowser <> nil) then FBrowserId := FBrowser.Identifier; - end; - - Internal_UpdatePreferences; - - FInitialized := (FBrowser <> nil) and (FBrowserId <> 0); - - if Assigned(FOnAfterCreated) then FOnAfterCreated(Self, browser); -end; - -function TChromium.doOnBeforeBrowse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - isRedirect : Boolean): Boolean; -begin - Result := False; - - if FUpdatePreferences then Internal_UpdatePreferences; - - if Assigned(FOnBeforeBrowse) then FOnBeforeBrowse(Self, browser, frame, request, isRedirect, Result); -end; - -procedure TChromium.doOnBeforeContextMenu(const browser : ICefBrowser; - const frame : ICefFrame; - const params : ICefContextMenuParams; - const model : ICefMenuModel); -begin - if Assigned(FOnBeforeContextMenu) then FOnBeforeContextMenu(Self, browser, frame, params, model); -end; - -procedure TChromium.doOnBeforeDownload(const browser : ICefBrowser; - const downloadItem : ICefDownloadItem; - const suggestedName : ustring; - const callback : ICefBeforeDownloadCallback); -begin - if Assigned(FOnBeforeDownload) then FOnBeforeDownload(Self, browser, downloadItem, suggestedName, callback); -end; - -function TChromium.doOnBeforePopup(const browser : ICefBrowser; - const frame : ICefFrame; - const targetUrl : ustring; - const targetFrameName : ustring; - targetDisposition : TCefWindowOpenDisposition; - userGesture : Boolean; - var popupFeatures : TCefPopupFeatures; - var windowInfo : TCefWindowInfo; - var client : ICefClient; - var settings : TCefBrowserSettings; - var noJavascriptAccess : Boolean): Boolean; -begin - Result := False; - - if Assigned(FOnBeforePopup) then - FOnBeforePopup(Self, browser, frame, targetUrl, targetFrameName, - targetDisposition, userGesture, popupFeatures, windowInfo, client, - settings, noJavascriptAccess, Result); -end; - -function TChromium.doOnBeforeResourceLoad(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const callback : ICefRequestCallback): TCefReturnValue; -var - TempHeaderMap : ICefStringMultimap; -begin - if FAddCustomHeader then - begin - TempHeaderMap := TCefStringMultimapOwn.Create; - request.GetHeaderMap(TempHeaderMap); - TempHeaderMap.Append(FCustomHeaderName, FCustomHeaderValue); - request.SetHeaderMap(TempHeaderMap); - TempHeaderMap := nil; - end; - - if not(FSendReferrer) then request.SetReferrer('', REFERRER_POLICY_NEVER); - - Result := RV_CONTINUE; - - if Assigned(FOnBeforeResourceLoad) then FOnBeforeResourceLoad(Self, browser, frame, request, callback, Result); -end; - -function TChromium.doOnBeforeUnloadDialog(const browser : ICefBrowser; - const messageText : ustring; - isReload : Boolean; - const callback : ICefJsDialogCallback): Boolean; -begin - Result := False; - - if Assigned(FOnBeforeUnloadDialog) then FOnBeforeUnloadDialog(Self, browser, messageText, isReload, callback, Result); -end; - -procedure TChromium.doOnCancelGeolocationPermission(const browser : ICefBrowser; requestId : Integer); -begin - if Assigned(FOnCancelGeolocationPermission) then - FOnCancelGeolocationPermission(Self, browser, requestId); -end; - -function TChromium.doOnCertificateError(const browser : ICefBrowser; - certError : TCefErrorcode; - const requestUrl : ustring; - const sslInfo : ICefSslInfo; - const callback : ICefRequestCallback): Boolean; -begin - Result := False; - - if Assigned(FOnCertificateError) then - FOnCertificateError(Self, browser, certError, requestUrl, sslInfo, callback, Result); -end; - -function TChromium.doOnConsoleMessage(const browser : ICefBrowser; - const aMessage : ustring; - const source : ustring; - line : Integer): Boolean; -begin - Result := False; - - if Assigned(FOnConsoleMessage) then FOnConsoleMessage(Self, browser, aMessage, source, line, Result); -end; - -function TChromium.doOnContextMenuCommand(const browser : ICefBrowser; - const frame : ICefFrame; - const params : ICefContextMenuParams; - commandId : Integer; - eventFlags : TCefEventFlags): Boolean; -begin - Result := False; - - if Assigned(FOnContextMenuCommand) then - FOnContextMenuCommand(Self, browser, frame, params, commandId, eventFlags, Result); -end; - -procedure TChromium.doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); -begin - if Assigned(FOnContextMenuDismissed) then FOnContextMenuDismissed(Self, browser, frame); -end; - -procedure TChromium.doOnCursorChange(const browser : ICefBrowser; - cursor : TCefCursorHandle; - cursorType : TCefCursorType; - const customCursorInfo : PCefCursorInfo); -begin - if assigned(FOnCursorChange) then FOnCursorChange(self, browser, cursor, cursorType, customCursorInfo); -end; - -procedure TChromium.doOnDialogClosed(const browser: ICefBrowser); -begin - if Assigned(FOnDialogClosed) then FOnDialogClosed(Self, browser); -end; - -procedure TChromium.doOnDownloadUpdated(const browser : ICefBrowser; - const downloadItem : ICefDownloadItem; - const callback : ICefDownloadItemCallback); -begin - if Assigned(FOnDownloadUpdated) then FOnDownloadUpdated(Self, browser, downloadItem, callback); -end; - -function TChromium.doOnDragEnter(const browser : ICefBrowser; - const dragData : ICefDragData; - mask : TCefDragOperations): Boolean; -begin - Result := False; - - if Assigned(FOnDragEnter) then FOnDragEnter(Self, browser, dragData, mask, Result); -end; - -procedure TChromium.doOnDraggableRegionsChanged(const browser : ICefBrowser; - regionsCount : NativeUInt; - regions : PCefDraggableRegionArray); -begin - if Assigned(FOnDraggableRegionsChanged) then FOnDraggableRegionsChanged(Self, browser, regionsCount, regions); -end; - -procedure TChromium.doOnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); -begin - if Assigned(FOnFavIconUrlChange) then FOnFavIconUrlChange(Self, browser, iconUrls); -end; - -function TChromium.doOnFileDialog(const browser : ICefBrowser; - mode : TCefFileDialogMode; - const title : ustring; - const defaultFilePath : ustring; - acceptFilters : TStrings; - selectedAcceptFilter : Integer; - const callback : ICefFileDialogCallback): Boolean; -begin - Result := False; - - if Assigned(FOnFileDialog) then - FOnFileDialog(Self, browser, mode, title, defaultFilePath, acceptFilters, - selectedAcceptFilter, callback, Result); -end; - -procedure TChromium.doOnFindResult(const browser : ICefBrowser; - identifier : integer; - count : Integer; - const selectionRect : PCefRect; - activeMatchOrdinal : Integer; - finalUpdate : Boolean); -begin - if Assigned(FOnFindResult) then - FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); -end; - -procedure TChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); -begin - if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen); -end; - -function TChromium.doOnGetAuthCredentials(const browser : ICefBrowser; - const frame : ICefFrame; - isProxy : Boolean; - const host : ustring; - port : Integer; - const realm : ustring; - const scheme : ustring; - const callback : ICefAuthCallback): Boolean; -begin - Result := False; - - if isProxy then - begin - if (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then - begin - Result := True; - callback.cont(FProxyUsername, FProxyPassword); - end; - end - else - if (frame <> nil) and frame.IsMain and Assigned(FOnGetAuthCredentials) then - FOnGetAuthCredentials(Self, browser, frame, isProxy, host, port, realm, scheme, callback, Result); -end; - -function TChromium.doOnGetResourceHandler(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): ICefResourceHandler; -begin - Result := nil; - - if Assigned(FOnGetResourceHandler) then - FOnGetResourceHandler(Self, browser, frame, request, Result); -end; - -procedure TChromium.doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); -begin - if assigned(FOnGetAccessibilityHandler) then FOnGetAccessibilityHandler(Self, aAccessibilityHandler); -end; - -function TChromium.doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; -begin - Result := False; - - if Assigned(FOnGetRootScreenRect) then FOnGetRootScreenRect(Self, browser, rect, Result); -end; - -function TChromium.doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; -begin - Result := False; - - if Assigned(FOnGetScreenInfo) then FOnGetScreenInfo(Self, browser, screenInfo, Result); -end; - -function TChromium.doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; -begin - Result := False; - - if Assigned(FOnGetScreenPoint) then FOnGetScreenPoint(Self, browser, viewX, viewY, screenX, screenY, Result); -end; - -function TChromium.doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; -begin - Result := False; - - if Assigned(FOnGetViewRect) then FOnGetViewRect(Self, browser, rect, Result); -end; - -procedure TChromium.doOnGotFocus(const browser: ICefBrowser); -begin - if Assigned(FOnGotFocus) then FOnGotFocus(Self, browser) -end; - -function TChromium.doOnJsdialog(const browser : ICefBrowser; - const originUrl : ustring; - dialogType : TCefJsDialogType; - const messageText : ustring; - const defaultPromptText : ustring; - const callback : ICefJsDialogCallback; - out suppressMessage : Boolean): Boolean; -begin - Result := False; - - if not(Initialized) then - suppressMessage := True - else - if Assigned(FOnJsdialog) then - FOnJsdialog(Self, browser, originUrl, dialogType, messageText, - defaultPromptText, callback, suppressMessage, Result); -end; - -function TChromium.doOnKeyEvent(const browser : ICefBrowser; - const event : PCefKeyEvent; - osEvent : TCefEventHandle): Boolean; -begin - Result := False; - - if Assigned(FOnKeyEvent) then FOnKeyEvent(Self, browser, event, osEvent, Result); -end; - -procedure TChromium.doOnLoadEnd(const browser : ICefBrowser; - const frame : ICefFrame; - httpStatusCode : Integer); -begin - if Assigned(FOnLoadEnd) then FOnLoadEnd(Self, browser, frame, httpStatusCode); -end; - -procedure TChromium.doOnLoadError(const browser : ICefBrowser; - const frame : ICefFrame; - errorCode : Integer; - const errorText : ustring; - const failedUrl : ustring); -begin - if Assigned(FOnLoadError) then FOnLoadError(Self, browser, frame, errorCode, errorText, failedUrl); -end; - -procedure TChromium.doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); -begin - if Assigned(FOnLoadingStateChange) then FOnLoadingStateChange(Self, browser, isLoading, canGoBack, canGoForward); -end; - -procedure TChromium.doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); -begin - if Assigned(FOnLoadStart) then FOnLoadStart(Self, browser, frame, transitionType); -end; - -function TChromium.doOnOpenUrlFromTab(const browser : ICefBrowser; - const frame : ICefFrame; - const targetUrl : ustring; - targetDisposition : TCefWindowOpenDisposition; - userGesture : Boolean): Boolean; -begin - Result := False; - - if Assigned(FOnOpenUrlFromTab) then - FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result); -end; - -procedure TChromium.doOnPaint(const browser : ICefBrowser; - kind : TCefPaintElementType; - dirtyRectsCount : NativeUInt; - const dirtyRects : PCefRectArray; - const buffer : Pointer; - width : Integer; - height : Integer); -begin - if Assigned(FOnPaint) then FOnPaint(Self, browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height); -end; - -function TChromium.doOnSelectClientCertificate(const browser : ICefBrowser; - isProxy : boolean; - const host : ustring; - port : integer; - certificatesCount : NativeUInt; - const certificates : TCefX509CertificateArray; - const callback : ICefSelectClientCertificateCallback): boolean; -begin - Result := False; - - if assigned(FOnSelectClientCertificate) then - FOnSelectClientCertificate(self, browser, isProxy, host, port, certificatesCount, certificates, callback, Result); -end; - -procedure TChromium.doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); -begin - if Assigned(FOnPluginCrashed) then FOnPluginCrashed(Self, browser, pluginPath); -end; - -procedure TChromium.doOnPopupShow(const browser: ICefBrowser; show: Boolean); -begin - if assigned(FOnPopupShow) then FOnPopupShow(self, browser, show); -end; - -procedure TChromium.doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); -begin - if assigned(FOnPopupSize) then FOnPopupSize(self, browser, rect); -end; - -function TChromium.doOnPreKeyEvent(const browser : ICefBrowser; - const event : PCefKeyEvent; - osEvent : TCefEventHandle; - out isKeyboardShortcut : Boolean): Boolean; -begin - Result := False; - - if Assigned(FOnPreKeyEvent) then FOnPreKeyEvent(Self, browser, event, osEvent, isKeyboardShortcut, Result); -end; - -function TChromium.doOnProcessMessageReceived(const browser : ICefBrowser; - sourceProcess : TCefProcessId; - const aMessage : ICefProcessMessage): Boolean; -begin - Result := False; - - if Assigned(FOnProcessMessageReceived) then - FOnProcessMessageReceived(Self, browser, sourceProcess, aMessage, Result); -end; - -procedure TChromium.doOnProtocolExecution(const browser : ICefBrowser; - const url : ustring; - out allowOsExecution : Boolean); -begin - if Assigned(FOnProtocolExecution) then FOnProtocolExecution(Self, browser, url, allowOsExecution); -end; - -function TChromium.doOnQuotaRequest(const browser : ICefBrowser; - const originUrl : ustring; - newSize : Int64; - const callback : ICefRequestCallback): Boolean; -begin - Result := False; - - if Assigned(FOnQuotaRequest) then FOnQuotaRequest(Self, browser, originUrl, newSize, callback, Result); -end; - -procedure TChromium.doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); -begin - if Assigned(FOnRenderProcessTerminated) then FOnRenderProcessTerminated(Self, browser, status); -end; - -procedure TChromium.doOnRenderViewReady(const browser: ICefBrowser); -begin - if Assigned(FOnRenderViewReady) then FOnRenderViewReady(Self, browser); -end; - -function TChromium.doOnRequestGeolocationPermission(const browser : ICefBrowser; - const requestingUrl : ustring; - requestId : Integer; - const callback : ICefGeolocationCallback): Boolean; -begin - Result := False; - - if Assigned(FOnRequestGeolocationPermission) then - FOnRequestGeolocationPermission(Self, browser, requestingUrl, requestId, callback, Result); -end; - -procedure TChromium.doOnResetDialogState(const browser: ICefBrowser); -begin - if Assigned(FOnResetDialogState) then FOnResetDialogState(Self, browser); -end; - -procedure TChromium.doOnResourceRedirect(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - var newUrl : ustring); -begin - if Assigned(FOnResourceRedirect) then FOnResourceRedirect(Self, browser, frame, request, response, newUrl); -end; - -function TChromium.doOnResourceResponse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): Boolean; -begin - Result := False; - - if Assigned(FOnResourceResponse) then FOnResourceResponse(Self, browser, frame, request, response, Result); -end; -function TChromium.doOnGetResourceResponseFilter(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse) : ICefResponseFilter; -begin - Result := nil; - - if Assigned(FOnGetResourceResponseFilter) then - FOnGetResourceResponseFilter(self, browser, frame, request, response, Result); -end; - -procedure TChromium.doOnResourceLoadComplete(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - status : TCefUrlRequestStatus; - receivedContentLength : Int64); -begin - if Assigned(FOnResourceLoadComplete) then - FOnResourceLoadComplete(self, browser, frame, request, response, status, receivedContentLength); -end; - -procedure TChromium.doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); -begin - if Assigned(FOnScrollOffsetChanged) then FOnScrollOffsetChanged(Self, browser, x, y); -end; - -procedure TChromium.doOnIMECompositionRangeChanged(const browser : ICefBrowser; - const selected_range : PCefRange; - character_boundsCount : NativeUInt; - const character_bounds : PCefRect); -begin - if assigned(FOnIMECompositionRangeChanged) then - FOnIMECompositionRangeChanged(self, browser, selected_range, character_boundsCount, character_bounds); -end; - -function TChromium.doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; -begin - Result := False; - - if Assigned(FOnSetFocus) then FOnSetFocus(Self, browser, source, Result); -end; - -function TChromium.doOnStartDragging(const browser : ICefBrowser; - const dragData : ICefDragData; - allowedOps : TCefDragOperations; - x : integer; - y : Integer): Boolean; -begin - Result := False; - - if FDragAndDropInitialized and - FDragDropManager.CloneDragData(dragData, allowedOps) then - begin - Result := True; - SendCompMessage(CEF_STARTDRAGGING); - end; - - if Assigned(FOnStartDragging) then FOnStartDragging(Self, browser, dragData, allowedOps, x, y, Result); -end; - -procedure TChromium.DelayedDragging; -var + DragOperationToDropEffect(FDragOperations, dwEffect); + end; +end; + +procedure TChromium.CloseBrowser(aForceClose : boolean); +begin + if Initialized then FBrowser.Host.CloseBrowser(aForceClose); +end; + +function TChromium.CreateBrowserHost(aWindowInfo : PCefWindowInfo; + const aURL : ustring; + const aSettings : PCefBrowserSettings; + const aContext : ICefRequestContext): Boolean; +var + TempURL : TCefString; +begin + TempURL := CefString(aURL); + Result := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext)) <> 0; +end; + +function TChromium.CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; + const aURL : ustring; + const aSettings : PCefBrowserSettings; + const aContext : ICefRequestContext): ICefBrowser; +var + TempURL : TCefString; + TempBrowser : PCefBrowser; +begin + TempURL := CefString(aURL); + TempBrowser := cef_browser_host_create_browser_sync(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext)); + Result := TCefBrowserRef.UnWrap(TempBrowser); +end; + +procedure TChromium.Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); +begin + if Initialized then FBrowser.Host.Find(aIdentifier, aSearchText, aForward, aMatchCase, aFindNext); +end; + +procedure TChromium.StopFinding(aClearSelection : Boolean); +begin + if Initialized then FBrowser.Host.StopFinding(aClearSelection); +end; + +procedure TChromium.Print; +begin + if Initialized then FBrowser.Host.Print; +end; + +procedure TChromium.PrintToPDF(const aFilePath, aTitle, aURL : ustring); +var + TempSettings : TCefPdfPrintSettings; +begin + if Initialized then + begin + GetPrintPDFSettings(TempSettings, aTitle, aURL); + if (FPDFPrintcb = nil) then FPDFPrintcb := TCefPDFPrintCallBack.Create(self); + FBrowser.Host.PrintToPdf(aFilePath, @TempSettings, FPDFPrintcb); + end; +end; + +procedure TChromium.ClipboardCopy; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.Copy; + end; +end; + +procedure TChromium.ClipboardPaste; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.Paste; + end; +end; + +procedure TChromium.ClipboardCut; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.Cut; + end; +end; + +procedure TChromium.ClipboardUndo; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.Undo; + end; +end; + +procedure TChromium.ClipboardRedo; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.Redo; + end; +end; + +procedure TChromium.ClipboardDel; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.Del; + end; +end; + +procedure TChromium.SelectAll; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.FocusedFrame; + if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then TempFrame.SelectAll; + end; +end; + +procedure TChromium.GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : string); +begin + if (FPDFPrintOptions <> nil) then + begin + aSettings.header_footer_title := CefString(aTitle); + 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; + aSettings.margin_left := FPDFPrintOptions.margin_left; + aSettings.margin_type := FPDFPrintOptions.margin_type; + aSettings.header_footer_enabled := FPDFPrintOptions.header_footer_enabled; + aSettings.selection_only := FPDFPrintOptions.selection_only; + aSettings.landscape := FPDFPrintOptions.landscape; + aSettings.backgrounds_enabled := FPDFPrintOptions.backgrounds_enabled; + end; +end; + +procedure TChromium.GetSettings(var aSettings : TCefBrowserSettings); +begin + if (FFontOptions <> nil) and (FOptions <> nil) then + begin + aSettings.size := SizeOf(TCefBrowserSettings); + aSettings.windowless_frame_rate := FOptions.WindowlessFrameRate; + aSettings.standard_font_family := CefString(FFontOptions.StandardFontFamily); + aSettings.fixed_font_family := CefString(FFontOptions.FixedFontFamily); + aSettings.serif_font_family := CefString(FFontOptions.SerifFontFamily); + aSettings.sans_serif_font_family := CefString(FFontOptions.SansSerifFontFamily); + aSettings.cursive_font_family := CefString(FFontOptions.CursiveFontFamily); + aSettings.fantasy_font_family := CefString(FFontOptions.FantasyFontFamily); + aSettings.default_font_size := FFontOptions.DefaultFontSize; + aSettings.default_fixed_font_size := FFontOptions.DefaultFixedFontSize; + aSettings.minimum_font_size := FFontOptions.MinimumFontSize; + aSettings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize; + aSettings.remote_fonts := FFontOptions.RemoteFonts; + aSettings.default_encoding := CefString(DefaultEncoding); + aSettings.javascript := FOptions.Javascript; + aSettings.javascript_close_windows := FOptions.JavascriptCloseWindows; + aSettings.javascript_access_clipboard := FOptions.JavascriptAccessClipboard; + aSettings.javascript_dom_paste := FOptions.JavascriptDomPaste; + aSettings.plugins := FOptions.Plugins; + aSettings.universal_access_from_file_urls := FOptions.UniversalAccessFromFileUrls; + aSettings.file_access_from_file_urls := FOptions.FileAccessFromFileUrls; + aSettings.web_security := FOptions.WebSecurity; + aSettings.image_loading := FOptions.ImageLoading; + aSettings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit; + aSettings.text_area_resize := FOptions.TextAreaResize; + aSettings.tab_to_links := FOptions.TabToLinks; + aSettings.local_storage := FOptions.LocalStorage; + aSettings.databases := FOptions.Databases; + aSettings.application_cache := FOptions.ApplicationCache; + aSettings.webgl := FOptions.Webgl; + aSettings.background_color := FOptions.BackgroundColor; + aSettings.accept_language_list := CefString(FOptions.AcceptLanguageList); + end; +end; + +procedure TChromium.InitializeSettings(var aSettings : TCefBrowserSettings); +begin + aSettings.size := SizeOf(TCefBrowserSettings); + aSettings.windowless_frame_rate := 30; + aSettings.standard_font_family := CefString(''); + aSettings.fixed_font_family := CefString(''); + aSettings.serif_font_family := CefString(''); + aSettings.sans_serif_font_family := CefString(''); + aSettings.cursive_font_family := CefString(''); + aSettings.fantasy_font_family := CefString(''); + aSettings.default_font_size := 0; + aSettings.default_fixed_font_size := 0; + aSettings.minimum_font_size := 0; + aSettings.minimum_logical_font_size := 0; + aSettings.remote_fonts := STATE_DEFAULT; + aSettings.default_encoding := CefString(''); + aSettings.javascript := STATE_DEFAULT; + aSettings.javascript_close_windows := STATE_DEFAULT; + aSettings.javascript_access_clipboard := STATE_DEFAULT; + aSettings.javascript_dom_paste := STATE_DEFAULT; + aSettings.plugins := STATE_DEFAULT; + aSettings.universal_access_from_file_urls := STATE_DEFAULT; + aSettings.file_access_from_file_urls := STATE_DEFAULT; + aSettings.web_security := STATE_DEFAULT; + aSettings.image_loading := STATE_DEFAULT; + aSettings.image_shrink_standalone_to_fit := STATE_DEFAULT; + aSettings.text_area_resize := STATE_DEFAULT; + aSettings.tab_to_links := STATE_DEFAULT; + aSettings.local_storage := STATE_DEFAULT; + aSettings.databases := STATE_DEFAULT; + aSettings.application_cache := STATE_DEFAULT; + aSettings.webgl := STATE_DEFAULT; + aSettings.background_color := 0; + aSettings.accept_language_list := CefString(''); +end; + +procedure TChromium.LoadURL(const aURL : ustring); +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.MainFrame; + if (TempFrame <> nil) then TempFrame.LoadUrl(aURL); + end; +end; + +procedure TChromium.LoadString(const aString : ustring; const aURL : ustring); +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.MainFrame; + if (TempFrame <> nil) then TempFrame.LoadString(aString, aURL); + end; +end; + +procedure TChromium.LoadRequest(const aRequest: ICefRequest); +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.MainFrame; + if (TempFrame <> nil) then TempFrame.LoadRequest(aRequest); + end; +end; + +procedure TChromium.GoBack; +begin + if Initialized and CanGoBack then FBrowser.GoBack; +end; + +procedure TChromium.GoForward; +begin + if Initialized and CanGoForward then FBrowser.GoForward; +end; + +procedure TChromium.Reload; +begin + if Initialized then FBrowser.Reload; +end; + +procedure TChromium.ReloadIgnoreCache; +begin + if Initialized then FBrowser.ReloadIgnoreCache; +end; + +procedure TChromium.StopLoad; +begin + if Initialized then FBrowser.StopLoad; +end; + +procedure TChromium.StartDownload(const aURL : ustring); +begin + if Initialized then FBrowser.Host.StartDownload(aURL); +end; + +function TChromium.GetIsLoading : boolean; +begin + Result := Initialized and FBrowser.IsLoading; +end; + +function TChromium.GetMultithreadApp : boolean; +begin + Result := True; + + try + if (GlobalCEFApp <> nil) then Result := GlobalCEFApp.MultiThreadedMessageLoop; + except + on e : exception do + if CustomExceptionHandler('TChromium.GetMultithreadApp', e) then raise; + end; +end; + +function TChromium.GetHasDocument : boolean; +begin + Result := Initialized and FBrowser.HasDocument; +end; + +function TChromium.GetHasView : boolean; +begin + Result := Initialized and FBrowser.Host.HasView; +end; + +function TChromium.GetHasDevTools : boolean; +begin + Result := Initialized and FBrowser.Host.HasDevTools; +end; + +function TChromium.GetHasClientHandler : boolean; +begin + Result := (FHandler <> nil); +end; + +function TChromium.GetHasBrowser : boolean; +begin + Result := (FBrowser <> nil); +end; + +function TChromium.GetWindowHandle : THandle; +begin + if Initialized then + Result := FBrowser.Host.WindowHandle + else + Result := 0; +end; + +function TChromium.GetFrameIsFocused : boolean; +begin + Result := Initialized and (FBrowser.FocusedFrame <> nil); +end; + +function TChromium.GetWindowlessFrameRate : integer; +begin + if Initialized then + Result := FBrowser.Host.GetWindowlessFrameRate + else + Result := 0; +end; + +function TChromium.GetVisibleNavigationEntry : ICefNavigationEntry; +begin + if Initialized then + Result := FBrowser.Host.VisibleNavigationEntry + else + Result := nil; +end; + +function TChromium.GetHasValidMainFrame : boolean; +begin + Result := Initialized and (FBrowser.MainFrame <> nil) and FBrowser.MainFrame.IsValid; +end; + +procedure TChromium.SetWindowlessFrameRate(aValue : integer); +begin + if Initialized then FBrowser.Host.SetWindowlessFrameRate(aValue); +end; + +function TChromium.GetCanGoBack : boolean; +begin + Result := Initialized and FBrowser.CanGoBack; +end; + +function TChromium.GetCanGoForward : boolean; +begin + Result := Initialized and FBrowser.CanGoForward; +end; + +function TChromium.GetIsPopUp : boolean; +begin + Result := Initialized and FBrowser.IsPopUp; +end; + +function TChromium.GetInitialized : boolean; +begin + Result := FInitialized and not(FClosing) and (FBrowser <> nil); +end; + +function TChromium.GetDocumentURL : string; +var + TempFrame : ICefFrame; +begin + Result := ''; + + if Initialized then + begin + TempFrame := FBrowser.MainFrame; + if (TempFrame <> nil) then Result := TempFrame.URL; + end; +end; + +function TChromium.GetZoomLevel : double; +begin + Result := 0; + + if Initialized then Result := FBrowser.Host.ZoomLevel; +end; + +procedure TChromium.SetZoomLevel(const aValue : double); +begin + if Initialized then FBrowser.Host.ZoomLevel := aValue; +end; + +function TChromium.GetZoomPct : double; +begin + Result := power(1.2, ZoomLevel) * 100; +end; + +procedure TChromium.SetZoomPct(const aValue : double); +begin + if Initialized and (aValue > 0) then ZoomLevel := LogN(1.2, aValue / 100); +end; + +procedure TChromium.ApplyZoomStep; +begin + case FZoomStep of + ZOOM_STEP_25 : ZoomPct := 25; + ZOOM_STEP_33 : ZoomPct := 33; + ZOOM_STEP_50 : ZoomPct := 50; + ZOOM_STEP_67 : ZoomPct := 67; + ZOOM_STEP_75 : ZoomPct := 75; + ZOOM_STEP_90 : ZoomPct := 90; + ZOOM_STEP_100 : ZoomPct := 100; + ZOOM_STEP_110 : ZoomPct := 110; + ZOOM_STEP_125 : ZoomPct := 125; + ZOOM_STEP_150 : ZoomPct := 150; + ZOOM_STEP_175 : ZoomPct := 175; + ZOOM_STEP_200 : ZoomPct := 200; + ZOOM_STEP_250 : ZoomPct := 250; + ZOOM_STEP_300 : ZoomPct := 300; + ZOOM_STEP_400 : ZoomPct := 400; + ZOOM_STEP_500 : ZoomPct := 500; + end; +end; + +procedure TChromium.SetZoomStep(aValue : byte); +begin + if Initialized and (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then + begin + FZoomStep := aValue; + ApplyZoomStep; + end; +end; + +procedure TChromium.IncZoomStep; +begin + if Initialized and (FZoomStep < ZOOM_STEP_MAX) then + begin + inc(FZoomStep); + ApplyZoomStep; + end; +end; + +procedure TChromium.DecZoomStep; +begin + if Initialized and (FZoomStep > ZOOM_STEP_MIN) then + begin + dec(FZoomStep); + ApplyZoomStep; + end; +end; + +procedure TChromium.ResetZoomStep; +begin + ZoomStep := ZOOM_STEP_DEF; +end; + +procedure TChromium.SetDoNotTrack(aValue : boolean); +begin + if (FDoNotTrack <> aValue) then + begin + FDoNotTrack := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetSendReferrer(aValue : boolean); +begin + if (FSendReferrer <> aValue) then + begin + FSendReferrer := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetHyperlinkAuditing(aValue : boolean); +begin + if (FHyperlinkAuditing <> aValue) then + begin + FHyperlinkAuditing := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetCookiePrefs(aValue : integer); +begin + if (FCookiePrefs <> aValue) then + begin + FCookiePrefs := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetImagesPrefs(aValue : integer); +begin + if (FImagesPrefs <> aValue) then + begin + FImagesPrefs := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyType(aValue : integer); +begin + if (FProxyType <> aValue) then + begin + FProxyType := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyServer(const aValue : string); +begin + if (FProxyServer <> aValue) then + begin + FProxyServer := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyPort(aValue : integer); +begin + if (FProxyPort <> aValue) then + begin + FProxyPort := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyUsername(const aValue : string); +begin + if (FProxyUsername <> aValue) then + begin + FProxyUsername := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyPassword(const aValue : string); +begin + if (FProxyPassword <> aValue) then + begin + FProxyPassword := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyScriptURL(const aValue : string); +begin + if (FProxyScriptURL <> aValue) then + begin + FProxyScriptURL := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetProxyByPassList(const aValue : string); +begin + if (FProxyByPassList <> aValue) then + begin + FProxyByPassList := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromium.SetCustomHeaderName(const aValue : string); +begin + if (FCustomHeaderName <> aValue) then + begin + FCustomHeaderName := aValue; + FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); + end; +end; + +procedure TChromium.SetCustomHeaderValue(const aValue : string); +begin + if (FCustomHeaderValue <> aValue) then + begin + FCustomHeaderValue := aValue; + FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); + end; +end; + +procedure TChromium.SetCMStoragePath(const aValue : ustring); +var + CookieManager : ICefCookieManager; +begin + FCMStoragePath := aValue; + CookieManager := TCefCookieManagerRef.Global(nil); + + if (CookieManager <> nil) then + CookieManager.SetStoragePath(FCMStoragePath, False, nil); +end; + +procedure TChromium.Internal_GetHTML; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := FBrowser.MainFrame; + if (TempFrame <> nil) then + begin + if (FVisitor = nil) then FVisitor := TCustomCefStringVisitor.Create(self); + TempFrame.GetSource(FVisitor); + end; + end; +end; + +procedure TChromium.DeleteCookies; +var + TempTask: ICefTask; +begin + if Initialized then + begin + if (FCookiDeletercb = nil) then FCookiDeletercb := TCefCustomDeleteCookiesCallback.Create(self); + TempTask := TCefDeleteCookiesTask.Create(FCookiDeletercb); + CefPostTask(TID_IO, TempTask); + end; +end; + +procedure TChromium.RetrieveHTML; +var + TempTask: ICefTask; +begin + if Initialized then + begin + TempTask := TCefGetHTMLTask.Create(self); + CefPostTask(TID_UI, TempTask); + end; +end; + +procedure TChromium.UpdatePreferences; +var + TempTask: ICefTask; +begin + if Initialized then + begin + TempTask := TCefUpdatePrefsTask.Create(self); + CefPostTask(TID_UI, TempTask); + end; +end; + +procedure TChromium.SavePreferences(const aFileName : string); +var + TempTask: ICefTask; +begin + if Initialized and (length(aFileName) > 0) then + begin + FPrefsFileName := aFileName; + TempTask := TCefSavePrefsTask.Create(self); + CefPostTask(TID_UI, TempTask); + end; +end; + +function TChromium.SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; +var + TempHandle : HWND; +begin + Result := False; + + if Initialized then + begin + TempHandle := FBrowser.Host.WindowHandle; + Result := (TempHandle <> 0) and (SetParent(TempHandle, aNewParentHwnd) <> 0); + end; +end; + +procedure TChromium.SimulateMouseWheel(aDeltaX, aDeltaY : integer); +var + TempEvent : TCefMouseEvent; +begin + if Initialized then + begin + TempEvent.x := 0; + TempEvent.y := 0; + TempEvent.modifiers := EVENTFLAG_NONE; + FBrowser.Host.SendMouseWheelEvent(@TempEvent, aDeltaX, aDeltaY); + end; +end; + +procedure TChromium.Internal_UpdatePreferences; +begin + FUpdatePreferences := False; + + UpdateProxyPrefs; + UpdatePreference('enable_do_not_track', FDoNotTrack); + UpdatePreference('enable_referrers', FSendReferrer); + UpdatePreference('enable_a_ping', FHyperlinkAuditing); +end; + +function TChromium.UpdateProxyPrefs : boolean; +var + TempError : ustring; + TempProxy : ICefValue; + TempValue : ICefValue; + TempDict : ICefDictionaryValue; +begin + Result := False; + + try + if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference('proxy') then + begin + TempProxy := TCefValueRef.New; + TempValue := TCefValueRef.New; + TempDict := TCefDictionaryValueRef.New; + + case FProxyType of + CEF_PROXYTYPE_AUTODETECT : + begin + TempValue.SetString('auto_detect'); + TempDict.SetValue('mode', TempValue); + end; + + CEF_PROXYTYPE_SYSTEM : + begin + TempValue.SetString('system'); + TempDict.SetValue('mode', TempValue); + end; + + CEF_PROXYTYPE_FIXED_SERVERS : + begin + TempValue.SetString('fixed_servers'); + TempDict.SetValue('mode', TempValue); + TempDict.SetString('server', FProxyServer + ':' + inttostr(FProxyPort)); + if (length(FProxyByPassList) > 0) then TempDict.SetString('bypass_list', FProxyByPassList); + end; + + CEF_PROXYTYPE_PAC_SCRIPT : + begin + TempValue.SetString('pac_script'); + TempDict.SetValue('mode', TempValue); + TempDict.SetString('pac_url', FProxyScriptURL); + end; + + else // CEF_PROXYTYPE_DIRECT + begin + TempValue.SetString('direct'); + TempDict.SetValue('mode', TempValue); + end; + end; + + Result := TempProxy.SetDictionary(TempDict) and + FBrowser.Host.RequestContext.SetPreference('proxy', TempProxy, TempError); + + if not(Result) then + OutputDebugMessage('TChromium.UpdateProxyPrefs error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.UpdateProxyPrefs', e) then raise; + end; +end; + +function TChromium.UpdatePreference(const aName : string; aValue : boolean) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + + if aValue then + TempValue.SetBool(1) + else + TempValue.SetBool(0); + + Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; + end; +end; + +function TChromium.UpdatePreference(const aName : string; aValue : integer) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetInt(aValue); + Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; + end; +end; + +function TChromium.UpdatePreference(const aName : string; const aValue : double) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetDouble(aValue); + Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; + end; +end; + +function TChromium.UpdatePreference(const aName, aValue : string) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + if (FBrowser <> nil) and FBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetString(aValue); + Result := FBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; + end; +end; + +procedure TChromium.HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : -null-') + else + aResultSL.Add('-null-'); +end; + +procedure TChromium.HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : ' + BoolToStr(aValue.GetBool, true)) + else + aResultSL.Add(BoolToStr(aValue.GetBool, true)); +end; + +procedure TChromium.HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : ' + IntToStr(aValue.GetInt)) + else + aResultSL.Add(IntToStr(aValue.GetInt)); +end; + +procedure TChromium.HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : ' + FloatToStr(aValue.GetDouble)) + else + aResultSL.Add(FloatToStr(aValue.GetDouble)); +end; + +procedure TChromium.HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : ' + aValue.GetString) + else + aResultSL.Add(aValue.GetString); +end; + +procedure TChromium.HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : -binary-') + else + aResultSL.Add('-binary-'); +end; + +procedure TChromium.HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey, TempResult : string; + i, j : integer; + TempList : ICefListValue; + TempValue : ICefValue; + TempSL : TStringList; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + TempList := aValue.GetList; + TempSL := TStringList.Create; + + i := 0; + j := TempList.GetSize; + + TempResult := '(' + inttostr(j) + '){'; + + while (i < j) do + begin + TempValue := TempList.GetValue(i); + + case TempValue.GetType of + VTYPE_NULL : TempResult := TempResult + '-null-,'; + VTYPE_BOOL : TempResult := TempResult + BoolToStr(aValue.GetBool, true) + ','; + VTYPE_INT : TempResult := TempResult + IntToStr(aValue.GetInt) + ','; + VTYPE_DOUBLE : TempResult := TempResult + FloatToStr(aValue.GetDouble) + ','; + VTYPE_STRING : TempResult := TempResult + aValue.GetString + ','; + VTYPE_BINARY : TempResult := TempResult + '-binary-,'; + VTYPE_DICTIONARY : + begin + TempSL.Clear; + HandleDictionary(TempValue.GetDictionary, TempSL, ''); + TempResult := TempResult + TempSL.CommaText + ','; + end; + + VTYPE_LIST : + begin + TempSL.Clear; + HandleList(TempValue, TempSL, '', ''); + TempResult := TempResult + TempSL.CommaText + ','; + end; + + else TempResult := TempResult + '-invalid-,'; + end; + + inc(i); + end; + + i := length(TempResult); + if (i > 0) and (TempResult[i] = ',') then TempResult := copy(TempResult, 1, pred(i)); + TempResult := TempResult + '}'; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : ' + TempResult) + else + aResultSL.Add(TempResult); + + TempSL.Free; +end; + +procedure TChromium.HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); +var + TempKey : string; +begin + if (aRoot <> '') then + TempKey := aRoot + '.' + aKey + else + TempKey := aKey; + + if (length(TempKey) > 0) then + aResultSL.Add(TempKey + ' : -invalid-') + else + aResultSL.Add('-invalid-'); +end; + +procedure TChromium.HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); +var + TempKeys : TStringList; + i, j : integer; + TempValue : ICefValue; + TempNewKey : string; +begin + TempKeys := nil; + + try + try + if (aDict <> nil) then + begin + TempKeys := TStringList.Create; + aDict.GetKeys(TempKeys); + + i := 0; + j := TempKeys.Count; + + while (i < j) do + begin + TempValue := aDict.GetValue(TempKeys[i]); + + case TempValue.GetType of + VTYPE_NULL : HandleNull(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_BOOL : HandleBool(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_INT : HandleInteger(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_DOUBLE : HandleDouble(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_STRING : HandleString(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_BINARY : HandleBinary(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_LIST : HandleList(TempValue, aResultSL, aRoot, TempKeys[i]); + VTYPE_DICTIONARY : + begin + if (length(aRoot) > 0) then + TempNewKey := aRoot + '.' + TempKeys[i] + else + TempNewKey := TempKeys[i]; + + HandleDictionary(TempValue.GetDictionary, aResultSL, TempNewKey); + end; + + else + HandleInvalid(TempValue, aResultSL, aRoot, TempKeys[i]); + end; + + inc(i); + end; + + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.HandleDictionary', e) then raise; + end; + finally + if (TempKeys <> nil) then TempKeys.Free; + end; +end; + +procedure TChromium.Internal_SavePreferences; +var + TempDict : ICefDictionaryValue; + TempPrefs : TStringList; +begin + TempPrefs := nil; + + try + try + if Initialized then + begin + TempPrefs := TStringList.Create; + TempDict := FBrowser.Host.RequestContext.GetAllPreferences(True); + HandleDictionary(TempDict, TempPrefs, ''); + TempPrefs.SaveToFile(FPrefsFileName); + SendCompMessage(CEF_PREFERENCES_SAVED); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.Internal_SavePreferences', e) then raise; + end; + finally + if (TempPrefs <> nil) then FreeAndNil(TempPrefs); + end; +end; + +procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage); +begin + if assigned(FOnPrefsAvailable) then FOnPrefsAvailable(self); +end; + +function TChromium.SendCompMessage(aMsg : cardinal; wParam : cardinal; lParam : integer) : boolean; +begin + Result := (FCompHandle <> 0) and PostMessage(FCompHandle, aMsg, wParam, lParam); +end; + +procedure TChromium.Internal_TextResultAvailable(const aText : string); +begin + if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText); +end; + +procedure TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; aStartLine : integer); +var + TempFrame : ICefFrame; +begin + try + if Initialized then + begin + TempFrame := FBrowser.MainFrame; + + if (TempFrame <> nil) then + TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); + end; + except + on e : exception do + if CustomExceptionHandler('TChromium.ExecuteJavaScript', e) then raise; + end; +end; + +procedure TChromium.Internal_CookiesDeleted(numDeleted : integer); +begin + if assigned(FOnCookiesDeleted) then FOnCookiesDeleted(self, numDeleted); +end; + +procedure TChromium.Internal_PdfPrintFinished(aResultOK : boolean); +begin + if assigned(FOnPdfPrintFinished) then FOnPdfPrintFinished(self, aResultOK); +end; + +procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); +var + TempPoint : TCefPoint; +begin + if not(Initialized) or HasDevTools then Exit; + + InitializeSettings(FDevBrowserSettings); + + if (aDevTools <> nil) then + WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name) + else + WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME); + + + if (inspectElementAt.x <> low(integer)) and + (inspectElementAt.y <> low(integer)) then + begin + TempPoint.x := inspectElementAt.x; + TempPoint.y := inspectElementAt.y; + + FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, @TempPoint); + end + else + FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, nil); +end; + +procedure TChromium.CloseDevTools(const aDevTools : TWinControl); +begin + if Initialized then + begin + if (aDevTools <> nil) then + begin + {$IFDEF DELPHI16_UP} + WinApi.Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0); + {$ELSE} + Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0); + {$ENDIF} + end; + + if (FBrowser <> nil) then FBrowser.Host.CloseDevTools; + end; +end; + +procedure TChromium.WndProc(var aMessage: TMessage); +begin + case aMessage.Msg of + CEF_PREFERENCES_SAVED : PrefsAvailableMsg(aMessage); + CEF_STARTDRAGGING : DelayedDragging; + + else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam); + end; +end; + +function TChromium.doOnClose(const browser: ICefBrowser): Boolean; +begin + Result := False; + + if (browser <> nil) and (FBrowserId = browser.Identifier) then FClosing := True; + + if Assigned(FOnClose) then FOnClose(Self, browser, Result); +end; + +procedure TChromium.doOnBeforeClose(const browser: ICefBrowser); +begin + if (browser <> nil) and (FBrowserId = browser.Identifier) then + begin + FInitialized := False; + FBrowser := nil; + FBrowserId := 0; + FHandler := nil; + end; + + if Assigned(FOnBeforeClose) then FOnBeforeClose(Self, browser); +end; + +procedure TChromium.doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); +begin + if Assigned(FOnAddressChange) then FOnAddressChange(Self, browser, frame, url); +end; + +procedure TChromium.doOnAfterCreated(const browser: ICefBrowser); +begin + if MultithreadApp and (FBrowser = nil) then + begin + FBrowser := browser; + if (FBrowser <> nil) then FBrowserId := FBrowser.Identifier; + end; + + Internal_UpdatePreferences; + + FInitialized := (FBrowser <> nil) and (FBrowserId <> 0); + + if Assigned(FOnAfterCreated) then FOnAfterCreated(Self, browser); +end; + +function TChromium.doOnBeforeBrowse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + isRedirect : Boolean): Boolean; +begin + Result := False; + + if FUpdatePreferences then Internal_UpdatePreferences; + + if Assigned(FOnBeforeBrowse) then FOnBeforeBrowse(Self, browser, frame, request, isRedirect, Result); +end; + +procedure TChromium.doOnBeforeContextMenu(const browser : ICefBrowser; + const frame : ICefFrame; + const params : ICefContextMenuParams; + const model : ICefMenuModel); +begin + if Assigned(FOnBeforeContextMenu) then FOnBeforeContextMenu(Self, browser, frame, params, model); +end; + +procedure TChromium.doOnBeforeDownload(const browser : ICefBrowser; + const downloadItem : ICefDownloadItem; + const suggestedName : ustring; + const callback : ICefBeforeDownloadCallback); +begin + if Assigned(FOnBeforeDownload) then FOnBeforeDownload(Self, browser, downloadItem, suggestedName, callback); +end; + +function TChromium.doOnBeforePopup(const browser : ICefBrowser; + const frame : ICefFrame; + const targetUrl : ustring; + const targetFrameName : ustring; + targetDisposition : TCefWindowOpenDisposition; + userGesture : Boolean; + var popupFeatures : TCefPopupFeatures; + var windowInfo : TCefWindowInfo; + var client : ICefClient; + var settings : TCefBrowserSettings; + var noJavascriptAccess : Boolean): Boolean; +begin + Result := False; + + if Assigned(FOnBeforePopup) then + FOnBeforePopup(Self, browser, frame, targetUrl, targetFrameName, + targetDisposition, userGesture, popupFeatures, windowInfo, client, + settings, noJavascriptAccess, Result); +end; + +function TChromium.doOnBeforeResourceLoad(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const callback : ICefRequestCallback): TCefReturnValue; +var + TempHeaderMap : ICefStringMultimap; +begin + if FAddCustomHeader then + begin + TempHeaderMap := TCefStringMultimapOwn.Create; + request.GetHeaderMap(TempHeaderMap); + TempHeaderMap.Append(FCustomHeaderName, FCustomHeaderValue); + request.SetHeaderMap(TempHeaderMap); + TempHeaderMap := nil; + end; + + if not(FSendReferrer) then request.SetReferrer('', REFERRER_POLICY_NEVER); + + Result := RV_CONTINUE; + + if Assigned(FOnBeforeResourceLoad) then FOnBeforeResourceLoad(Self, browser, frame, request, callback, Result); +end; + +function TChromium.doOnBeforeUnloadDialog(const browser : ICefBrowser; + const messageText : ustring; + isReload : Boolean; + const callback : ICefJsDialogCallback): Boolean; +begin + Result := False; + + if Assigned(FOnBeforeUnloadDialog) then FOnBeforeUnloadDialog(Self, browser, messageText, isReload, callback, Result); +end; + +procedure TChromium.doOnCancelGeolocationPermission(const browser : ICefBrowser; requestId : Integer); +begin + if Assigned(FOnCancelGeolocationPermission) then + FOnCancelGeolocationPermission(Self, browser, requestId); +end; + +function TChromium.doOnCertificateError(const browser : ICefBrowser; + certError : TCefErrorcode; + const requestUrl : ustring; + const sslInfo : ICefSslInfo; + const callback : ICefRequestCallback): Boolean; +begin + Result := False; + + if Assigned(FOnCertificateError) then + FOnCertificateError(Self, browser, certError, requestUrl, sslInfo, callback, Result); +end; + +function TChromium.doOnConsoleMessage(const browser : ICefBrowser; + const aMessage : ustring; + const source : ustring; + line : Integer): Boolean; +begin + Result := False; + + if Assigned(FOnConsoleMessage) then FOnConsoleMessage(Self, browser, aMessage, source, line, Result); +end; + +function TChromium.doOnContextMenuCommand(const browser : ICefBrowser; + const frame : ICefFrame; + const params : ICefContextMenuParams; + commandId : Integer; + eventFlags : TCefEventFlags): Boolean; +begin + Result := False; + + if Assigned(FOnContextMenuCommand) then + FOnContextMenuCommand(Self, browser, frame, params, commandId, eventFlags, Result); +end; + +procedure TChromium.doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); +begin + if Assigned(FOnContextMenuDismissed) then FOnContextMenuDismissed(Self, browser, frame); +end; + +procedure TChromium.doOnCursorChange(const browser : ICefBrowser; + cursor : TCefCursorHandle; + cursorType : TCefCursorType; + const customCursorInfo : PCefCursorInfo); +begin + if assigned(FOnCursorChange) then FOnCursorChange(self, browser, cursor, cursorType, customCursorInfo); +end; + +procedure TChromium.doOnDialogClosed(const browser: ICefBrowser); +begin + if Assigned(FOnDialogClosed) then FOnDialogClosed(Self, browser); +end; + +procedure TChromium.doOnDownloadUpdated(const browser : ICefBrowser; + const downloadItem : ICefDownloadItem; + const callback : ICefDownloadItemCallback); +begin + if Assigned(FOnDownloadUpdated) then FOnDownloadUpdated(Self, browser, downloadItem, callback); +end; + +function TChromium.doOnDragEnter(const browser : ICefBrowser; + const dragData : ICefDragData; + mask : TCefDragOperations): Boolean; +begin + Result := False; + + if Assigned(FOnDragEnter) then FOnDragEnter(Self, browser, dragData, mask, Result); +end; + +procedure TChromium.doOnDraggableRegionsChanged(const browser : ICefBrowser; + regionsCount : NativeUInt; + regions : PCefDraggableRegionArray); +begin + if Assigned(FOnDraggableRegionsChanged) then FOnDraggableRegionsChanged(Self, browser, regionsCount, regions); +end; + +procedure TChromium.doOnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); +begin + if Assigned(FOnFavIconUrlChange) then FOnFavIconUrlChange(Self, browser, iconUrls); +end; + +function TChromium.doOnFileDialog(const browser : ICefBrowser; + mode : TCefFileDialogMode; + const title : ustring; + const defaultFilePath : ustring; + acceptFilters : TStrings; + selectedAcceptFilter : Integer; + const callback : ICefFileDialogCallback): Boolean; +begin + Result := False; + + if Assigned(FOnFileDialog) then + FOnFileDialog(Self, browser, mode, title, defaultFilePath, acceptFilters, + selectedAcceptFilter, callback, Result); +end; + +procedure TChromium.doOnFindResult(const browser : ICefBrowser; + identifier : integer; + count : Integer; + const selectionRect : PCefRect; + activeMatchOrdinal : Integer; + finalUpdate : Boolean); +begin + if Assigned(FOnFindResult) then + FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); +end; + +procedure TChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); +begin + if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen); +end; + +function TChromium.doOnGetAuthCredentials(const browser : ICefBrowser; + const frame : ICefFrame; + isProxy : Boolean; + const host : ustring; + port : Integer; + const realm : ustring; + const scheme : ustring; + const callback : ICefAuthCallback): Boolean; +begin + Result := False; + + if isProxy then + begin + if (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then + begin + Result := True; + callback.cont(FProxyUsername, FProxyPassword); + end; + end + else + if (frame <> nil) and frame.IsMain and Assigned(FOnGetAuthCredentials) then + FOnGetAuthCredentials(Self, browser, frame, isProxy, host, port, realm, scheme, callback, Result); +end; + +function TChromium.doOnGetResourceHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest): ICefResourceHandler; +begin + Result := nil; + + if Assigned(FOnGetResourceHandler) then + FOnGetResourceHandler(Self, browser, frame, request, Result); +end; + +procedure TChromium.doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); +begin + if assigned(FOnGetAccessibilityHandler) then FOnGetAccessibilityHandler(Self, aAccessibilityHandler); +end; + +function TChromium.doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; +begin + Result := False; + + if Assigned(FOnGetRootScreenRect) then FOnGetRootScreenRect(Self, browser, rect, Result); +end; + +function TChromium.doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; +begin + Result := False; + + if Assigned(FOnGetScreenInfo) then FOnGetScreenInfo(Self, browser, screenInfo, Result); +end; + +function TChromium.doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; +begin + Result := False; + + if Assigned(FOnGetScreenPoint) then FOnGetScreenPoint(Self, browser, viewX, viewY, screenX, screenY, Result); +end; + +function TChromium.doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; +begin + Result := False; + + if Assigned(FOnGetViewRect) then FOnGetViewRect(Self, browser, rect, Result); +end; + +procedure TChromium.doOnGotFocus(const browser: ICefBrowser); +begin + if Assigned(FOnGotFocus) then FOnGotFocus(Self, browser) +end; + +function TChromium.doOnJsdialog(const browser : ICefBrowser; + const originUrl : ustring; + dialogType : TCefJsDialogType; + const messageText : ustring; + const defaultPromptText : ustring; + const callback : ICefJsDialogCallback; + out suppressMessage : Boolean): Boolean; +begin + Result := False; + + if not(Initialized) then + suppressMessage := True + else + if Assigned(FOnJsdialog) then + FOnJsdialog(Self, browser, originUrl, dialogType, messageText, + defaultPromptText, callback, suppressMessage, Result); +end; + +function TChromium.doOnKeyEvent(const browser : ICefBrowser; + const event : PCefKeyEvent; + osEvent : TCefEventHandle): Boolean; +begin + Result := False; + + if Assigned(FOnKeyEvent) then FOnKeyEvent(Self, browser, event, osEvent, Result); +end; + +procedure TChromium.doOnLoadEnd(const browser : ICefBrowser; + const frame : ICefFrame; + httpStatusCode : Integer); +begin + if Assigned(FOnLoadEnd) then FOnLoadEnd(Self, browser, frame, httpStatusCode); +end; + +procedure TChromium.doOnLoadError(const browser : ICefBrowser; + const frame : ICefFrame; + errorCode : Integer; + const errorText : ustring; + const failedUrl : ustring); +begin + if Assigned(FOnLoadError) then FOnLoadError(Self, browser, frame, errorCode, errorText, failedUrl); +end; + +procedure TChromium.doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +begin + if Assigned(FOnLoadingStateChange) then FOnLoadingStateChange(Self, browser, isLoading, canGoBack, canGoForward); +end; + +procedure TChromium.doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); +begin + if Assigned(FOnLoadStart) then FOnLoadStart(Self, browser, frame, transitionType); +end; + +function TChromium.doOnOpenUrlFromTab(const browser : ICefBrowser; + const frame : ICefFrame; + const targetUrl : ustring; + targetDisposition : TCefWindowOpenDisposition; + userGesture : Boolean): Boolean; +begin + Result := False; + + if Assigned(FOnOpenUrlFromTab) then + FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result); +end; + +procedure TChromium.doOnPaint(const browser : ICefBrowser; + kind : TCefPaintElementType; + dirtyRectsCount : NativeUInt; + const dirtyRects : PCefRectArray; + const buffer : Pointer; + width : Integer; + height : Integer); +begin + if Assigned(FOnPaint) then FOnPaint(Self, browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height); +end; + +function TChromium.doOnSelectClientCertificate(const browser : ICefBrowser; + isProxy : boolean; + const host : ustring; + port : integer; + certificatesCount : NativeUInt; + const certificates : TCefX509CertificateArray; + const callback : ICefSelectClientCertificateCallback): boolean; +begin + Result := False; + + if assigned(FOnSelectClientCertificate) then + FOnSelectClientCertificate(self, browser, isProxy, host, port, certificatesCount, certificates, callback, Result); +end; + +procedure TChromium.doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); +begin + if Assigned(FOnPluginCrashed) then FOnPluginCrashed(Self, browser, pluginPath); +end; + +procedure TChromium.doOnPopupShow(const browser: ICefBrowser; show: Boolean); +begin + if assigned(FOnPopupShow) then FOnPopupShow(self, browser, show); +end; + +procedure TChromium.doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); +begin + if assigned(FOnPopupSize) then FOnPopupSize(self, browser, rect); +end; + +function TChromium.doOnPreKeyEvent(const browser : ICefBrowser; + const event : PCefKeyEvent; + osEvent : TCefEventHandle; + out isKeyboardShortcut : Boolean): Boolean; +begin + Result := False; + + if Assigned(FOnPreKeyEvent) then FOnPreKeyEvent(Self, browser, event, osEvent, isKeyboardShortcut, Result); +end; + +function TChromium.doOnProcessMessageReceived(const browser : ICefBrowser; + sourceProcess : TCefProcessId; + const aMessage : ICefProcessMessage): Boolean; +begin + Result := False; + + if Assigned(FOnProcessMessageReceived) then + FOnProcessMessageReceived(Self, browser, sourceProcess, aMessage, Result); +end; + +procedure TChromium.doOnProtocolExecution(const browser : ICefBrowser; + const url : ustring; + out allowOsExecution : Boolean); +begin + if Assigned(FOnProtocolExecution) then FOnProtocolExecution(Self, browser, url, allowOsExecution); +end; + +function TChromium.doOnQuotaRequest(const browser : ICefBrowser; + const originUrl : ustring; + newSize : Int64; + const callback : ICefRequestCallback): Boolean; +begin + Result := False; + + if Assigned(FOnQuotaRequest) then FOnQuotaRequest(Self, browser, originUrl, newSize, callback, Result); +end; + +procedure TChromium.doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); +begin + if Assigned(FOnRenderProcessTerminated) then FOnRenderProcessTerminated(Self, browser, status); +end; + +procedure TChromium.doOnRenderViewReady(const browser: ICefBrowser); +begin + if Assigned(FOnRenderViewReady) then FOnRenderViewReady(Self, browser); +end; + +function TChromium.doOnRequestGeolocationPermission(const browser : ICefBrowser; + const requestingUrl : ustring; + requestId : Integer; + const callback : ICefGeolocationCallback): Boolean; +begin + Result := False; + + if Assigned(FOnRequestGeolocationPermission) then + FOnRequestGeolocationPermission(Self, browser, requestingUrl, requestId, callback, Result); +end; + +procedure TChromium.doOnResetDialogState(const browser: ICefBrowser); +begin + if Assigned(FOnResetDialogState) then FOnResetDialogState(Self, browser); +end; + +procedure TChromium.doOnResourceRedirect(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var newUrl : ustring); +begin + if Assigned(FOnResourceRedirect) then FOnResourceRedirect(Self, browser, frame, request, response, newUrl); +end; + +function TChromium.doOnResourceResponse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse): Boolean; +begin + Result := False; + + if Assigned(FOnResourceResponse) then FOnResourceResponse(Self, browser, frame, request, response, Result); +end; +function TChromium.doOnGetResourceResponseFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse) : ICefResponseFilter; +begin + Result := nil; + + if Assigned(FOnGetResourceResponseFilter) then + FOnGetResourceResponseFilter(self, browser, frame, request, response, Result); +end; + +procedure TChromium.doOnResourceLoadComplete(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + status : TCefUrlRequestStatus; + receivedContentLength : Int64); +begin + if Assigned(FOnResourceLoadComplete) then + FOnResourceLoadComplete(self, browser, frame, request, response, status, receivedContentLength); +end; + +procedure TChromium.doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); +begin + if Assigned(FOnScrollOffsetChanged) then FOnScrollOffsetChanged(Self, browser, x, y); +end; + +procedure TChromium.doOnIMECompositionRangeChanged(const browser : ICefBrowser; + const selected_range : PCefRange; + character_boundsCount : NativeUInt; + const character_bounds : PCefRect); +begin + if assigned(FOnIMECompositionRangeChanged) then + FOnIMECompositionRangeChanged(self, browser, selected_range, character_boundsCount, character_bounds); +end; + +function TChromium.doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; +begin + Result := False; + + if Assigned(FOnSetFocus) then FOnSetFocus(Self, browser, source, Result); +end; + +function TChromium.doOnStartDragging(const browser : ICefBrowser; + const dragData : ICefDragData; + allowedOps : TCefDragOperations; + x : integer; + y : Integer): Boolean; +begin + Result := False; + + if FDragAndDropInitialized and + FDragDropManager.CloneDragData(dragData, allowedOps) then + begin + Result := True; + SendCompMessage(CEF_STARTDRAGGING); + end; + + if Assigned(FOnStartDragging) then FOnStartDragging(Self, browser, dragData, allowedOps, x, y, Result); +end; + +procedure TChromium.DelayedDragging; +var TempOperation : TCefDragOperation; - TempPoint : TPoint; -begin - if FDragAndDropInitialized and (FDropTargetCtrl <> nil) and (GlobalCEFApp <> nil) then - begin + TempPoint : TPoint; +begin + if FDragAndDropInitialized and (FDropTargetCtrl <> nil) and (GlobalCEFApp <> nil) then + begin FDragOperations := DRAG_OPERATION_NONE; TempOperation := FDragDropManager.StartDragging; FDragOperations := DRAG_OPERATION_NONE; @@ -2844,241 +2855,241 @@ begin DragSourceEndedAt(TempPoint.x, TempPoint.y, TempOperation); DragSourceSystemDragEnded; end; -end; - -procedure TChromium.doOnStatusMessage(const browser: ICefBrowser; const value: ustring); -begin - if Assigned(FOnStatusMessage) then FOnStatusMessage(Self, browser, value); -end; - -procedure TChromium.doOnTakeFocus(const browser: ICefBrowser; next: Boolean); -begin - if Assigned(FOnTakeFocus) then FOnTakeFocus(Self, browser, next); -end; - -procedure TChromium.doOnTitleChange(const browser: ICefBrowser; const title: ustring); -begin - if Assigned(FOnTitleChange) then FOnTitleChange(Self, browser, title); -end; - -function TChromium.doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; -begin - Result := False; - - if Assigned(FOnTooltip) then FOnTooltip(Self, browser, text, Result); -end; - -procedure TChromium.doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); -begin - if FDragAndDropInitialized then FDragOperations := operation; - - if Assigned(FOnUpdateDragCursor) then FOnUpdateDragCursor(Self, browser, operation); -end; - -function TChromium.GetParentForm : TCustomForm; -var - TempComp : TComponent; -begin - Result := nil; - TempComp := Owner; - - while (TempComp <> nil) do - if (TempComp is TCustomForm) then - begin - Result := TCustomForm(TempComp); - exit; - end - else - TempComp := TempComp.owner; -end; - -procedure TChromium.MoveFormTo(const x, y: Integer); -var - TempForm : TCustomForm; - TempRect : TRect; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - begin - TempRect.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); - TempRect.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); - TempRect.Right := TempRect.Left + TempForm.Width - 1; - TempRect.Bottom := TempRect.Top + TempForm.Height - 1; - - TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); - end; -end; - -procedure TChromium.MoveFormBy(const x, y: Integer); -var - TempForm : TCustomForm; - TempRect : TRect; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - begin - TempRect.Left := min(max(TempForm.Left + x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); - TempRect.Top := min(max(TempForm.Top + y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); - TempRect.Right := TempRect.Left + TempForm.Width - 1; - TempRect.Bottom := TempRect.Top + TempForm.Height - 1; - - TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); - end; -end; - -procedure TChromium.ResizeFormWidthTo(const x : Integer); -var - TempForm : TCustomForm; - TempX, TempDeltaX : integer; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - begin - TempX := max(x, 100); - TempDeltaX := TempForm.Width - TempForm.ClientWidth; - TempForm.Width := TempX + TempDeltaX; - end; -end; - -procedure TChromium.ResizeFormHeightTo(const y : Integer); -var - TempForm : TCustomForm; - TempY, TempDeltaY : integer; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - begin - TempY := max(y, 100); - TempDeltaY := TempForm.Height - TempForm.ClientHeight; - TempForm.Height := TempY + TempDeltaY; - end; -end; - -procedure TChromium.SetFormLeftTo(const x : Integer); -var - TempForm : TCustomForm; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - TempForm.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); -end; - -procedure TChromium.SetFormTopTo(const y : Integer); -var - TempForm : TCustomForm; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - TempForm.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); -end; - -procedure TChromium.WasResized; -begin - if Initialized then FBrowser.Host.WasResized; -end; - -procedure TChromium.WasHidden(hidden: Boolean); -begin - if Initialized then FBrowser.Host.WasHidden(hidden); -end; - -procedure TChromium.NotifyScreenInfoChanged; -begin - if Initialized then FBrowser.Host.NotifyScreenInfoChanged; -end; - -procedure TChromium.NotifyMoveOrResizeStarted; -begin - if Initialized then FBrowser.Host.NotifyMoveOrResizeStarted; -end; - -procedure TChromium.Invalidate(kind: TCefPaintElementType); -begin - if Initialized then FBrowser.Host.Invalidate(kind); -end; - -procedure TChromium.SendKeyEvent(const event: PCefKeyEvent); -begin - if Initialized then FBrowser.Host.SendKeyEvent(event); -end; - -procedure TChromium.SendMouseClickEvent(const event : PCefMouseEvent; - kind : TCefMouseButtonType; - mouseUp : Boolean; - clickCount : Integer); -begin - if Initialized then FBrowser.Host.SendMouseClickEvent(event, kind, mouseUp, clickCount); -end; - -procedure TChromium.SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); -begin - if Initialized then FBrowser.Host.SendMouseMoveEvent(event, mouseLeave); -end; - -procedure TChromium.SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); -begin - if Initialized then FBrowser.Host.SendMouseWheelEvent(event, deltaX, deltaY); -end; - -procedure TChromium.SendFocusEvent(setFocus: Boolean); -begin - if Initialized then FBrowser.Host.SendFocusEvent(setFocus); -end; - -procedure TChromium.SendCaptureLostEvent; -begin - if Initialized then FBrowser.Host.SendCaptureLostEvent; -end; - -procedure TChromium.SetFocus(focus: Boolean); -begin - if Initialized then FBrowser.Host.SetFocus(focus); -end; - -procedure TChromium.SetAccessibilityState(accessibilityState: TCefState); -begin - if Initialized then FBrowser.Host.SetAccessibilityState(accessibilityState); -end; - -function TChromium.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; -begin - Result := Initialized and FBrowser.SendProcessMessage(targetProcess, ProcMessage); -end; - -procedure TChromium.DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); -begin - if Initialized then FBrowser.Host.DragTargetDragEnter(dragData, event, allowedOps); -end; - -procedure TChromium.DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); -begin - if Initialized then FBrowser.Host.DragTargetDragOver(event, allowedOps); -end; - -procedure TChromium.DragTargetDragLeave; -begin - if Initialized then FBrowser.Host.DragTargetDragLeave; -end; - -procedure TChromium.DragTargetDrop(event: PCefMouseEvent); -begin - if Initialized then FBrowser.Host.DragTargetDrop(event); -end; - -procedure TChromium.DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); -begin - if Initialized then FBrowser.Host.DragSourceEndedAt(x, y, op); -end; - -procedure TChromium.DragSourceSystemDragEnded; -begin - if Initialized then FBrowser.Host.DragSourceSystemDragEnded; -end; - -end. +end; + +procedure TChromium.doOnStatusMessage(const browser: ICefBrowser; const value: ustring); +begin + if Assigned(FOnStatusMessage) then FOnStatusMessage(Self, browser, value); +end; + +procedure TChromium.doOnTakeFocus(const browser: ICefBrowser; next: Boolean); +begin + if Assigned(FOnTakeFocus) then FOnTakeFocus(Self, browser, next); +end; + +procedure TChromium.doOnTitleChange(const browser: ICefBrowser; const title: ustring); +begin + if Assigned(FOnTitleChange) then FOnTitleChange(Self, browser, title); +end; + +function TChromium.doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; +begin + Result := False; + + if Assigned(FOnTooltip) then FOnTooltip(Self, browser, text, Result); +end; + +procedure TChromium.doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); +begin + if FDragAndDropInitialized then FDragOperations := operation; + + if Assigned(FOnUpdateDragCursor) then FOnUpdateDragCursor(Self, browser, operation); +end; + +function TChromium.GetParentForm : TCustomForm; +var + TempComp : TComponent; +begin + Result := nil; + TempComp := Owner; + + while (TempComp <> nil) do + if (TempComp is TCustomForm) then + begin + Result := TCustomForm(TempComp); + exit; + end + else + TempComp := TempComp.owner; +end; + +procedure TChromium.MoveFormTo(const x, y: Integer); +var + TempForm : TCustomForm; + TempRect : TRect; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + begin + TempRect.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); + TempRect.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); + TempRect.Right := TempRect.Left + TempForm.Width - 1; + TempRect.Bottom := TempRect.Top + TempForm.Height - 1; + + TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); + end; +end; + +procedure TChromium.MoveFormBy(const x, y: Integer); +var + TempForm : TCustomForm; + TempRect : TRect; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + begin + TempRect.Left := min(max(TempForm.Left + x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); + TempRect.Top := min(max(TempForm.Top + y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); + TempRect.Right := TempRect.Left + TempForm.Width - 1; + TempRect.Bottom := TempRect.Top + TempForm.Height - 1; + + TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); + end; +end; + +procedure TChromium.ResizeFormWidthTo(const x : Integer); +var + TempForm : TCustomForm; + TempX, TempDeltaX : integer; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + begin + TempX := max(x, 100); + TempDeltaX := TempForm.Width - TempForm.ClientWidth; + TempForm.Width := TempX + TempDeltaX; + end; +end; + +procedure TChromium.ResizeFormHeightTo(const y : Integer); +var + TempForm : TCustomForm; + TempY, TempDeltaY : integer; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + begin + TempY := max(y, 100); + TempDeltaY := TempForm.Height - TempForm.ClientHeight; + TempForm.Height := TempY + TempDeltaY; + end; +end; + +procedure TChromium.SetFormLeftTo(const x : Integer); +var + TempForm : TCustomForm; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + TempForm.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); +end; + +procedure TChromium.SetFormTopTo(const y : Integer); +var + TempForm : TCustomForm; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + TempForm.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); +end; + +procedure TChromium.WasResized; +begin + if Initialized then FBrowser.Host.WasResized; +end; + +procedure TChromium.WasHidden(hidden: Boolean); +begin + if Initialized then FBrowser.Host.WasHidden(hidden); +end; + +procedure TChromium.NotifyScreenInfoChanged; +begin + if Initialized then FBrowser.Host.NotifyScreenInfoChanged; +end; + +procedure TChromium.NotifyMoveOrResizeStarted; +begin + if Initialized then FBrowser.Host.NotifyMoveOrResizeStarted; +end; + +procedure TChromium.Invalidate(kind: TCefPaintElementType); +begin + if Initialized then FBrowser.Host.Invalidate(kind); +end; + +procedure TChromium.SendKeyEvent(const event: PCefKeyEvent); +begin + if Initialized then FBrowser.Host.SendKeyEvent(event); +end; + +procedure TChromium.SendMouseClickEvent(const event : PCefMouseEvent; + kind : TCefMouseButtonType; + mouseUp : Boolean; + clickCount : Integer); +begin + if Initialized then FBrowser.Host.SendMouseClickEvent(event, kind, mouseUp, clickCount); +end; + +procedure TChromium.SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); +begin + if Initialized then FBrowser.Host.SendMouseMoveEvent(event, mouseLeave); +end; + +procedure TChromium.SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); +begin + if Initialized then FBrowser.Host.SendMouseWheelEvent(event, deltaX, deltaY); +end; + +procedure TChromium.SendFocusEvent(setFocus: Boolean); +begin + if Initialized then FBrowser.Host.SendFocusEvent(setFocus); +end; + +procedure TChromium.SendCaptureLostEvent; +begin + if Initialized then FBrowser.Host.SendCaptureLostEvent; +end; + +procedure TChromium.SetFocus(focus: Boolean); +begin + if Initialized then FBrowser.Host.SetFocus(focus); +end; + +procedure TChromium.SetAccessibilityState(accessibilityState: TCefState); +begin + if Initialized then FBrowser.Host.SetAccessibilityState(accessibilityState); +end; + +function TChromium.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; +begin + Result := Initialized and FBrowser.SendProcessMessage(targetProcess, ProcMessage); +end; + +procedure TChromium.DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); +begin + if Initialized then FBrowser.Host.DragTargetDragEnter(dragData, event, allowedOps); +end; + +procedure TChromium.DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); +begin + if Initialized then FBrowser.Host.DragTargetDragOver(event, allowedOps); +end; + +procedure TChromium.DragTargetDragLeave; +begin + if Initialized then FBrowser.Host.DragTargetDragLeave; +end; + +procedure TChromium.DragTargetDrop(event: PCefMouseEvent); +begin + if Initialized then FBrowser.Host.DragTargetDrop(event); +end; + +procedure TChromium.DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); +begin + if Initialized then FBrowser.Host.DragSourceEndedAt(x, y, op); +end; + +procedure TChromium.DragSourceSystemDragEnded; +begin + if Initialized then FBrowser.Host.DragSourceSystemDragEnded; +end; + +end. diff --git a/source/uCEFRenderProcessHandler.pas b/source/uCEFRenderProcessHandler.pas index 511c0a84..d7c0b9ca 100644 --- a/source/uCEFRenderProcessHandler.pas +++ b/source/uCEFRenderProcessHandler.pas @@ -75,6 +75,7 @@ type TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn) protected + FExtraMsgNames : TStringList; FMessageName : ustring; FOnRenderThreadCreatedEvent : TOnRenderThreadCreatedEvent; FOnWebKitInitializedEvent : TOnWebKitInitializedEvent; @@ -100,6 +101,8 @@ type public constructor Create; override; + destructor Destroy; override; + procedure AddMessageName(const aName : string); property MessageName : ustring read FMessageName write FMessageName; property OnRenderThreadCreatedEvent : TOnRenderThreadCreatedEvent read FOnRenderThreadCreatedEvent write FOnRenderThreadCreatedEvent; @@ -304,6 +307,7 @@ begin inherited Create; FMessageName := ''; + FExtraMsgNames := TStringList.Create; FOnRenderThreadCreatedEvent := nil; FOnWebKitInitializedEvent := nil; FOnBrowserCreatedEvent := nil; @@ -316,6 +320,18 @@ begin FOnProcessMessageReceivedEvent := nil; end; +destructor TCefCustomRenderProcessHandler.Destroy; +begin + FExtraMsgNames.Free; + + inherited Destroy; +end; + +procedure TCefCustomRenderProcessHandler.AddMessageName(const aName : string); +begin + FExtraMsgNames.Add(aName); +end; + procedure TCefCustomRenderProcessHandler.OnRenderThreadCreated(const extraInfo: ICefListValue); begin if assigned(FOnRenderThreadCreatedEvent) then FOnRenderThreadCreatedEvent(extraInfo); @@ -384,7 +400,8 @@ function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser sourceProcess : TCefProcessId; const message : ICefProcessMessage): Boolean; begin - if assigned(FOnProcessMessageReceivedEvent) and (message.Name = FMessageName) then + if assigned(FOnProcessMessageReceivedEvent) and + ((message.Name = FMessageName) or (FExtraMsgNames.IndexOf(message.Name) >= 0)) then begin FOnProcessMessageReceivedEvent(browser, sourceProcess, message); Result := True;