diff --git a/bin/JSDialog.html b/bin/JSDialog.html new file mode 100644 index 00000000..f1dcbd03 --- /dev/null +++ b/bin/JSDialog.html @@ -0,0 +1,36 @@ + + + + +

The following button shows an alert box.

+ +
+ +

The following button shows an confirm box.

+ +
+ +

The following button shows an Prompt box.

+ +
+ +

+ + + + + \ No newline at end of file diff --git a/demos/CookieVisitor/CookieVisitor.dpr b/demos/CookieVisitor/CookieVisitor.dpr index fb0431b9..85cf9495 100644 --- a/demos/CookieVisitor/CookieVisitor.dpr +++ b/demos/CookieVisitor/CookieVisitor.dpr @@ -48,28 +48,16 @@ uses Windows, {$ENDIF } uCEFApplication, - uCEFMiscFunctions, - uCEFTypes, uCookieVisitor in 'uCookieVisitor.pas' {CookieVisitorFrm}, uSimpleTextViewer in 'uSimpleTextViewer.pas' {SimpleTextViewerFrm}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin - GlobalCEFApp := TCefApplication.Create; + GlobalCEFApp := TCefApplication.Create; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 Application.Initialize; diff --git a/demos/CookieVisitor/uCookieVisitor.pas b/demos/CookieVisitor/uCookieVisitor.pas index e3198245..96ddff7e 100644 --- a/demos/CookieVisitor/uCookieVisitor.pas +++ b/demos/CookieVisitor/uCookieVisitor.pas @@ -85,6 +85,8 @@ type private procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure ShowCookiesMsg(var aMessage : TMessage); message MINIBROWSER_SHOWCOOKIES; @@ -249,4 +251,18 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TCookieVisitorFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TCookieVisitorFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/CustomResourceBrowser/CRBrowser.dpr b/demos/CustomResourceBrowser/CRBrowser.dpr index 66286221..24563517 100644 --- a/demos/CustomResourceBrowser/CRBrowser.dpr +++ b/demos/CustomResourceBrowser/CRBrowser.dpr @@ -41,9 +41,11 @@ program CRBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF } uCEFApplication, uMainForm in 'uMainForm.pas' {MainForm}, @@ -51,22 +53,11 @@ uses {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin GlobalCEFApp := TCefApplication.Create; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 Application.Initialize; diff --git a/demos/CustomResourceBrowser/uMainForm.pas b/demos/CustomResourceBrowser/uMainForm.pas index 3e0d7626..184ab739 100644 --- a/demos/CustomResourceBrowser/uMainForm.pas +++ b/demos/CustomResourceBrowser/uMainForm.pas @@ -66,6 +66,8 @@ type private procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; protected procedure Chromium_OnAfterCreated(Sender: TObject); @@ -83,7 +85,7 @@ implementation {$R *.dfm} uses - uCEFMiscFunctions; + uCEFMiscFunctions, uCEFApplication; procedure TMainForm.Button1Click(Sender: TObject); begin @@ -142,18 +144,28 @@ procedure TMainForm.WMMove(var aMessage : TWMMove); begin inherited; - if (ChromiumWindow1 <> nil) and - (ChromiumWindow1.ChromiumBrowser <> nil) then - ChromiumWindow1.ChromiumBrowser.NotifyMoveOrResizeStarted; + if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; end; procedure TMainForm.WMMoving(var aMessage : TMessage); begin inherited; - if (ChromiumWindow1 <> nil) and - (ChromiumWindow1.ChromiumBrowser <> nil) then - ChromiumWindow1.ChromiumBrowser.NotifyMoveOrResizeStarted; + if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; +end; + +procedure TMainForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TMainForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; end; end. diff --git a/demos/DOMVisitor/DOMVisitor.dpr b/demos/DOMVisitor/DOMVisitor.dpr index 23919814..e267b5ba 100644 --- a/demos/DOMVisitor/DOMVisitor.dpr +++ b/demos/DOMVisitor/DOMVisitor.dpr @@ -43,144 +43,23 @@ uses {$IFDEF DELPHI16_UP} Vcl.Forms, WinApi.Windows, - System.SysUtils, {$ELSE} Forms, Windows, - SysUtils, {$ENDIF } uCEFApplication, - uCEFMiscFunctions, - uCEFSchemeRegistrar, - uCEFRenderProcessHandler, - uCEFv8Handler, - uCEFInterfaces, - uCEFDomVisitor, - uCEFDomNode, - uCEFConstants, uCEFTypes, - uCEFTask, - uCEFProcessMessage, uDOMVisitor in 'uDOMVisitor.pas' {DOMVisitorFrm}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} -procedure SimpleDOMIteration(const aDocument: ICefDomDocument); -var - TempHead, TempChild : ICefDomNode; -begin - try - if (aDocument <> nil) then - begin - TempHead := aDocument.Head; - - if (TempHead <> nil) then - begin - TempChild := TempHead.FirstChild; - - while (TempChild <> nil) do - begin - CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'Head child element : ' + TempChild.Name); - TempChild := TempChild.NextSibling; - end; - end; - end; - except - on e : exception do - if CustomExceptionHandler('SimpleDOMIteration', e) then raise; - end; -end; - -procedure SimpleNodeSearch(const aDocument: ICefDomDocument); -const - NODE_ID = 'lst-ib'; // node found in google.com homepage -var - TempNode : ICefDomNode; -begin - try - if (aDocument <> nil) then - begin - TempNode := aDocument.GetElementById(NODE_ID); - - if (TempNode <> nil) then - CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, NODE_ID + ' element name : ' + TempNode.Name); - - TempNode := aDocument.GetFocusedNode; - - if (TempNode <> nil) then - CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'Focused element name : ' + TempNode.Name); - end; - except - on e : exception do - if CustomExceptionHandler('SimpleNodeSearch', e) then raise; - end; -end; - -procedure DOMVisitor_OnDocAvailable(const browser: ICefBrowser; const document: ICefDomDocument); -var - msg: ICefProcessMessage; -begin - // This function is called from a different process. - // document is only valid inside this function. - // As an example, this function only writes the document title to the 'debug.log' file. - CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'document.Title : ' + document.Title); - - // Simple DOM iteration example - SimpleDOMIteration(document); - - // Simple DOM searches - SimpleNodeSearch(document); - - // Sending back some custom results to the browser process - // Notice that the DOMVISITOR_MSGNAME message name needs to be recognized in - // Chromium1ProcessMessageReceived - msg := TCefProcessMessageRef.New(DOMVISITOR_MSGNAME); - msg.ArgumentList.SetString(0, 'document.Title : ' + document.Title); - browser.SendProcessMessage(PID_BROWSER, msg); -end; - -procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser; - sourceProcess : TCefProcessId; - const message : ICefProcessMessage; - var aHandled : boolean); -var - TempFrame : ICefFrame; - TempVisitor : TCefFastDomVisitor2; -begin - if (browser <> nil) and (message.name = RETRIEVEDOM_MSGNAME) then - begin - TempFrame := browser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCefFastDomVisitor2.Create(browser, DOMVisitor_OnDocAvailable); - TempFrame.VisitDom(TempVisitor); - end; - - aHandled := True; - end - else - aHandled := False; -end; - begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.RemoteDebuggingPort := 9000; GlobalCEFApp.OnProcessMessageReceived := GlobalCEFApp_OnProcessMessageReceived; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - GlobalCEFApp.FrameworkDirPath := 'cef'; - GlobalCEFApp.ResourcesDirPath := 'cef'; - GlobalCEFApp.LocalesDirPath := 'cef\locales'; - GlobalCEFApp.cache := 'cef\cache'; - GlobalCEFApp.cookies := 'cef\cookies'; - GlobalCEFApp.UserDataPath := 'cef\User Data'; -} - // Enabling the debug log file for then DOM visitor demo. // This adds lots of warnings to the console, specially if you run this inside VirtualBox. // Remove it if you don't want to use the DOM visitor diff --git a/demos/DOMVisitor/uDOMVisitor.pas b/demos/DOMVisitor/uDOMVisitor.pas index 04cc7efa..85d478cc 100644 --- a/demos/DOMVisitor/uDOMVisitor.pas +++ b/demos/DOMVisitor/uDOMVisitor.pas @@ -100,12 +100,116 @@ type var DOMVisitorFrm: TDOMVisitorFrm; +procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser; + sourceProcess : TCefProcessId; + const message : ICefProcessMessage; + var aHandled : boolean); + implementation {$R *.dfm} uses - uCEFProcessMessage; + uCEFProcessMessage, uCEFMiscFunctions, uCEFSchemeRegistrar, uCEFRenderProcessHandler, + uCEFv8Handler, uCEFDomVisitor, uCEFDomNode, uCEFTask; + +procedure SimpleDOMIteration(const aDocument: ICefDomDocument); +var + TempHead, TempChild : ICefDomNode; +begin + try + if (aDocument <> nil) then + begin + TempHead := aDocument.Head; + + if (TempHead <> nil) then + begin + TempChild := TempHead.FirstChild; + + while (TempChild <> nil) do + begin + CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'Head child element : ' + TempChild.Name); + TempChild := TempChild.NextSibling; + end; + end; + end; + except + on e : exception do + if CustomExceptionHandler('SimpleDOMIteration', e) then raise; + end; +end; + +procedure SimpleNodeSearch(const aDocument: ICefDomDocument); +const + NODE_ID = 'lst-ib'; // node found in google.com homepage +var + TempNode : ICefDomNode; +begin + try + if (aDocument <> nil) then + begin + TempNode := aDocument.GetElementById(NODE_ID); + + if (TempNode <> nil) then + CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, NODE_ID + ' element name : ' + TempNode.Name); + + TempNode := aDocument.GetFocusedNode; + + if (TempNode <> nil) then + CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'Focused element name : ' + TempNode.Name); + end; + except + on e : exception do + if CustomExceptionHandler('SimpleNodeSearch', e) then raise; + end; +end; + +procedure DOMVisitor_OnDocAvailable(const browser: ICefBrowser; const document: ICefDomDocument); +var + msg: ICefProcessMessage; +begin + // This function is called from a different process. + // document is only valid inside this function. + // As an example, this function only writes the document title to the 'debug.log' file. + CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_ERROR, 'document.Title : ' + document.Title); + + // Simple DOM iteration example + SimpleDOMIteration(document); + + // Simple DOM searches + SimpleNodeSearch(document); + + // Sending back some custom results to the browser process + // Notice that the DOMVISITOR_MSGNAME message name needs to be recognized in + // Chromium1ProcessMessageReceived + msg := TCefProcessMessageRef.New(DOMVISITOR_MSGNAME); + msg.ArgumentList.SetString(0, 'document.Title : ' + document.Title); + browser.SendProcessMessage(PID_BROWSER, msg); +end; + +procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser; + sourceProcess : TCefProcessId; + const message : ICefProcessMessage; + var aHandled : boolean); +var + TempFrame : ICefFrame; + TempVisitor : TCefFastDomVisitor2; +begin + if (browser <> nil) and (message.name = RETRIEVEDOM_MSGNAME) then + begin + TempFrame := browser.MainFrame; + + if (TempFrame <> nil) then + begin + TempVisitor := TCefFastDomVisitor2.Create(browser, DOMVisitor_OnDocAvailable); + TempFrame.VisitDom(TempVisitor); + end; + + aHandled := True; + end + else + aHandled := False; +end; procedure TDOMVisitorFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); begin diff --git a/demos/FullScreenBrowser/FullScreenBrowser.dpr b/demos/FullScreenBrowser/FullScreenBrowser.dpr index 939e5231..14ffac08 100644 --- a/demos/FullScreenBrowser/FullScreenBrowser.dpr +++ b/demos/FullScreenBrowser/FullScreenBrowser.dpr @@ -41,32 +41,23 @@ program FullScreenBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF } uCEFApplication, uMainForm in 'uMainForm.pas' {MainForm}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.FlashEnabled := False; - GlobalCEFApp.FastUnload := True; // Enable the fast unload controller, which speeds up tab/window close by running a tab's onunload js handler independently of the GUI - - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - GlobalCEFApp.FrameworkDirPath := 'cef'; - GlobalCEFApp.ResourcesDirPath := 'cef'; - GlobalCEFApp.LocalesDirPath := 'cef\locales'; - GlobalCEFApp.cache := 'cef\cache'; - GlobalCEFApp.cookies := 'cef\cookies'; - GlobalCEFApp.UserDataPath := 'cef\User Data'; -} + GlobalCEFApp.FastUnload := True; if GlobalCEFApp.StartMainProcess then begin diff --git a/demos/FullScreenBrowser/uMainForm.pas b/demos/FullScreenBrowser/uMainForm.pas index 080fda7f..c08766a5 100644 --- a/demos/FullScreenBrowser/uMainForm.pas +++ b/demos/FullScreenBrowser/uMainForm.pas @@ -71,6 +71,8 @@ type protected procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure HandleKeyUp(const aMsg : TMsg; var aHandled : boolean); @@ -86,6 +88,9 @@ implementation {$R *.dfm} +uses + uCEFApplication; + procedure TMainForm.HandleKeyUp(const aMsg : TMsg; var aHandled : boolean); var TempMessage : TMessage; @@ -195,4 +200,18 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TMainForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TMainForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/Geolocation/Geolocation.dpr b/demos/Geolocation/Geolocation.dpr index a3d60c80..914a7ea9 100644 --- a/demos/Geolocation/Geolocation.dpr +++ b/demos/Geolocation/Geolocation.dpr @@ -41,55 +41,24 @@ program Geolocation; uses {$IFDEF DELPHI16_UP} - WinApi.Windows, Vcl.Forms, + WinApi.Windows, {$ELSE} Forms, Windows, {$ENDIF } uCEFApplication, - uCEFMiscFunctions, - uCEFTypes, uGeolocation in 'uGeolocation.pas' {GeolocationFrm}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} - -procedure GeoLocationUpdate(const position: PCefGeoposition); begin - GlobalPosition.latitude := position.latitude; - GlobalPosition.longitude := position.longitude; - GlobalPosition.altitude := position.altitude; - GlobalPosition.accuracy := position.accuracy; - GlobalPosition.altitude_accuracy := position.altitude_accuracy; - GlobalPosition.heading := position.heading; - GlobalPosition.speed := position.speed; - GlobalPosition.timestamp := position.timestamp; - GlobalPosition.error_code := position.error_code; - GlobalPosition.error_message := position.error_message; + GlobalCEFApp := TCefApplication.Create; - PostMessage(Application.MainForm.Handle, MINIBROWSER_NEWLOCATION, 0, 0); -end; - -begin - GlobalCEFApp := TCefApplication.Create; - - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 - CefGetGeolocation(GeoLocationUpdate); - Application.Initialize; {$IFDEF DELPHI11_UP} Application.MainFormOnTaskbar := True; diff --git a/demos/Geolocation/uGeolocation.dfm b/demos/Geolocation/uGeolocation.dfm index b7055f94..71e8e8d8 100644 --- a/demos/Geolocation/uGeolocation.dfm +++ b/demos/Geolocation/uGeolocation.dfm @@ -12,6 +12,7 @@ object GeolocationFrm: TGeolocationFrm Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnCreate = FormCreate OnShow = FormShow PixelsPerInch = 96 TextHeight = 13 diff --git a/demos/Geolocation/uGeolocation.pas b/demos/Geolocation/uGeolocation.pas index b67b906d..a605e0dc 100644 --- a/demos/Geolocation/uGeolocation.pas +++ b/demos/Geolocation/uGeolocation.pas @@ -68,11 +68,14 @@ type procedure GoBtnClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure Timer1Timer(Sender: TObject); + procedure FormCreate(Sender: TObject); protected procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure NewLocationMsg(var aMessage : TMessage); message MINIBROWSER_NEWLOCATION; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; end; var @@ -83,11 +86,35 @@ implementation {$R *.dfm} +uses + uCEFMiscFunctions; + +procedure GeoLocationUpdate(const position: PCefGeoposition); +begin + GlobalPosition.latitude := position.latitude; + GlobalPosition.longitude := position.longitude; + GlobalPosition.altitude := position.altitude; + GlobalPosition.accuracy := position.accuracy; + GlobalPosition.altitude_accuracy := position.altitude_accuracy; + GlobalPosition.heading := position.heading; + GlobalPosition.speed := position.speed; + GlobalPosition.timestamp := position.timestamp; + GlobalPosition.error_code := position.error_code; + GlobalPosition.error_message := position.error_message; + + PostMessage(GeolocationFrm.Handle, MINIBROWSER_NEWLOCATION, 0, 0); +end; + procedure TGeolocationFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); begin PostMessage(Handle, CEF_AFTERCREATED, 0, 0); end; +procedure TGeolocationFrm.FormCreate(Sender: TObject); +begin + CefGetGeolocation(GeoLocationUpdate); +end; + procedure TGeolocationFrm.FormShow(Sender: TObject); begin // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser @@ -135,4 +162,18 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TGeolocationFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TGeolocationFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/JavaScript/JSDialog/00-DeleteDCUs.bat b/demos/JavaScript/JSDialog/00-DeleteDCUs.bat new file mode 100644 index 00000000..dbd008bc --- /dev/null +++ b/demos/JavaScript/JSDialog/00-DeleteDCUs.bat @@ -0,0 +1,14 @@ +del /s /q *.dcu +del /s /q *.exe +del /s /q *.res +del /s /q *.log +del /s /q *.dsk +del /s /q *.identcache +del /s /q *.stat +del /s /q *.local +del /s /q *.~* +rmdir Win32\Debug +rmdir Win32\Release +rmdir Win32 +rmdir __history +rmdir __recovery diff --git a/demos/JavaScript/JSDialog/JSDialogBrowser.dpr b/demos/JavaScript/JSDialog/JSDialogBrowser.dpr new file mode 100644 index 00000000..d8aba815 --- /dev/null +++ b/demos/JavaScript/JSDialog/JSDialogBrowser.dpr @@ -0,0 +1,71 @@ +// ************************************************************************ +// ***************************** 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. + * + *) + +program JSDialogBrowser; + +{$I cef.inc} + +uses + {$IFDEF DELPHI16_UP} + Vcl.Forms, + WinApi.Windows, + {$ELSE} + Forms, + Windows, + {$ENDIF } + uCEFApplication, + uJSDialogBrowser in 'uJSDialogBrowser.pas' {JSDialogBrowserFrm}; + +{$R *.res} + +{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} + +begin + GlobalCEFApp := TCefApplication.Create; + + if GlobalCEFApp.StartMainProcess then + begin + Application.Initialize; + {$IFDEF DELPHI11_UP} + Application.MainFormOnTaskbar := True; + {$ENDIF} + Application.CreateForm(TJSDialogBrowserFrm, JSDialogBrowserFrm); + Application.Run; + end; + + GlobalCEFApp.Free; +end. diff --git a/demos/JavaScript/JSDialog/JSDialogBrowser.dproj b/demos/JavaScript/JSDialog/JSDialogBrowser.dproj new file mode 100644 index 00000000..0c308d3f --- /dev/null +++ b/demos/JavaScript/JSDialog/JSDialogBrowser.dproj @@ -0,0 +1,597 @@ + + + {55E00327-9D98-4DA3-A4E1-844942A01C6B} + 18.2 + VCL + JSDialogBrowser.dpr + True + Debug + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + true + Cfg_2 + true + true + + + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= + 3082 + JSDialogBrowser + $(BDS)\bin\delphi_PROJECTICON.ico + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + .\$(Platform)\$(Config) + false + false + false + false + false + + + DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;frxe23;vclFireDAC;emsclientfiredac;DataSnapFireDAC;svnui;tethering;Componentes;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;Intraweb;DBXOracleDriver;inetdb;Componentes_Int;CEF4Delphi;FmxTeeUI;FireDACIBDriver;fmx;fmxdae;vclib;FireDACDBXDriver;dbexpress;IndyProtocols230;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;frxTee23;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;CloudService;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;vcl;DBXSybaseASEDriver;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;Componentes_UI;TeeDB;FireDAC;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;Componentes_Misc;ibxpress;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;ibxbindings;rtl;FireDACDSDriver;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;Componentes_RTF;DBXInformixDriver;bindcompvcl;frxDB23;Componentes_vCard;TeeUI;IndyCore230;vclribbon;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;IndySystem230;dsnapxml;DataSnapProviderClient;dbrtl;inetdbxpress;FireDACMongoDBDriver;frx23;fmxase;$(DCC_UsePackage) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + true + $(BDS)\bin\default_app.manifest + 1033 + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + ..\..\..\bin + + + DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;DataSnapFireDAC;tethering;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;Intraweb;DBXOracleDriver;inetdb;FmxTeeUI;FireDACIBDriver;fmx;fmxdae;vclib;FireDACDBXDriver;dbexpress;IndyProtocols230;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;CloudService;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;vcl;DBXSybaseASEDriver;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;ibxbindings;rtl;FireDACDSDriver;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;bindcompvcl;TeeUI;IndyCore230;vclribbon;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;IndySystem230;dsnapxml;DataSnapProviderClient;dbrtl;inetdbxpress;FireDACMongoDBDriver;fmxase;$(DCC_UsePackage) + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\default_app.manifest + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + true + 1033 + true + true + false + Debug + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + + + true + true + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + true + + + true + true + + + + MainSource + + +
JSDialogBrowserFrm
+
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Application + + + + JSDialogBrowser.dpr + + + IP Abstraction Indy Implementation Design Time + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + JSDialogBrowser.exe + true + + + + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 0 + + + + + classes + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + + + res\values + 1 + + + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + 1 + + + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\ + 1 + + + + + Contents + 1 + + + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/demos/JavaScript/JSDialog/cef.inc b/demos/JavaScript/JSDialog/cef.inc new file mode 100644 index 00000000..984ae795 --- /dev/null +++ b/demos/JavaScript/JSDialog/cef.inc @@ -0,0 +1,384 @@ +// ************************************************************************ +// ***************************** 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. + * + *) + + // The complete list of compiler versions is here : + // http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions + +{$DEFINE DELPHI_VERSION_UNKNOW} + +{$IFDEF FPC} + {$DEFINE CEF_MULTI_THREADED_MESSAGE_LOOP} + {$DEFINE SUPPORTS_INLINE} +{$ENDIF} + +// Delphi 5 +{$IFDEF VER130} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} +{$ENDIF} + +// Delphi 6 +{$IFDEF VER140} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} +{$ENDIF} + +// Delphi 7 +{$IFDEF VER150} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} +{$ENDIF} + +// Delphi 8 +{$IFDEF VER160} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} +{$ENDIF} + +// Delphi 2005 +{$IFDEF VER170} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} +{$ENDIF} + +{$IFDEF VER180} + {$UNDEF DELPHI_VERSION_UNKNOW} + // Delphi 2007 + {$IFDEF VER185} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + // Delphi 2006 + {$ELSE} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$ENDIF} +{$ENDIF} + +// Delphi 2009 +{$IFDEF VER200} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} +{$ENDIF} + +//Delphi 2010 +{$IFDEF VER210} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} +{$ENDIF} + +// Delphi XE +{$IFDEF VER220} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} +{$ENDIF} + +// Delphi XE2 +{$IFDEF VER230} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} +{$ENDIF} + +// Delphi XE3 +{$IFDEF VER240} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} +{$ENDIF} + +// Delphi XE4 +{$IFDEF VER250} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} +{$ENDIF} + +// Delphi XE5 +{$IFDEF VER260} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} +{$ENDIF} + +// Delphi XE6 +{$IFDEF VER270} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} +{$ENDIF} + +// Delphi XE7 +{$IFDEF VER280} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} +{$ENDIF} + +// Delphi XE8 +{$IFDEF VER290} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} +{$ENDIF VER290} + +// Rad Studio 10 - Delphi Seattle +{$IFDEF VER300} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} +{$ENDIF} + +// Rad Studio 10.1 - Delphi Berlin +{$IFDEF VER310} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} +{$ENDIF} + +// Rad Studio 10.2 - Delphi Tokyo +{$IFDEF VER320} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} +{$ENDIF} + + +{$IFDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} +{$ENDIF} + +{$IFDEF DELPHI9_UP} + {$DEFINE SUPPORTS_INLINE} +{$ENDIF} + diff --git a/demos/JavaScript/JSDialog/uJSDialogBrowser.dfm b/demos/JavaScript/JSDialog/uJSDialogBrowser.dfm new file mode 100644 index 00000000..5b7e3d4d --- /dev/null +++ b/demos/JavaScript/JSDialog/uJSDialogBrowser.dfm @@ -0,0 +1,73 @@ +object JSDialogBrowserFrm: TJSDialogBrowserFrm + Left = 0 + Top = 0 + Caption = 'Initializing browser. Please wait...' + ClientHeight = 624 + ClientWidth = 1038 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + OnCreate = FormCreate + OnDestroy = FormDestroy + OnShow = FormShow + PixelsPerInch = 96 + TextHeight = 13 + object ChromiumWindow1: TChromiumWindow + Left = 0 + Top = 30 + Width = 1038 + Height = 594 + Align = alClient + TabOrder = 0 + OnAfterCreated = ChromiumWindow1AfterCreated + end + object AddressPnl: TPanel + Left = 0 + Top = 0 + Width = 1038 + Height = 30 + Align = alTop + BevelOuter = bvNone + Enabled = False + Padding.Left = 5 + Padding.Top = 5 + Padding.Right = 5 + Padding.Bottom = 5 + ShowCaption = False + TabOrder = 1 + object AddressEdt: TEdit + Left = 5 + Top = 5 + Width = 997 + Height = 20 + Margins.Right = 5 + Align = alClient + TabOrder = 0 + Text = 'file:///JSDialog.html' + ExplicitHeight = 21 + end + object GoBtn: TButton + Left = 1002 + Top = 5 + Width = 31 + Height = 20 + Margins.Left = 5 + Align = alRight + Caption = 'Go' + TabOrder = 1 + OnClick = GoBtnClick + end + end + object Timer1: TTimer + Enabled = False + Interval = 300 + OnTimer = Timer1Timer + Left = 56 + Top = 88 + end +end diff --git a/demos/JavaScript/JSDialog/uJSDialogBrowser.pas b/demos/JavaScript/JSDialog/uJSDialogBrowser.pas new file mode 100644 index 00000000..4173d250 --- /dev/null +++ b/demos/JavaScript/JSDialog/uJSDialogBrowser.pas @@ -0,0 +1,241 @@ +// ************************************************************************ +// ***************************** 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 uJSDialogBrowser; + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, System.SyncObjs, + {$ELSE} + Windows, Messages, SysUtils, Variants, Classes, Graphics, + Controls, Forms, Dialogs, StdCtrls, ExtCtrls, SyncObjs, + {$ENDIF} + uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFInterfaces, uCEFTypes, uCEFConstants; + +const + CEFBROWSER_SHOWJSDIALOG = WM_APP + $101; + +type + TJSDialogBrowserFrm = class(TForm) + ChromiumWindow1: TChromiumWindow; + AddressPnl: TPanel; + AddressEdt: TEdit; + GoBtn: TButton; + Timer1: TTimer; + procedure GoBtnClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure ChromiumWindow1AfterCreated(Sender: TObject); + procedure Timer1Timer(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + + protected + FJSDialogInfoCS : TCriticalSection; + FOriginUrl : ustring; + FMessageText : ustring; + FDefaultPromptText : ustring; + FPendingDlg : boolean; + FDialogType : TCefJsDialogType; + FCallback : ICefJsDialogCallback; + + procedure ChromiumBrowser_OnJsdialog(Sender: TObject; const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean; out Result: Boolean); + + procedure WMMove(var aMessage : TWMMove); message WM_MOVE; + procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; + procedure ShowJSDialogMsg(var aMessage: TMessage); message CEFBROWSER_SHOWJSDIALOG; + + end; + +var + JSDialogBrowserFrm: TJSDialogBrowserFrm; + +implementation + +{$R *.dfm} + +uses + uCEFApplication; + +// This is a demo with custom JS dialogs + +procedure TJSDialogBrowserFrm.FormCreate(Sender: TObject); +begin + FJSDialogInfoCS := TCriticalSection.Create; + FOriginUrl := ''; + FMessageText := ''; + FDefaultPromptText := ''; + FPendingDlg := False; + FDialogType := JSDIALOGTYPE_ALERT; + FCallback := nil; +end; + +procedure TJSDialogBrowserFrm.FormDestroy(Sender: TObject); +begin + FreeAndNil(FJSDialogInfoCS); + FCallback := nil; +end; + +procedure TJSDialogBrowserFrm.FormShow(Sender: TObject); +begin + ChromiumWindow1.ChromiumBrowser.OnJsdialog := ChromiumBrowser_OnJsdialog; + + // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser + // If it's not initialized yet, we use a simple timer to create the browser later. + if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True; +end; + +procedure TJSDialogBrowserFrm.ChromiumWindow1AfterCreated(Sender: TObject); +begin + Caption := 'JS Dialog Browser'; + AddressPnl.Enabled := True; + GoBtn.Click; +end; + +procedure TJSDialogBrowserFrm.GoBtnClick(Sender: TObject); +begin + ChromiumWindow1.LoadURL(AddressEdt.Text); +end; + +procedure TJSDialogBrowserFrm.Timer1Timer(Sender: TObject); +begin + Timer1.Enabled := False; + if not(ChromiumWindow1.CreateBrowser) and not(ChromiumWindow1.Initialized) then + Timer1.Enabled := True; +end; + +procedure TJSDialogBrowserFrm.WMMove(var aMessage : TWMMove); +begin + inherited; + + if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; +end; + +procedure TJSDialogBrowserFrm.WMMoving(var aMessage : TMessage); +begin + inherited; + + if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; +end; + +procedure TJSDialogBrowserFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSDialogBrowserFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + +procedure TJSDialogBrowserFrm.ChromiumBrowser_OnJsdialog(Sender : TObject; + const browser : ICefBrowser; + const originUrl : ustring; + dialogType : TCefJsDialogType; + const messageText : ustring; + const defaultPromptText : ustring; + const callback : ICefJsDialogCallback; + out suppressMessage : Boolean; + out Result : Boolean); +begin + // In this event we must store the dialog information and post a message to the main form to show the dialog + + FJSDialogInfoCS.Acquire; + + if FPendingDlg then + begin + Result := False; + suppressMessage := True; + end + else + begin + FOriginUrl := originUrl; + FMessageText := messageText; + FDefaultPromptText := defaultPromptText; + FDialogType := dialogType; + FCallback := callback; + FPendingDlg := True; + Result := True; + suppressMessage := False; + + PostMessage(Handle, CEFBROWSER_SHOWJSDIALOG, 0, 0); + end; + + FJSDialogInfoCS.Release; +end; + +procedure TJSDialogBrowserFrm.ShowJSDialogMsg(var aMessage: TMessage); +var + TempCaption : string; +begin + // Here we show the dialog and reset the information. + // showmessage, MessageDlg and InputBox should be replaced by nicer custom forms with the same functionality. + + FJSDialogInfoCS.Acquire; + + if FPendingDlg then + begin + TempCaption := 'JavaScript message from : ' + FOriginUrl; + + case FDialogType of + JSDIALOGTYPE_ALERT : showmessage(TempCaption + CRLF + CRLF + FMessageText); + JSDIALOGTYPE_CONFIRM : FCallback.cont((MessageDlg(TempCaption + CRLF + CRLF + FMessageText, mtConfirmation, [mbYes, mbNo], 0, mbYes) = mrYes), ''); + JSDIALOGTYPE_PROMPT : FCallback.cont(True, InputBox(TempCaption, FMessageText, FDefaultPromptText)); + end; + end; + + FOriginUrl := ''; + FMessageText := ''; + FDefaultPromptText := ''; + FPendingDlg := False; + FDialogType := JSDIALOGTYPE_ALERT; + FCallback := nil; + + FJSDialogInfoCS.Release; +end; + +end. diff --git a/demos/JavaScript/JSEval/uJSEval.pas b/demos/JavaScript/JSEval/uJSEval.pas index 610923f7..9276cea8 100644 --- a/demos/JavaScript/JSEval/uJSEval.pas +++ b/demos/JavaScript/JSEval/uJSEval.pas @@ -99,6 +99,8 @@ type procedure EvalJSBinParamMsg(var aMessage : TMessage); message MINIBROWSER_JSBINPARAM; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; procedure ParseEvalJsAnswer(const pMessage: ICefProcessMessage; pBrowser: ICefBrowser; pReturnValue : ICefv8Value; pException : ICefV8Exception); procedure ParseBinaryValue(const pBrowser : ICefBrowser; const aBinaryValue : ICefBinaryValue); @@ -235,6 +237,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TJSEvalFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSEvalFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TJSEvalFrm.EvalJSCodeMsg(var aMessage : TMessage); var TempMsg : ICefProcessMessage; diff --git a/demos/JavaScript/JSExecutingFunctions/uJSExecutingFunctions.pas b/demos/JavaScript/JSExecutingFunctions/uJSExecutingFunctions.pas index 30d8b8c0..83f580f0 100644 --- a/demos/JavaScript/JSExecutingFunctions/uJSExecutingFunctions.pas +++ b/demos/JavaScript/JSExecutingFunctions/uJSExecutingFunctions.pas @@ -80,6 +80,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -201,6 +203,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TJSExecutingFunctionsFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSExecutingFunctionsFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TJSExecutingFunctionsFrm.Timer1Timer(Sender: TObject); begin Timer1.Enabled := False; diff --git a/demos/JavaScript/JSExtension/uJSExtension.pas b/demos/JavaScript/JSExtension/uJSExtension.pas index 7d9fb6b7..6715eec2 100644 --- a/demos/JavaScript/JSExtension/uJSExtension.pas +++ b/demos/JavaScript/JSExtension/uJSExtension.pas @@ -90,6 +90,8 @@ type procedure ShowTextViewerMsg(var aMessage : TMessage); message MINIBROWSER_SHOWTEXTVIEWER; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -257,6 +259,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TJSExtensionFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSExtensionFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TJSExtensionFrm.ShowTextViewerMsg(var aMessage : TMessage); begin // This form will show the HTML received from JavaScript diff --git a/demos/JavaScript/JSExtensionWithFunction/uJSExtensionWithFunction.pas b/demos/JavaScript/JSExtensionWithFunction/uJSExtensionWithFunction.pas index 14ab5f48..414bc6b8 100644 --- a/demos/JavaScript/JSExtensionWithFunction/uJSExtensionWithFunction.pas +++ b/demos/JavaScript/JSExtensionWithFunction/uJSExtensionWithFunction.pas @@ -67,6 +67,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -158,4 +160,18 @@ begin GoBtn.Click; end; +procedure TJSExtensionWithFunctionFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSExtensionWithFunctionFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/JavaScript/JSExtensionWithObjectParameter/uJSExtensionWithObjectParameter.pas b/demos/JavaScript/JSExtensionWithObjectParameter/uJSExtensionWithObjectParameter.pas index d64dbce4..a7ad468f 100644 --- a/demos/JavaScript/JSExtensionWithObjectParameter/uJSExtensionWithObjectParameter.pas +++ b/demos/JavaScript/JSExtensionWithObjectParameter/uJSExtensionWithObjectParameter.pas @@ -67,6 +67,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -150,6 +152,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TJSExtensionWithObjectParameterFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSExtensionWithObjectParameterFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TJSExtensionWithObjectParameterFrm.Timer1Timer(Sender: TObject); begin Timer1.Enabled := False; diff --git a/demos/JavaScript/JSSimpleExtension/uJSSimpleExtension.pas b/demos/JavaScript/JSSimpleExtension/uJSSimpleExtension.pas index 77295a3b..fad51213 100644 --- a/demos/JavaScript/JSSimpleExtension/uJSSimpleExtension.pas +++ b/demos/JavaScript/JSSimpleExtension/uJSSimpleExtension.pas @@ -67,6 +67,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -152,4 +154,18 @@ begin GoBtn.Click; end; +procedure TJSSimpleExtensionFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSSimpleExtensionFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/JavaScript/JSSimpleWindowBinding/uJSSimpleWindowBinding.pas b/demos/JavaScript/JSSimpleWindowBinding/uJSSimpleWindowBinding.pas index 5d62479d..66adc569 100644 --- a/demos/JavaScript/JSSimpleWindowBinding/uJSSimpleWindowBinding.pas +++ b/demos/JavaScript/JSSimpleWindowBinding/uJSSimpleWindowBinding.pas @@ -68,6 +68,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -145,4 +147,18 @@ begin GoBtn.Click; end; +procedure TJSSimpleWindowBindingFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSSimpleWindowBindingFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/JavaScript/JSWindowBindingWithFunction/uJSWindowBindingWithFunction.pas b/demos/JavaScript/JSWindowBindingWithFunction/uJSWindowBindingWithFunction.pas index d9db1ddd..8c99489c 100644 --- a/demos/JavaScript/JSWindowBindingWithFunction/uJSWindowBindingWithFunction.pas +++ b/demos/JavaScript/JSWindowBindingWithFunction/uJSWindowBindingWithFunction.pas @@ -67,6 +67,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -149,4 +151,18 @@ begin GoBtn.Click; end; +procedure TJSWindowBindingWithFunctionFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSWindowBindingWithFunctionFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/JavaScript/JSWindowBindingWithObject/uJSWindowBindingWithObject.pas b/demos/JavaScript/JSWindowBindingWithObject/uJSWindowBindingWithObject.pas index 862a4974..b4a90657 100644 --- a/demos/JavaScript/JSWindowBindingWithObject/uJSWindowBindingWithObject.pas +++ b/demos/JavaScript/JSWindowBindingWithObject/uJSWindowBindingWithObject.pas @@ -67,6 +67,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -150,4 +152,18 @@ begin GoBtn.Click; end; +procedure TJSWindowBindingWithObjectFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TJSWindowBindingWithObjectFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/MDIBrowser/MDIBrowser.dpr b/demos/MDIBrowser/MDIBrowser.dpr index 4275d830..60162161 100644 --- a/demos/MDIBrowser/MDIBrowser.dpr +++ b/demos/MDIBrowser/MDIBrowser.dpr @@ -41,9 +41,11 @@ program MDIBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF } uCEFApplication, uMainForm in 'uMainForm.pas' {MainForm}, @@ -51,7 +53,6 @@ uses {$R *.RES} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin @@ -60,16 +61,6 @@ begin GlobalCEFApp.FastUnload := True; GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 Application.Initialize; diff --git a/demos/MDIBrowser/uChildForm.dfm b/demos/MDIBrowser/uChildForm.dfm index 0c47b0a6..45ec74d5 100644 --- a/demos/MDIBrowser/uChildForm.dfm +++ b/demos/MDIBrowser/uChildForm.dfm @@ -61,7 +61,6 @@ object ChildForm: TChildForm Height = 402 Align = alClient TabOrder = 1 - ExplicitHeight = 421 end object StatusBar1: TStatusBar Left = 0 @@ -75,9 +74,6 @@ object ChildForm: TChildForm item Width = 500 end> - ExplicitLeft = 360 - ExplicitTop = 424 - ExplicitWidth = 0 end object Chromium1: TChromium OnLoadingStateChange = Chromium1LoadingStateChange diff --git a/demos/MDIBrowser/uChildForm.pas b/demos/MDIBrowser/uChildForm.pas index 95c5274b..5791e508 100644 --- a/demos/MDIBrowser/uChildForm.pas +++ b/demos/MDIBrowser/uChildForm.pas @@ -87,6 +87,8 @@ type procedure BrowserDestroyMsg(var aMessage : TMessage); message CEFBROWSER_DESTROY; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public property Closing : boolean read FClosing; @@ -103,7 +105,7 @@ implementation // 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form. uses - uCEFRequestContext; + uCEFRequestContext, uCEFApplication; procedure TChildForm.Button1Click(Sender: TObject); begin @@ -210,6 +212,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TChildForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TChildForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TChildForm.BrowserCreatedMsg(var aMessage : TMessage); begin CEFWindowParent1.UpdateSize; diff --git a/demos/MiniBrowser/MiniBrowser.dpr b/demos/MiniBrowser/MiniBrowser.dpr index 0afc8184..9e3a770e 100644 --- a/demos/MiniBrowser/MiniBrowser.dpr +++ b/demos/MiniBrowser/MiniBrowser.dpr @@ -54,32 +54,10 @@ uses {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin - GlobalCEFApp := TCefApplication.Create; - - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - GlobalCEFApp.FrameworkDirPath := 'cef'; - GlobalCEFApp.ResourcesDirPath := 'cef'; - GlobalCEFApp.LocalesDirPath := 'cef\locales'; - GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration - GlobalCEFApp.DisableGPUCache := True; // Disable the creation of a 'GPUCache' directory in the hard drive. - GlobalCEFApp.cache := 'cef\cache'; - GlobalCEFApp.cookies := 'cef\cookies'; - GlobalCEFApp.UserDataPath := 'cef\User Data'; -} - - // Examples of command line switches. - // ********************************** - // - // Uncomment the following line to see an FPS counter in the browser. - //GlobalCEFApp.AddCustomCommandLine('--show-fps-counter'); - // - // Uncomment the following line to change the user agent string. - //GlobalCEFApp.AddCustomCommandLine('--user-agent', 'MiniBrowser'); + GlobalCEFApp := TCefApplication.Create; if GlobalCEFApp.StartMainProcess then begin diff --git a/demos/MiniBrowser/uMiniBrowser.dfm b/demos/MiniBrowser/uMiniBrowser.dfm index a90018f3..78c39e44 100644 --- a/demos/MiniBrowser/uMiniBrowser.dfm +++ b/demos/MiniBrowser/uMiniBrowser.dfm @@ -132,10 +132,10 @@ object MiniBrowserFrm: TMiniBrowserFrm 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-b' + 'rowser-sending' 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert' 'https://www.w3schools.com/html/html5_video.asp' 'http://www.adobe.com/software/flash/about/' 'http://isflashinstalled.com/' - 'chrome://version/' 'http://html5test.com/' 'https://www.w3schools.com/' 'http://webglsamples.org/' @@ -149,7 +149,23 @@ object MiniBrowserFrm: TMiniBrowserFrm 'https://www.w3schools.com/Tags/tryit.asp?filename=tryhtml_iframe' + '_name' 'https://www.browserleaks.com/webrtc' - 'https://frames-per-second.appspot.com/') + 'https://frames-per-second.appspot.com/' + 'chrome://version/' + 'chrome://net-internals/' + 'chrome://tracing/' + 'chrome://appcache-internals/' + 'chrome://blob-internals/' + 'chrome://view-http-cache/' + 'chrome://credits/' + 'chrome://histograms/' + 'chrome://media-internals/' + 'chrome://kill' + 'chrome://crash' + 'chrome://hang' + 'chrome://shorthang' + 'chrome://gpuclean' + 'chrome://gpucrash' + 'chrome://gpuhang') end end object ConfigPnl: TPanel diff --git a/demos/OSRExternalPumpBrowser/OSRExternalPumpBrowser.dpr b/demos/OSRExternalPumpBrowser/OSRExternalPumpBrowser.dpr index f80de8ae..bf8c368b 100644 --- a/demos/OSRExternalPumpBrowser/OSRExternalPumpBrowser.dpr +++ b/demos/OSRExternalPumpBrowser/OSRExternalPumpBrowser.dpr @@ -83,8 +83,9 @@ begin Application.CreateForm(TOSRExternalPumpBrowserFrm, OSRExternalPumpBrowserFrm); Application.Run; - // Unlike the ExternalPumpBrowser, in OSR mode we don't need to destroy the - // form before stopping the scheduler. + // The form needs to be destroyed *BEFORE* stopping the scheduler. + OSRExternalPumpBrowserFrm.Free; + GlobalCEFWorkScheduler.StopScheduler; end; diff --git a/demos/OSRExternalPumpBrowser/uOSRExternalPumpBrowser.pas b/demos/OSRExternalPumpBrowser/uOSRExternalPumpBrowser.pas index 712aa01f..476a9141 100644 --- a/demos/OSRExternalPumpBrowser/uOSRExternalPumpBrowser.pas +++ b/demos/OSRExternalPumpBrowser/uOSRExternalPumpBrowser.pas @@ -600,6 +600,7 @@ begin if not(FClosing) then begin FClosing := True; + Visible := False; NavControlPnl.Enabled := False; chrmosr.CloseBrowser(True); end; diff --git a/demos/PostDataInspector/PostDataInspector.dpr b/demos/PostDataInspector/PostDataInspector.dpr index 7c736c83..86ceee70 100644 --- a/demos/PostDataInspector/PostDataInspector.dpr +++ b/demos/PostDataInspector/PostDataInspector.dpr @@ -41,65 +41,23 @@ program PostDataInspector; uses {$IFDEF DELPHI16_UP} - WinApi.Windows, Vcl.Forms, - System.SysUtils, + WinApi.Windows, {$ELSE} Forms, Windows, - SysUtils, {$ENDIF } uCEFApplication, - uCEFRenderProcessHandler, - uCEFInterfaces, - uCEFProcessMessage, - uCEFTypes, uPostDataInspector in 'uPostDataInspector.pas' {PostDataInspectorFrm}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} -procedure GlobalCEFApp_OnBeforeNavigation(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - navigationType : TCefNavigationType; - isRedirect : Boolean; - var aStopNavigation : boolean); -var - msg: ICefProcessMessage; - TempString : string; -begin - aStopNavigation := False; - - if (request = nil) then - TempString := 'no request' - else - if (request.postdata = nil) then - TempString := 'no postdata' - else - TempString := 'postdata elements : ' + inttostr(request.postdata.GetCount); - - msg := TCefProcessMessageRef.New(POSTDATA_MSGNAME); - msg.ArgumentList.SetString(0, TempString); - browser.SendProcessMessage(PID_BROWSER, msg); -end; - begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.OnBeforeNavigation := GlobalCEFApp_OnBeforeNavigation; - // 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 Application.Initialize; diff --git a/demos/PostDataInspector/PostDataInspector.dproj.local b/demos/PostDataInspector/PostDataInspector.dproj.local deleted file mode 100644 index b3811b7e..00000000 --- a/demos/PostDataInspector/PostDataInspector.dproj.local +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/demos/PostDataInspector/PostDataInspector.dsk b/demos/PostDataInspector/PostDataInspector.dsk deleted file mode 100644 index 3fad3990..00000000 --- a/demos/PostDataInspector/PostDataInspector.dsk +++ /dev/null @@ -1,812 +0,0 @@ -[Closed Files] -File_0=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFApplication.pas',0,1,1150,3,1179,0,0,,{1 -File_1=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFMiscFunctions.pas',0,1,63,11,90,0,0,, -File_2=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Componentes\cache\uBookmarksDBThread.pas',0,1,843,59,875,0,0,, -File_3=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Componentes\base_components\uWebPanel.pas',0,1,893,80,917,0,0,, -File_4=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\BriskBard\uBriskBardMainForm.pas',0,1,1,1,1,0,0,, -File_5=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Componentes\cache\uDatabaseThread.pas',0,1,643,1,665,0,0,, -File_6=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\Componentes\cache\uDownloadManager.pas',0,1,3021,63,3055,0,0,, -File_7=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\source\rtl\common\System.Classes.pas',0,1,9322,1,9344,0,0,, -File_8=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\SOURCE\VCL\Vcl.Controls.pas',0,1,12377,1,12401,0,0,, - -[Modules] -Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas -Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas -Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\PostDataInspector.dproj -Module3=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\uPostDataInspector.pas -Module4=default.htm -Count=5 -EditWindowCount=1 - -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas] -ModuleType=TSourceModule - -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas] -ModuleType=TSourceModule - -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\PostDataInspector.dproj] -ModuleType=TBaseProject - -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\uPostDataInspector.pas] -ModuleType=TSourceModule - -[default.htm] -ModuleType=TURLModule - -[EditWindow0] -ViewCount=5 -CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas -View0=0 -View1=1 -View2=2 -View3=3 -View4=4 -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=10000 -Height=9423 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=10000 -ClientHeight=9423 -DockedToMainForm=1 -BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 -TopPanelSize=0 -LeftPanelSize=0 -RightPanelSize=2000 -RightPanelClients=DockSite2 -RightPanelData=00000800010100000000E91900000000000001D00700000000000001000000009F23000009000000446F636B5369746532FFFFFFFF -BottomPanelSize=0 -BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1234000000000000022006000000000000FFFFFFFF -BottomMiddlePanelSize=0 -BottomMiddlePanelClients=DockSite0,GraphDrawingModel -BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779F1D00000000000002F706000000000000FFFFFFFF -TabDockLeftClients=PropertyInspector=0,DockSite3=1 -TabDockRightClients=DockSite4=0 - -[View0] -CustomEditViewType=TWelcomePageView -WelcomePageURL=bds:/default.htm - -[View1] -CustomEditViewType=TEditView -Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\uPostDataInspector.pas -CursorX=1 -CursorY=1 -TopLine=1 -LeftCol=1 -Bookmarks= -EditViewName=Borland.FormDesignerView - -[View2] -CustomEditViewType=TEditView -Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\PostDataInspector.dpr -CursorX=42 -CursorY=64 -TopLine=37 -LeftCol=1 -Bookmarks= -EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\PostDataInspector\PostDataInspector.dpr - -[View3] -CustomEditViewType=TEditView -Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFInterfaces.pas -CursorX=40 -CursorY=293 -TopLine=261 -LeftCol=1 -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\source\uCEFTypes.pas -CursorX=3 -CursorY=443 -TopLine=414 -LeftCol=1 -Bookmarks= -EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFTypes.pas - -[UndockedDesigner] -Count=0 - -[Watches] -Count=0 - -[WatchWindow] -WatchColumnWidth=120 -WatchShowColumnHeaders=1 -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1143 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1143 -TBDockHeight=211 -LRDockWidth=13602 -Dockable=1 -StayOnTop=0 - -[Breakpoints] -Count=0 - -[EmbarcaderoWin32Debugger_AddressBreakpoints] -Count=0 - -[EmbarcaderoWin64Debugger_AddressBreakpoints] -Count=0 - -[Main Window] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=0 -State=2 -Left=148 -Top=277 -Width=8930 -Height=8524 -MaxLeft=-8 -MaxTop=-11 -MaxWidth=8930 -MaxHeight=8524 -ClientWidth=10000 -ClientHeight=9756 -BottomPanelSize=9119 -BottomPanelClients=EditWindow0 -BottomPanelData=0000080000000000000000000000000000000000000000000000000100000000000000000C0000004564697457696E646F775F30FFFFFFFF - -[ProjectManager] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2000 -Height=8946 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=8946 -TBDockHeight=5905 -LRDockWidth=2352 -Dockable=1 -StayOnTop=0 - -[MessageView] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2773 -Height=1421 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2773 -ClientHeight=1421 -TBDockHeight=1421 -LRDockWidth=2773 -Dockable=1 -StayOnTop=0 - -[ToolForm] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2000 -Height=4384 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=4384 -TBDockHeight=7148 -LRDockWidth=2000 -Dockable=1 -StayOnTop=0 - -[ClipboardHistory] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=0 -State=0 -Left=0 -Top=0 -Width=1906 -Height=4939 -MaxLeft=-8 -MaxTop=-11 -ClientWidth=1781 -ClientHeight=4517 -TBDockHeight=4939 -LRDockWidth=1906 -Dockable=1 -StayOnTop=0 - -[ProjectStatistics] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=0 -State=0 -Left=0 -Top=0 -Width=2062 -Height=5683 -MaxLeft=-8 -MaxTop=-11 -ClientWidth=1938 -ClientHeight=5261 -TBDockHeight=5683 -LRDockWidth=2062 -Dockable=1 -StayOnTop=0 - -[ClassBrowserTool] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=-148 -Top=-133 -Width=1844 -Height=3141 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=1844 -ClientHeight=3141 -TBDockHeight=3141 -LRDockWidth=1844 -Dockable=1 -StayOnTop=0 - -[MetricsView] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1199 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1199 -TBDockHeight=4839 -LRDockWidth=3562 -Dockable=1 -StayOnTop=0 - -[QAView] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1199 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1199 -TBDockHeight=4839 -LRDockWidth=3562 -Dockable=1 -StayOnTop=0 - -[PropertyInspector] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=360 -Width=1898 -Height=5427 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=1898 -ClientHeight=5427 -TBDockHeight=7236 -LRDockWidth=1898 -Dockable=1 -StayOnTop=0 -SplitPos=111 - -[frmDesignPreview] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2000 -Height=6959 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=6959 -TBDockHeight=5960 -LRDockWidth=2508 -Dockable=1 -StayOnTop=0 - -[TFileExplorerForm] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=-898 -Top=-133 -Width=2844 -Height=6204 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2844 -ClientHeight=6204 -TBDockHeight=6204 -LRDockWidth=2844 -Dockable=1 -StayOnTop=0 - -[TemplateView] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=-1026 -Top=-133 -Width=273 -Height=366 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=273 -ClientHeight=366 -TBDockHeight=366 -LRDockWidth=273 -Dockable=1 -StayOnTop=0 -Name=120 -Description=334 -filter=1 - -[DebugLogView] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1143 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1143 -TBDockHeight=411 -LRDockWidth=4953 -Dockable=1 -StayOnTop=0 - -[ThreadStatusWindow] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1143 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1143 -TBDockHeight=211 -LRDockWidth=7406 -Dockable=1 -StayOnTop=0 -Column0Width=145 -Column1Width=100 -Column2Width=115 -Column3Width=250 - -[LocalVarsWindow] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1143 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1143 -TBDockHeight=1532 -LRDockWidth=3484 -Dockable=1 -StayOnTop=0 - -[CallStackWindow] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1143 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1143 -TBDockHeight=2064 -LRDockWidth=3484 -Dockable=1 -StayOnTop=0 - -[PatchForm] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1199 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1199 -TBDockHeight=2497 -LRDockWidth=3398 -Dockable=1 -StayOnTop=0 - -[FindReferencsForm] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1199 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1199 -TBDockHeight=2320 -LRDockWidth=2820 -Dockable=1 -StayOnTop=0 - -[RefactoringForm] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1199 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1199 -TBDockHeight=3208 -LRDockWidth=2820 -Dockable=1 -StayOnTop=0 - -[ToDo List] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1199 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1199 -TBDockHeight=1154 -LRDockWidth=3680 -Dockable=1 -StayOnTop=0 -Column0Width=314 -Column1Width=30 -Column2Width=150 -Column3Width=172 -Column4Width=129 -SortOrder=4 -ShowHints=1 -ShowChecked=1 - -[DataExplorerContainer] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2000 -Height=6959 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=6959 -TBDockHeight=4883 -LRDockWidth=7148 -Dockable=1 -StayOnTop=0 - -[GraphDrawingModel] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2859 -Height=3208 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2859 -ClientHeight=3208 -TBDockHeight=3208 -LRDockWidth=2859 -Dockable=1 -StayOnTop=0 - -[BreakpointWindow] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1143 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1143 -TBDockHeight=1543 -LRDockWidth=8742 -Dockable=1 -StayOnTop=0 -Column0Width=200 -Column1Width=75 -Column2Width=200 -Column3Width=200 -Column4Width=200 -Column5Width=75 -Column6Width=75 - -[StructureView] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=1898 -Height=9223 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=1898 -ClientHeight=9223 -TBDockHeight=3674 -LRDockWidth=1898 -Dockable=1 -StayOnTop=0 - -[ModelViewTool] -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2000 -Height=6959 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=6959 -TBDockHeight=4883 -LRDockWidth=5305 -Dockable=1 -StayOnTop=0 - -[BorlandEditorCodeExplorer@EditWindow0] -PercentageSizes=1 -Create=1 -Visible=0 -Docked=0 -State=0 -Left=0 -Top=0 -Width=1828 -Height=6171 -MaxLeft=-8 -MaxTop=-11 -ClientWidth=1703 -ClientHeight=5749 -TBDockHeight=6171 -LRDockWidth=1828 -Dockable=1 -StayOnTop=0 - -[DockHosts] -DockHostCount=5 - -[DockSite0] -HostDockSite=DockBottomCenterPanel -DockSiteType=1 -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=0 -Width=2336 -Height=1476 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2336 -ClientHeight=1476 -TBDockHeight=1476 -LRDockWidth=2336 -Dockable=1 -StayOnTop=0 -TabPosition=1 -ActiveTabID=RefactoringForm -TabDockClients=RefactoringForm,PatchForm,FindReferencsForm,ToDo List,MetricsView,QAView - -[DockSite1] -HostDockSite=DockBottomPanel -DockSiteType=1 -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=0 -Width=3820 -Height=1421 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=3820 -ClientHeight=1421 -TBDockHeight=1421 -LRDockWidth=3820 -Dockable=1 -StayOnTop=0 -TabPosition=1 -ActiveTabID=DebugLogView -TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow - -[DockSite2] -HostDockSite=DockRightPanel -DockSiteType=1 -PercentageSizes=1 -Create=1 -Visible=1 -Docked=1 -State=0 -Left=0 -Top=18 -Width=2000 -Height=9223 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=9223 -TBDockHeight=7236 -LRDockWidth=2000 -Dockable=1 -StayOnTop=0 -TabPosition=1 -ActiveTabID=ProjectManager -TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm - -[DockSite3] -HostDockSite=LeftDockTabSet -DockSiteType=1 -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=18 -Width=1898 -Height=9223 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=1898 -ClientHeight=9223 -TBDockHeight=7236 -LRDockWidth=1898 -Dockable=1 -StayOnTop=0 -TabPosition=1 -ActiveTabID=StructureView -TabDockClients=StructureView,ClassBrowserTool - -[DockSite4] -HostDockSite=RightTabDock -DockSiteType=1 -PercentageSizes=1 -Create=1 -Visible=0 -Docked=1 -State=0 -Left=0 -Top=454 -Width=2000 -Height=4384 -MaxLeft=-1 -MaxTop=-1 -ClientWidth=2000 -ClientHeight=4384 -TBDockHeight=7236 -LRDockWidth=2000 -Dockable=1 -StayOnTop=0 -TabPosition=1 -ActiveTabID=ToolForm -TabDockClients=ToolForm,TemplateView - diff --git a/demos/PostDataInspector/PostDataInspector.identcache b/demos/PostDataInspector/PostDataInspector.identcache deleted file mode 100644 index 1a330939..00000000 Binary files a/demos/PostDataInspector/PostDataInspector.identcache and /dev/null differ diff --git a/demos/PostDataInspector/PostDataInspector.stat b/demos/PostDataInspector/PostDataInspector.stat deleted file mode 100644 index 36e4e1b8..00000000 --- a/demos/PostDataInspector/PostDataInspector.stat +++ /dev/null @@ -1,10 +0,0 @@ -[Stats] -EditorSecs=334 -DesignerSecs=4 -InspectorSecs=1 -CompileSecs=1 -OtherSecs=6 -StartTime=03/12/2017 15:51:34 -RealKeys=0 -EffectiveKeys=0 -DebugSecs=1 diff --git a/demos/PostDataInspector/uPostDataInspector.pas b/demos/PostDataInspector/uPostDataInspector.pas index 3263fcc7..a5d5197d 100644 --- a/demos/PostDataInspector/uPostDataInspector.pas +++ b/demos/PostDataInspector/uPostDataInspector.pas @@ -76,6 +76,8 @@ type procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -83,10 +85,20 @@ type var PostDataInspectorFrm: TPostDataInspectorFrm; +procedure GlobalCEFApp_OnBeforeNavigation(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + navigationType : TCefNavigationType; + isRedirect : Boolean; + var aStopNavigation : boolean); + implementation {$R *.dfm} +uses + uCEFRenderProcessHandler, uCEFProcessMessage; + // This demo shows an alternative way to inspect the POST data in read only mode. // This data is not always available in the request of TChromium.OnBeforeBrowse // so this demo uses the TCefCustomRenderProcessHandler.OnBeforeNavigationEvent event @@ -96,6 +108,31 @@ implementation // If you need more control over the POST data register an scheme. // See the SchemeRegistrationBrowser demo. +procedure GlobalCEFApp_OnBeforeNavigation(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + navigationType : TCefNavigationType; + isRedirect : Boolean; + var aStopNavigation : boolean); +var + msg: ICefProcessMessage; + TempString : string; +begin + aStopNavigation := False; + + if (request = nil) then + TempString := 'no request' + else + if (request.postdata = nil) then + TempString := 'no postdata' + else + TempString := 'postdata elements : ' + inttostr(request.postdata.GetCount); + + msg := TCefProcessMessageRef.New(POSTDATA_MSGNAME); + msg.ArgumentList.SetString(0, TempString); + browser.SendProcessMessage(PID_BROWSER, msg); +end; + procedure TPostDataInspectorFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); begin PostMessage(Handle, CEF_AFTERCREATED, 0, 0); @@ -157,6 +194,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TPostDataInspectorFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TPostDataInspectorFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TPostDataInspectorFrm.BrowserCreatedMsg(var aMessage : TMessage); begin CEFWindowParent1.UpdateSize; diff --git a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dpr b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dpr index 6191cc13..3cbedb4f 100644 --- a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dpr +++ b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dpr @@ -48,41 +48,19 @@ uses Windows, {$ENDIF } uCEFApplication, - uCEFSchemeRegistrar, - uCEFMiscFunctions, uSchemeRegistrationBrowser in 'uSchemeRegistrationBrowser.pas' {SchemeRegistrationBrowserFrm}, uHelloScheme in 'uHelloScheme.pas'; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} - -procedure GlobalCEFApp_OnRegCustomSchemes(const registrar: TCefSchemeRegistrarRef); -begin - registrar.AddCustomScheme('hello', True, True, False, False, False, False); -end; - begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.OnRegCustomSchemes := GlobalCEFApp_OnRegCustomSchemes; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 - // You can register the Scheme Handler Factory here or later, for example in a context menu command. - CefRegisterSchemeHandlerFactory('hello', '', THelloScheme); - Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TSchemeRegistrationBrowserFrm, SchemeRegistrationBrowserFrm); diff --git a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj index ab8d1138..91f61bc6 100644 --- a/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj +++ b/demos/SchemeRegistrationBrowser/SchemeRegistrationBrowser.dproj @@ -107,7 +107,6 @@
SchemeRegistrationBrowserFrm
- dfm
diff --git a/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm b/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm index bd5dd75a..33534d31 100644 --- a/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm +++ b/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm @@ -12,6 +12,7 @@ object SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnCreate = FormCreate OnShow = FormShow PixelsPerInch = 96 TextHeight = 13 diff --git a/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.pas b/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.pas index d379cfcc..7de46fa7 100644 --- a/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.pas +++ b/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.pas @@ -50,7 +50,8 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, {$ENDIF} - uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants; + uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFSchemeRegistrar, + uCEFTypes, uCEFConstants; const MINIBROWSER_CONTEXTMENU_REGSCHEME = MENU_ID_USER_FIRST + 1; @@ -76,12 +77,15 @@ type procedure GoBtnClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure Timer1Timer(Sender: TObject); + procedure FormCreate(Sender: TObject); private { Private declarations } protected procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -89,12 +93,19 @@ type var SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm; +procedure GlobalCEFApp_OnRegCustomSchemes(const registrar: TCefSchemeRegistrarRef); + implementation {$R *.dfm} uses - uCEFSchemeHandlerFactory, uHelloScheme; + uCEFSchemeHandlerFactory, uCEFMiscFunctions, uHelloScheme; + +procedure GlobalCEFApp_OnRegCustomSchemes(const registrar: TCefSchemeRegistrarRef); +begin + registrar.AddCustomScheme('hello', True, True, False, False, False, False); +end; procedure TSchemeRegistrationBrowserFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); begin @@ -141,6 +152,12 @@ begin end; end; +procedure TSchemeRegistrationBrowserFrm.FormCreate(Sender: TObject); +begin + // You can register the Scheme Handler Factory here or later, for example in a context menu command. + CefRegisterSchemeHandlerFactory('hello', '', THelloScheme); +end; + procedure TSchemeRegistrationBrowserFrm.FormShow(Sender: TObject); begin // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser @@ -181,4 +198,18 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TSchemeRegistrationBrowserFrm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TSchemeRegistrationBrowserFrm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + end. diff --git a/demos/SimpleOSRBrowser/SimpleOSRBrowser.dpr b/demos/SimpleOSRBrowser/SimpleOSRBrowser.dpr index 071c4caf..b22fa0db 100644 --- a/demos/SimpleOSRBrowser/SimpleOSRBrowser.dpr +++ b/demos/SimpleOSRBrowser/SimpleOSRBrowser.dpr @@ -41,16 +41,17 @@ program SimpleOSRBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF} uCEFApplication, uSimpleOSRBrowser in 'uSimpleOSRBrowser.pas' {Form1}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin @@ -59,18 +60,6 @@ begin GlobalCEFApp.EnableHighDPISupport := True; GlobalCEFApp.FastUnload := True; - //GlobalCEFApp.AddCustomCommandLine('--show-fps-counter'); - - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 Application.Initialize; diff --git a/demos/SimpleOSRBrowser/uSimpleOSRBrowser.pas b/demos/SimpleOSRBrowser/uSimpleOSRBrowser.pas index db7320a7..8e231443 100644 --- a/demos/SimpleOSRBrowser/uSimpleOSRBrowser.pas +++ b/demos/SimpleOSRBrowser/uSimpleOSRBrowser.pas @@ -115,6 +115,8 @@ type procedure WMMoving(var aMessage : TMessage); message WM_MOVING; procedure WMCaptureChanged(var aMessage : TMessage); message WM_CAPTURECHANGED; procedure WMCancelMode(var aMessage : TMessage); message WM_CANCELMODE; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; procedure PendingResizeMsg(var aMessage : TMessage); message CEF_PENDINGRESIZE; @@ -550,6 +552,20 @@ begin if (chrmosr <> nil) then chrmosr.SendCaptureLostEvent; end; +procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TForm1.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TForm1.BrowserCreatedMsg(var aMessage : TMessage); begin Caption := 'Simple OSR Browser'; diff --git a/demos/SimpleServer/00-DeleteDCUs.bat b/demos/SimpleServer/00-DeleteDCUs.bat new file mode 100644 index 00000000..dbd008bc --- /dev/null +++ b/demos/SimpleServer/00-DeleteDCUs.bat @@ -0,0 +1,14 @@ +del /s /q *.dcu +del /s /q *.exe +del /s /q *.res +del /s /q *.log +del /s /q *.dsk +del /s /q *.identcache +del /s /q *.stat +del /s /q *.local +del /s /q *.~* +rmdir Win32\Debug +rmdir Win32\Release +rmdir Win32 +rmdir __history +rmdir __recovery diff --git a/demos/SimpleServer/SimpleServer.dpr b/demos/SimpleServer/SimpleServer.dpr new file mode 100644 index 00000000..e7429ad2 --- /dev/null +++ b/demos/SimpleServer/SimpleServer.dpr @@ -0,0 +1,67 @@ +// ************************************************************************ +// ***************************** 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. + * + *) + +program SimpleServer; + +{$I cef.inc} + +uses + {$IFDEF DELPHI16_UP} + Vcl.Forms, + {$ELSE} + Forms, + {$ENDIF } + uCEFApplication, + uSimpleServer in 'uSimpleServer.pas' {SimpleServerFrm}; + +{$R *.res} + +begin + GlobalCEFApp := TCefApplication.Create; + + if GlobalCEFApp.StartMainProcess then + begin + Application.Initialize; + {$IFDEF DELPHI11_UP} + Application.MainFormOnTaskbar := True; + {$ENDIF} + Application.CreateForm(TSimpleServerFrm, SimpleServerFrm); + Application.Run; + end; + + GlobalCEFApp.Free; +end. diff --git a/demos/SimpleServer/SimpleServer.dproj b/demos/SimpleServer/SimpleServer.dproj new file mode 100644 index 00000000..5e04853d --- /dev/null +++ b/demos/SimpleServer/SimpleServer.dproj @@ -0,0 +1,569 @@ + + + {5901DE83-097F-456D-9507-D75337BE827A} + 18.2 + VCL + SimpleServer.dpr + True + Debug + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + .\$(Platform)\$(Config) + ..\..\bin + false + false + false + false + false + RESTComponents;emsclientfiredac;FireDAC;FireDACSqliteDriver;soaprtl;FireDACIBDriver;soapmidas;FireDACCommon;emsclient;RESTBackendComponents;soapserver;FireDACCommonDriver;CloudService;inet;$(DCC_UsePackage) + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + $(BDS)\bin\delphi_PROJECTICON.ico + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + SimpleServer + 3082 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + + + DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;vclFireDAC;FireDACDb2Driver;DataSnapFireDAC;svnui;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;Componentes_UI;vcldb;bindcompfmx;svn;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;CEF4Delphi;DbxCommonDriver;IndyProtocols240;IndySystem240;fmx;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;IndyCore240;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;bindcompvcl;DataSnapConnectors;VCLRESTComponents;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;DataSnapClient;DataSnapServerMidas;$(DCC_UsePackage) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\default_app.manifest + + + DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;vclFireDAC;FireDACDb2Driver;DataSnapFireDAC;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;DbxCommonDriver;IndyProtocols240;IndySystem240;fmx;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;IndyCore240;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;bindcompvcl;DataSnapConnectors;VCLRESTComponents;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;DataSnapClient;DataSnapServerMidas;$(DCC_UsePackage) + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + false + true + true + true + 1033 + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + true + + + + MainSource + + +
SimpleServerFrm
+ dfm +
+ + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Application + + + + SimpleServer.dpr + + + IP Abstraction Indy Implementation Design Time + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + SimpleServer.exe + true + + + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 0 + + + + + classes + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + + + res\values + 1 + + + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + 1 + + + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\ + 1 + + + + + Contents + 1 + + + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/demos/SimpleServer/cef.inc b/demos/SimpleServer/cef.inc new file mode 100644 index 00000000..984ae795 --- /dev/null +++ b/demos/SimpleServer/cef.inc @@ -0,0 +1,384 @@ +// ************************************************************************ +// ***************************** 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. + * + *) + + // The complete list of compiler versions is here : + // http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions + +{$DEFINE DELPHI_VERSION_UNKNOW} + +{$IFDEF FPC} + {$DEFINE CEF_MULTI_THREADED_MESSAGE_LOOP} + {$DEFINE SUPPORTS_INLINE} +{$ENDIF} + +// Delphi 5 +{$IFDEF VER130} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} +{$ENDIF} + +// Delphi 6 +{$IFDEF VER140} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} +{$ENDIF} + +// Delphi 7 +{$IFDEF VER150} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} +{$ENDIF} + +// Delphi 8 +{$IFDEF VER160} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} +{$ENDIF} + +// Delphi 2005 +{$IFDEF VER170} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} +{$ENDIF} + +{$IFDEF VER180} + {$UNDEF DELPHI_VERSION_UNKNOW} + // Delphi 2007 + {$IFDEF VER185} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + // Delphi 2006 + {$ELSE} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$ENDIF} +{$ENDIF} + +// Delphi 2009 +{$IFDEF VER200} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} +{$ENDIF} + +//Delphi 2010 +{$IFDEF VER210} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} +{$ENDIF} + +// Delphi XE +{$IFDEF VER220} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} +{$ENDIF} + +// Delphi XE2 +{$IFDEF VER230} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} +{$ENDIF} + +// Delphi XE3 +{$IFDEF VER240} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} +{$ENDIF} + +// Delphi XE4 +{$IFDEF VER250} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} +{$ENDIF} + +// Delphi XE5 +{$IFDEF VER260} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} +{$ENDIF} + +// Delphi XE6 +{$IFDEF VER270} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} +{$ENDIF} + +// Delphi XE7 +{$IFDEF VER280} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} +{$ENDIF} + +// Delphi XE8 +{$IFDEF VER290} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} +{$ENDIF VER290} + +// Rad Studio 10 - Delphi Seattle +{$IFDEF VER300} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} +{$ENDIF} + +// Rad Studio 10.1 - Delphi Berlin +{$IFDEF VER310} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} +{$ENDIF} + +// Rad Studio 10.2 - Delphi Tokyo +{$IFDEF VER320} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} +{$ENDIF} + + +{$IFDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} +{$ENDIF} + +{$IFDEF DELPHI9_UP} + {$DEFINE SUPPORTS_INLINE} +{$ENDIF} + diff --git a/demos/SimpleServer/uSimpleServer.dfm b/demos/SimpleServer/uSimpleServer.dfm new file mode 100644 index 00000000..1bddc11c --- /dev/null +++ b/demos/SimpleServer/uSimpleServer.dfm @@ -0,0 +1,120 @@ +object SimpleServerFrm: TSimpleServerFrm + Left = 0 + Top = 0 + BorderIcons = [biSystemMenu, biMinimize] + BorderStyle = bsSingle + Caption = 'Simple Server' + ClientHeight = 436 + ClientWidth = 554 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate + PixelsPerInch = 96 + TextHeight = 13 + object ButtonPnl: TPanel + Left = 0 + Top = 0 + Width = 554 + Height = 94 + Align = alTop + BevelOuter = bvNone + TabOrder = 0 + ExplicitWidth = 557 + object AddressLbl: TLabel + Left = 14 + Top = 11 + Width = 39 + Height = 13 + Caption = 'Address' + end + object PortLbl: TLabel + Left = 14 + Top = 39 + Width = 20 + Height = 13 + Caption = 'Port' + end + object BacklogLbl: TLabel + Left = 14 + Top = 68 + Width = 36 + Height = 13 + Caption = 'Backlog' + end + object AddressEdt: TEdit + Left = 87 + Top = 8 + Width = 211 + Height = 21 + TabOrder = 0 + Text = '127.0.0.1' + OnChange = AddressEdtChange + end + object PortEdt: TSpinEdit + Left = 87 + Top = 36 + Width = 211 + Height = 22 + MaxValue = 65535 + MinValue = 1025 + TabOrder = 1 + Value = 8099 + end + object BacklogEdt: TSpinEdit + Left = 87 + Top = 65 + Width = 211 + Height = 22 + MaxValue = 512 + MinValue = 1 + TabOrder = 2 + Value = 10 + end + object StartBtn: TButton + Left = 312 + Top = 8 + Width = 105 + Height = 79 + Caption = 'Start' + TabOrder = 3 + OnClick = StartBtnClick + end + object StopBtn: TButton + Left = 434 + Top = 8 + Width = 105 + Height = 79 + Caption = 'Stop' + Enabled = False + TabOrder = 4 + OnClick = StopBtnClick + end + end + object ConnectionLogMem: TMemo + Left = 0 + Top = 94 + Width = 554 + Height = 342 + Align = alClient + ReadOnly = True + ScrollBars = ssBoth + TabOrder = 1 + ExplicitWidth = 557 + end + object CEFServerComponent1: TCEFServerComponent + OnServerCreated = CEFServerComponent1ServerCreated + OnServerDestroyed = CEFServerComponent1ServerDestroyed + OnClientConnected = CEFServerComponent1ClientConnected + OnClientDisconnected = CEFServerComponent1ClientDisconnected + OnHttpRequest = CEFServerComponent1HttpRequest + Left = 456 + Top = 304 + end +end diff --git a/demos/SimpleServer/uSimpleServer.pas b/demos/SimpleServer/uSimpleServer.pas new file mode 100644 index 00000000..6e4af346 --- /dev/null +++ b/demos/SimpleServer/uSimpleServer.pas @@ -0,0 +1,271 @@ +// ************************************************************************ +// ***************************** 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 uSimpleServer; + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Samples.Spin, Vcl.ExtCtrls, System.Math, + {$ELSE} + Windows, Messages, SysUtils, Variants, Classes, Graphics, + Controls, Forms, Dialogs, StdCtrls, Spin, ExtCtrls, Math, + {$ENDIF} + uCEFInterfaces, uCEFServerComponent, uCEFTypes, uCEFMiscFunctions; + +type + TSimpleServerFrm = class(TForm) + CEFServerComponent1: TCEFServerComponent; + ButtonPnl: TPanel; + ConnectionLogMem: TMemo; + AddressLbl: TLabel; + AddressEdt: TEdit; + PortLbl: TLabel; + PortEdt: TSpinEdit; + BacklogLbl: TLabel; + BacklogEdt: TSpinEdit; + StartBtn: TButton; + StopBtn: TButton; + procedure StartBtnClick(Sender: TObject); + procedure AddressEdtChange(Sender: TObject); + procedure CEFServerComponent1ServerCreated(Sender: TObject; + const server: ICefServer); + procedure CEFServerComponent1ServerDestroyed(Sender: TObject; + const server: ICefServer); + procedure CEFServerComponent1ClientConnected(Sender: TObject; + const server: ICefServer; connection_id: Integer); + procedure CEFServerComponent1ClientDisconnected(Sender: TObject; + const server: ICefServer; connection_id: Integer); + procedure StopBtnClick(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure FormCreate(Sender: TObject); + procedure CEFServerComponent1HttpRequest(Sender: TObject; + const server: ICefServer; connection_id: Integer; + const client_address: ustring; const request: ICefRequest); + protected + FClosing : boolean; + + function BufferToString(const aBuffer : TBytes) : string; + procedure ShowRequestInfo(const aRequest : ICefRequest); + procedure ShowPostDataInfo(const aPostData : ICefPostData); + public + { Public declarations } + end; + +var + SimpleServerFrm: TSimpleServerFrm; + +implementation + +{$R *.dfm} + +// Server capacity is limited and is intended to handle only a small number of +// simultaneous connections (e.g. for communicating between applications on localhost). + +// To test it follow these steps : +// 1- Build and run this demo. +// 2- Click on the Start button. +// 3- Open your web browser and visit this address http://127.0.0.1:8099 +// 4- You should see some connection details in the server log and a "Hellow world" text in your web browser. + +procedure TSimpleServerFrm.AddressEdtChange(Sender: TObject); +begin + if not(CEFServerComponent1.IsRunning) then + StartBtn.Enabled := (length(trim(AddressEdt.Text)) > 0); +end; + +procedure TSimpleServerFrm.StartBtnClick(Sender: TObject); +begin + if (length(trim(AddressEdt.Text)) > 0) then + CEFServerComponent1.CreateServer(AddressEdt.Text, PortEdt.Value, BacklogEdt.Value); +end; + +procedure TSimpleServerFrm.StopBtnClick(Sender: TObject); +begin + CEFServerComponent1.Shutdown; +end; + +procedure TSimpleServerFrm.CEFServerComponent1ClientConnected( + Sender: TObject; const server: ICefServer; connection_id: Integer); +begin + ConnectionLogMem.Lines.Add('Client connected : ' + inttostr(connection_id)); +end; + +procedure TSimpleServerFrm.CEFServerComponent1ClientDisconnected( + Sender: TObject; const server: ICefServer; connection_id: Integer); +begin + ConnectionLogMem.Lines.Add('Client disconnected : ' + inttostr(connection_id)); +end; + +procedure TSimpleServerFrm.CEFServerComponent1HttpRequest(Sender: TObject; + const server: ICefServer; connection_id: Integer; + const client_address: ustring; const request: ICefRequest); +var + TempData : string; + TempParts : TUrlParts; +begin + ConnectionLogMem.Lines.Add('---------------------------------------'); + ConnectionLogMem.Lines.Add('HTTP request received from connection ' + inttostr(connection_id)); + ConnectionLogMem.Lines.Add('Client address : ' + client_address); + ShowRequestInfo(request); + ConnectionLogMem.Lines.Add('---------------------------------------'); + + if (request <> nil) and CefParseUrl(Request.URL, TempParts) then + begin + if (TempParts.path = '') or (TempParts.path = '/') then + begin + TempData := 'Hello world from Simple Server'; + CEFServerComponent1.SendHttp200response(connection_id, 'text/html', @TempData[1], length(TempData) * SizeOf(char)); + end + else + CEFServerComponent1.SendHttp404response(connection_id); + end + else + CEFServerComponent1.SendHttp404response(connection_id); +end; + +procedure TSimpleServerFrm.ShowRequestInfo(const aRequest : ICefRequest); +begin + if (aRequest = nil) then exit; + + ConnectionLogMem.Lines.Add('Request URL : ' + aRequest.URL); + ConnectionLogMem.Lines.Add('Request Method : ' + aRequest.Method); + + if (length(aRequest.ReferrerUrl) > 0) then + ConnectionLogMem.Lines.Add('Request Referrer : ' + aRequest.ReferrerUrl); + + ShowPostDataInfo(aRequest.PostData); +end; + +procedure TSimpleServerFrm.ShowPostDataInfo(const aPostData : ICefPostData); +var + i, j : integer; + TempLen : NativeUInt; + TempList : IInterfaceList; + TempElement : ICefPostDataElement; + TempBytes : TBytes; +begin + if (aPostData = nil) then exit; + + i := 0; + j := aPostData.GetCount; + + TempList := aPostData.GetElements(j); + + while (i < j) do + begin + TempElement := TempList.Items[i] as ICefPostDataElement; + + if (TempElement.GetBytesCount > 0) then + begin + SetLength(TempBytes, TempElement.GetBytesCount); + TempLen := TempElement.GetBytes(TempElement.GetBytesCount, @TempBytes[0]); + + if (TempLen > 0) then + begin + ConnectionLogMem.Lines.Add('Post contents length : ' + inttostr(TempLen)); + ConnectionLogMem.Lines.Add('Post contents sample : ' + BufferToString(TempBytes)); + end; + end; + + inc(i); + end; +end; + +function TSimpleServerFrm.BufferToString(const aBuffer : TBytes) : string; +var + i, j : integer; +begin + Result := ''; + + i := 0; + j := min(length(aBuffer), 5); + + while (i < j) do + begin + Result := Result + IntToHex(aBuffer[i], 2); + inc(i); + end; +end; + +procedure TSimpleServerFrm.CEFServerComponent1ServerCreated(Sender: TObject; const server: ICefServer); +begin + if CEFServerComponent1.Initialized then + begin + ConnectionLogMem.Lines.Add('Server created'); + StartBtn.Enabled := False; + StopBtn.Enabled := True; + end + else + ConnectionLogMem.Lines.Add('Server creation error!'); +end; + +procedure TSimpleServerFrm.CEFServerComponent1ServerDestroyed(Sender: TObject; const server: ICefServer); +begin + if FClosing then + PostMessage(Handle, WM_CLOSE, 0, 0) + else + begin + ConnectionLogMem.Lines.Add('Server destroyed'); + StartBtn.Enabled := True; + StopBtn.Enabled := False; + end; +end; + +procedure TSimpleServerFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + if CEFServerComponent1.Initialized then + begin + CanClose := False; + FClosing := True; + Visible := False; + CEFServerComponent1.Shutdown; + end + else + CanClose := True; +end; + +procedure TSimpleServerFrm.FormCreate(Sender: TObject); +begin + FClosing := False; +end; + +end. diff --git a/demos/SubProcess/SimpleBrowser.dpr b/demos/SubProcess/SimpleBrowser.dpr index 7f67aa8f..9fcce6f9 100644 --- a/demos/SubProcess/SimpleBrowser.dpr +++ b/demos/SubProcess/SimpleBrowser.dpr @@ -41,9 +41,11 @@ program SimpleBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF} uCEFApplication, uSimpleBrowser in 'uSimpleBrowser.pas' {Form1}; diff --git a/demos/SubProcess/uSimpleBrowser.pas b/demos/SubProcess/uSimpleBrowser.pas index 8d30473f..541e78d0 100644 --- a/demos/SubProcess/uSimpleBrowser.pas +++ b/demos/SubProcess/uSimpleBrowser.pas @@ -66,6 +66,9 @@ type // You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned. procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + // You also have to handle these two messages to set GlobalCEFApp.OsmodalLoop + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; public { Public declarations } end; @@ -77,6 +80,9 @@ implementation {$R *.dfm} +uses + uCEFApplication; + // This is a demo with the simplest web browser you can build using CEF4Delphi and // it doesn't show any sign of progress like other web browsers do. @@ -127,18 +133,28 @@ procedure TForm1.WMMove(var aMessage : TWMMove); begin inherited; - if (ChromiumWindow1 <> nil) and - (ChromiumWindow1.ChromiumBrowser <> nil) then - ChromiumWindow1.ChromiumBrowser.NotifyMoveOrResizeStarted; + if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; end; procedure TForm1.WMMoving(var aMessage : TMessage); begin inherited; - if (ChromiumWindow1 <> nil) and - (ChromiumWindow1.ChromiumBrowser <> nil) then - ChromiumWindow1.ChromiumBrowser.NotifyMoveOrResizeStarted; + if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; +end; + +procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TForm1.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; end; end. diff --git a/demos/TabbedBrowser/TabBrowser.dpr b/demos/TabbedBrowser/TabBrowser.dpr index 28976f0f..dcae7e2f 100644 --- a/demos/TabbedBrowser/TabBrowser.dpr +++ b/demos/TabbedBrowser/TabBrowser.dpr @@ -41,16 +41,17 @@ program TabBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF } uCEFApplication, uMainForm in 'uMainForm.pas' {MainForm}; {$R *.res} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin @@ -59,16 +60,6 @@ begin GlobalCEFApp.FastUnload := True; GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 Application.Initialize; diff --git a/demos/TabbedBrowser/uMainForm.pas b/demos/TabbedBrowser/uMainForm.pas index ac194fae..c33b5286 100644 --- a/demos/TabbedBrowser/uMainForm.pas +++ b/demos/TabbedBrowser/uMainForm.pas @@ -97,6 +97,8 @@ type procedure CEFInitializedMsg(var aMessage : TMessage); message CEFBROWSER_INITIALIZED; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; function GetPageIndex(const aSender : TObject; var aPageIndex : integer) : boolean; procedure NotifyMoveOrResizeStarted; @@ -414,6 +416,20 @@ begin NotifyMoveOrResizeStarted; end; +procedure TMainForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TMainForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TMainForm.PageControl1Change(Sender: TObject); var TempChromium : TChromium; diff --git a/demos/ToolBoxBrowser/ToolBoxBrowser.dpr b/demos/ToolBoxBrowser/ToolBoxBrowser.dpr index e3856f45..2d79d042 100644 --- a/demos/ToolBoxBrowser/ToolBoxBrowser.dpr +++ b/demos/ToolBoxBrowser/ToolBoxBrowser.dpr @@ -41,9 +41,11 @@ program ToolBoxBrowser; uses {$IFDEF DELPHI16_UP} - Vcl.Forms, WinApi.Windows, + Vcl.Forms, + WinApi.Windows, {$ELSE} - Forms, Windows, + Forms, + Windows, {$ENDIF } uCEFApplication, uMainForm in 'uMainForm.pas' {MainForm}, @@ -51,7 +53,6 @@ uses {$R *.RES} -// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} begin @@ -60,16 +61,6 @@ begin GlobalCEFApp.FastUnload := True; GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; - // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. -{ - 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 Application.Initialize; diff --git a/demos/ToolBoxBrowser/uChildForm.pas b/demos/ToolBoxBrowser/uChildForm.pas index e9a4fff8..05139f0e 100644 --- a/demos/ToolBoxBrowser/uChildForm.pas +++ b/demos/ToolBoxBrowser/uChildForm.pas @@ -85,6 +85,8 @@ type procedure BrowserDestroyMsg(var aMessage : TMessage); message CEFBROWSER_DESTROY; procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; procedure HandleKeyUp(const aMsg : TMsg; var aHandled : boolean); procedure HandleKeyDown(const aMsg : TMsg; var aHandled : boolean); @@ -98,6 +100,9 @@ implementation {$R *.dfm} +uses + uCEFApplication; + // Destruction steps // ================= // 1. FormCloseQuery calls TChromium.CloseBrowser @@ -236,6 +241,20 @@ begin if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted; end; +procedure TChildForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TChildForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; +end; + procedure TChildForm.BrowserCreatedMsg(var aMessage : TMessage); begin CEFWindowParent1.UpdateSize; diff --git a/demos/ToolBoxBrowser/uMainForm.dfm b/demos/ToolBoxBrowser/uMainForm.dfm index 4d58d962..68f5d6e5 100644 --- a/demos/ToolBoxBrowser/uMainForm.dfm +++ b/demos/ToolBoxBrowser/uMainForm.dfm @@ -28,10 +28,6 @@ object MainForm: TMainForm Enabled = False ShowCaption = False TabOrder = 0 - ExplicitLeft = 136 - ExplicitTop = 8 - ExplicitWidth = 185 - ExplicitHeight = 41 object Edit1: TEdit Left = 8 Top = 8 diff --git a/source/CEF4Delphi.dpk b/source/CEF4Delphi.dpk index 6bfd136d..978e18a0 100644 --- a/source/CEF4Delphi.dpk +++ b/source/CEF4Delphi.dpk @@ -159,7 +159,11 @@ contains uCEFExtensionHandler in 'uCEFExtensionHandler.pas', uBufferPanel in 'uBufferPanel.pas', uCEFApp in 'uCEFApp.pas', - uCEFWorkScheduler in 'uCEFWorkScheduler.pas'; + uCEFWorkScheduler in 'uCEFWorkScheduler.pas', + uCEFServer in 'uCEFServer.pas', + uCEFServerHandler in 'uCEFServerHandler.pas', + uCEFServerEvents in 'uCEFServerEvents.pas', + uCEFServerComponent in 'uCEFServerComponent.pas'; end. diff --git a/source/CEF4Delphi.dproj b/source/CEF4Delphi.dproj index 02b46791..2b18dc41 100644 --- a/source/CEF4Delphi.dproj +++ b/source/CEF4Delphi.dproj @@ -251,6 +251,10 @@ + + + + Base diff --git a/source/CEF4Delphi_D7.dpk b/source/CEF4Delphi_D7.dpk index 37a515de..b7c3f4a6 100644 --- a/source/CEF4Delphi_D7.dpk +++ b/source/CEF4Delphi_D7.dpk @@ -155,6 +155,11 @@ contains uCEFExtension in 'uCEFExtension.pas', uCEFExtensionHandler in 'uCEFExtensionHandler.pas', uBufferPanel in 'uBufferPanel.pas', - uCEFApp in 'uCEFApp.pas'; + uCEFApp in 'uCEFApp.pas', + uCEFWorkScheduler in 'uCEFWorkScheduler.pas', + uCEFServer in 'uCEFServer.pas', + uCEFServerHandler in 'uCEFServerHandler.pas', + uCEFServerEvents in 'uCEFServerEvents.pas', + uCEFServerComponent in 'uCEFServerComponent.pas'; end. diff --git a/source/uCEFAccessibilityHandler.pas b/source/uCEFAccessibilityHandler.pas index 2f8eaef8..afe24fb3 100644 --- a/source/uCEFAccessibilityHandler.pas +++ b/source/uCEFAccessibilityHandler.pas @@ -50,6 +50,8 @@ uses uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFChromiumEvents; type + TOnAccessibilityEvent = procedure(Sender: TObject; const value: ICefValue) of object; + TCEFAccessibilityHandlerOwn = class(TCefBaseRefCountedOwn, ICefAccessibilityHandler) protected procedure OnAccessibilityTreeChange(const value: ICefValue); virtual; diff --git a/source/uCEFApplication.pas b/source/uCEFApplication.pas index b5ea5480..3beb3c6c 100644 --- a/source/uCEFApplication.pas +++ b/source/uCEFApplication.pas @@ -56,14 +56,14 @@ uses const CEF_SUPPORTED_VERSION_MAJOR = 3; - CEF_SUPPORTED_VERSION_MINOR = 3202; - CEF_SUPPORTED_VERSION_RELEASE = 1694; + CEF_SUPPORTED_VERSION_MINOR = 3239; + CEF_SUPPORTED_VERSION_RELEASE = 1700; CEF_SUPPORTED_VERSION_BUILD = 0; - CEF_CHROMEELF_VERSION_MAJOR = 62; + CEF_CHROMEELF_VERSION_MAJOR = 63; CEF_CHROMEELF_VERSION_MINOR = 0; - CEF_CHROMEELF_VERSION_RELEASE = 3202; - CEF_CHROMEELF_VERSION_BUILD = 94; + CEF_CHROMEELF_VERSION_RELEASE = 3239; + CEF_CHROMEELF_VERSION_BUILD = 70; LIBCEF_DLL = 'libcef.dll'; CHROMEELF_DLL = 'chrome_elf.dll'; @@ -130,6 +130,8 @@ type FDeviceScaleFactor : single; FCheckDevToolsResources : boolean; FDisableGPUCache : boolean; + FStatus : TCefAplicationStatus; + FMissingLibFiles : string; FProcessType : TCefProcessType; FResourceBundleHandler : ICefResourceBundleHandler; FBrowserProcessHandler : ICefBrowserProcessHandler; @@ -339,6 +341,8 @@ type property BrowserProcessHandler : ICefBrowserProcessHandler read FBrowserProcessHandler write FBrowserProcessHandler; property RenderProcessHandler : ICefRenderProcessHandler read FRenderProcessHandler write FRenderProcessHandler; property OsmodalLoop : boolean write SetOsmodalLoop; + property Status : TCefAplicationStatus read FStatus; + property MissingLibFiles : string read FMissingLibFiles; property OnRegCustomSchemes : TOnRegisterCustomSchemes read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes; @@ -385,6 +389,8 @@ constructor TCefApplication.Create; begin inherited Create; + FStatus := asLoading; + FMissingLibFiles := ''; FLibHandle := 0; FMustShutDown := False; FCache := ''; @@ -497,6 +503,8 @@ begin FLibLoaded := False; end; + FStatus := asUnloaded; + if (FCustomCommandLines <> nil) then FreeAndNil(FCustomCommandLines); if (FCustomCommandLineValues <> nil) then FreeAndNil(FCustomCommandLineValues); @@ -546,21 +554,16 @@ var begin Result := False; - try - if CheckCEFLibrary and LoadCEFlibrary then - begin - TempApp := TCustomCefApp.Create(self); + if CheckCEFLibrary and LoadCEFlibrary then + begin + TempApp := TCustomCefApp.Create(self); - if (ExecuteProcess(TempApp) < 0) then - begin - FMustShutDown := True; - Result := InitializeLibrary(TempApp); - end; - end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.SingleExeProcessing', e) then raise; - end; + if (ExecuteProcess(TempApp) < 0) and (FStatus = asLoaded) then + begin + FMustShutDown := True; + Result := InitializeLibrary(TempApp); + end; + end; end; function TCefApplication.GetChromeVersion : string; @@ -627,94 +630,48 @@ end; function TCefApplication.CheckCEFLibrary : boolean; var - TempString, TempPath : string; + TempString : string; + TempMissingFrm, TempMissingRsc, TempMissingLoc : boolean; begin - if FCheckCEFFiles then - Result := False - else - begin - Result := True; - exit; - end; + Result := False; - - if not(CheckDLLs(FFrameworkDirPath)) then - begin - TempString := 'CEF framework files missing !' + CRLF + CRLF; - - if GetAbsoluteDirPath(FFrameworkDirPath, TempPath) then - begin - if (length(TempPath) = 0) then TempPath := GetModulePath; - TempString := TempString + - 'Make sure all the CEF framework files can be found in this directory :' + - CRLF + SplitLongString(TempPath); - end - else - TempString := TempString + - 'The CEF framework directory doesn' + #39 +'t exist!' + - CRLF + SplitLongString(FFrameworkDirPath); - - ShowErrorMessageDlg(TempString); - exit; - end; - - - if not(CheckResources(FResourcesDirPath, FCheckDevToolsResources)) then - begin - TempString := 'CEF resources missing !' + CRLF + CRLF; - - if GetAbsoluteDirPath(FResourcesDirPath, TempPath) then - begin - if (length(TempPath) = 0) then TempPath := GetModulePath; - TempString := TempString + - 'Make sure all the CEF resources can be found in this directory :' + - CRLF + SplitLongString(TempPath); - end - else - TempString := TempString + - 'The CEF resources directory doesn' + #39 +'t exist!' + - CRLF + SplitLongString(FResourcesDirPath); - - ShowErrorMessageDlg(TempString); - exit; - end; - - - if not(CheckLocales(FLocalesDirPath, FLocalesRequired)) then - begin - TempString := 'CEF locale files missing !' + CRLF + CRLF; - - if GetAbsoluteDirPath(FLocalesDirPath, TempPath) then - begin - if (length(TempPath) = 0) then TempPath := GetModulePath + 'locales'; - TempString := TempString + - 'Make sure all the CEF locale files can be found in this directory :' + - CRLF + SplitLongString(TempPath); - end - else - TempString := TempString + - 'The CEF locales directory doesn' + #39 +'t exist!' + - CRLF + SplitLongString(FLocalesDirPath); - - ShowErrorMessageDlg(TempString); - exit; - end; - - - if CheckDLLVersion(LibCefPath, - CEF_SUPPORTED_VERSION_MAJOR, - CEF_SUPPORTED_VERSION_MINOR, - CEF_SUPPORTED_VERSION_RELEASE, - CEF_SUPPORTED_VERSION_BUILD) then + if not(FCheckCEFFiles) or (FProcessType <> ptBrowser) then Result := True else begin - TempString := 'Unsupported CEF version !' + - CRLF + CRLF + - 'Use only the CEF3 binaries specified in the CEF4Delphi Readme.md file at ' + - CRLF + CEF4DELPHI_URL; + TempMissingFrm := not(CheckDLLs(FFrameworkDirPath, FMissingLibFiles)); + TempMissingRsc := not(CheckResources(FResourcesDirPath, FMissingLibFiles, FCheckDevToolsResources)); + TempMissingLoc := not(CheckLocales(FLocalesDirPath, FMissingLibFiles, FLocalesRequired)); - ShowErrorMessageDlg(TempString); + if TempMissingFrm or TempMissingRsc or TempMissingLoc then + begin + FStatus := asErrorMissingFiles; + TempString := 'CEF3 binaries missing !'; + + if (length(FMissingLibFiles) > 0) then + TempString := TempString + CRLF + CRLF + + 'The missing files are :' + CRLF + + trim(FMissingLibFiles); + + ShowErrorMessageDlg(TempString); + end + else + if CheckDLLVersion(LibCefPath, + CEF_SUPPORTED_VERSION_MAJOR, + CEF_SUPPORTED_VERSION_MINOR, + CEF_SUPPORTED_VERSION_RELEASE, + CEF_SUPPORTED_VERSION_BUILD) then + Result := True + else + begin + FStatus := asErrorDLLVersion; + TempString := 'Unsupported CEF version !' + + CRLF + CRLF + + 'Use only the CEF3 binaries specified in the CEF4Delphi Readme.md file at ' + + CRLF + CEF4DELPHI_URL; + + ShowErrorMessageDlg(TempString); + end; end; end; @@ -732,16 +689,11 @@ var begin Result := False; - try - if not(FSingleProcess) and LoadCEFlibrary then - begin - TempApp := TCustomCefApp.Create(self); - Result := (ExecuteProcess(TempApp) >= 0); - end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.StartSubProcess', e) then raise; - end; + if not(FSingleProcess) and LoadCEFlibrary then + begin + TempApp := TCustomCefApp.Create(self); + Result := (ExecuteProcess(TempApp) >= 0); + end; end; procedure TCefApplication.DoMessageLoopWork; @@ -792,8 +744,17 @@ function TCefApplication.ExecuteProcess(const aApp : ICefApp) : integer; var TempArgs : TCefMainArgs; begin - TempArgs.instance := HINSTANCE; - Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo); + Result := -1; + try + TempArgs.instance := HINSTANCE; + Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo); + except + on e : exception do + begin + FStatus := asErrorExecutingProcess; + if CustomExceptionHandler('TCefApplication.ExecuteProcess', e) then raise; + end; + end; end; procedure TCefApplication.InitializeSettings(var aSettings : TCefSettings); @@ -835,16 +796,25 @@ begin Result := False; try - if FDeleteCache then DeleteDirContents(FCache); - if FDeleteCookies then DeleteDirContents(FCookies); + try + if FDeleteCache then DeleteDirContents(FCache); + if FDeleteCookies then DeleteDirContents(FCookies); - InitializeSettings(FAppSettings); + InitializeSettings(FAppSettings); - TempArgs.instance := HINSTANCE; - Result := (cef_initialize(@TempArgs, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0); - except - on e : exception do - if CustomExceptionHandler('TCefApplication.InitializeLibrary', e) then raise; + TempArgs.instance := HINSTANCE; + + if (cef_initialize(@TempArgs, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0) then + begin + Result := True; + FStatus := asInitialized; + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplication.InitializeLibrary', e) then raise; + end; + finally + if not(Result) then FStatus := asErrorInitializingLibrary; end; end; @@ -1251,7 +1221,7 @@ end; function TCefApplication.LoadCEFlibrary : boolean; var - TempOldDir : string; + TempOldDir, TempString : string; begin if FSetCurrentDir then begin @@ -1263,8 +1233,12 @@ begin if (FLibHandle = 0) then begin - Result := False; - OutputDebugMessage('TCefApplication.LoadCEFlibrary error: Cannot load libcef.dll. Error code : 0x' + inttohex(GetLastError, 8)); + Result := False; + FStatus := asErrorLoadingLibrary; + TempString := 'Error loading libcef.dll' + CRLF + CRLF + + 'Error code : 0x' + inttohex(GetLastError, 8); + + ShowErrorMessageDlg(TempString); exit; end; @@ -1289,7 +1263,7 @@ begin Load_cef_request_context_capi_h and Load_cef_resource_bundle_capi_h and Load_cef_response_capi_h and - // Load_cef_server_capi_h and + Load_cef_server_capi_h and Load_cef_scheme_capi_h and Load_cef_ssl_info_capi_h and Load_cef_stream_capi_h and @@ -1311,6 +1285,7 @@ begin Load_cef_thread_internal_h and Load_cef_trace_event_internal_h then begin + FStatus := asLoaded; FLibLoaded := True; Result := True; @@ -1320,8 +1295,14 @@ begin end else begin - Result := False; - OutputDebugMessage('TCefApplication.LoadCEFlibrary error: Unsupported CEF version !'); + Result := False; + FStatus := asErrorDLLVersion; + TempString := 'Unsupported CEF version !' + + CRLF + CRLF + + 'Use only the CEF3 binaries specified in the CEF4Delphi Readme.md file at ' + + CRLF + CEF4DELPHI_URL; + + ShowErrorMessageDlg(TempString); end; if FSetCurrentDir then chdir(TempOldDir); diff --git a/source/uCEFChromium.pas b/source/uCEFChromium.pas index 9f363639..35652be9 100644 --- a/source/uCEFChromium.pas +++ b/source/uCEFChromium.pas @@ -124,6 +124,7 @@ type // ICefContextMenuHandler FOnBeforeContextMenu : TOnBeforeContextMenu; + FOnRunContextMenu : TOnRunContextMenu; FOnContextMenuCommand : TOnContextMenuCommand; FOnContextMenuDismissed : TOnContextMenuDismissed; @@ -263,7 +264,6 @@ type procedure InitializeEvents; procedure InitializeSettings(var aSettings : TCefBrowserSettings); - procedure GetSettings(var aSettings : TCefBrowserSettings); procedure GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : string); function UpdateProxyPrefs : boolean; @@ -282,6 +282,20 @@ type procedure HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); procedure HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); + function MustCreateLoadHandler : boolean; virtual; + function MustCreateFocusHandler : boolean; virtual; + function MustCreateContextMenuHandler : boolean; virtual; + function MustCreateDialogHandler : boolean; virtual; + function MustCreateKeyboardHandler : boolean; virtual; + function MustCreateDisplayHandler : boolean; virtual; + function MustCreateDownloadHandler : boolean; virtual; + function MustCreateGeolocationHandler : boolean; virtual; + function MustCreateJsDialogHandler : boolean; virtual; + function MustCreateLifeSpanHandler : boolean; virtual; + function MustCreateRequestHandler : boolean; virtual; + function MustCreateDragHandler : boolean; virtual; + function MustCreateFindHandler : boolean; virtual; + procedure PrefsAvailableMsg(var aMessage : TMessage); function GetParentForm : TCustomForm; procedure ApplyZoomStep; @@ -295,6 +309,9 @@ type procedure DragDropManager_OnDragLeave(Sender: TObject); procedure DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); + // IChromiumEvents + procedure GetSettings(var aSettings : TCefBrowserSettings); + // ICefClient function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; @@ -311,6 +328,7 @@ type // ICefContextMenuHandler procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); virtual; + function doRunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; 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; @@ -574,6 +592,7 @@ type // ICefContextMenuHandler property OnBeforeContextMenu : TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu; + property OnRunContextMenu : TOnRunContextMenu read FOnRunContextMenu write FOnRunContextMenu; property OnContextMenuCommand : TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand; property OnContextMenuDismissed : TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed; @@ -785,7 +804,22 @@ begin if (FHandler = nil) then begin FIsOSR := aIsOsr; - FHandler := TCustomClientHandler.Create(Self, FIsOSR); + FHandler := TCustomClientHandler.Create(Self, + MustCreateLoadHandler, + MustCreateFocusHandler, + MustCreateContextMenuHandler, + MustCreateDialogHandler, + MustCreateKeyboardHandler, + MustCreateDisplayHandler, + MustCreateDownloadHandler, + MustCreateGeolocationHandler, + MustCreateJsDialogHandler, + MustCreateLifeSpanHandler, + FIsOSR, // Create the Render Handler in OSR mode only + MustCreateRequestHandler, + MustCreateDragHandler, + MustCreateFindHandler); + Result := True; end; except @@ -823,6 +857,7 @@ begin // ICefContextMenuHandler FOnBeforeContextMenu := nil; + FOnRunContextMenu := nil; FOnContextMenuCommand := nil; FOnContextMenuDismissed := nil; @@ -2040,7 +2075,7 @@ begin if (TempHWND <> 0) then begin - Winapi.Windows.GetClientRect(TempHWND, TempRect); + {$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect); TempDC := GetDC(TempHWND); TempWidth := TempRect.Right - TempRect.Left; @@ -2520,6 +2555,111 @@ begin if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps); end; +function TChromium.MustCreateLoadHandler : boolean; +begin + Result := assigned(FOnLoadStart) or + assigned(FOnLoadEnd) or + assigned(FOnLoadError) or + assigned(FOnLoadingStateChange); +end; + +function TChromium.MustCreateFocusHandler : boolean; +begin + Result := assigned(FOnTakeFocus) or + assigned(FOnSetFocus) or + assigned(FOnGotFocus); +end; + +function TChromium.MustCreateContextMenuHandler : boolean; +begin + Result := assigned(FOnBeforeContextMenu) or + assigned(FOnRunContextMenu) or + assigned(FOnContextMenuCommand) or + assigned(FOnContextMenuDismissed); +end; + +function TChromium.MustCreateDialogHandler : boolean; +begin + Result := assigned(FOnFileDialog); +end; + +function TChromium.MustCreateKeyboardHandler : boolean; +begin + Result := assigned(FOnPreKeyEvent) or + assigned(FOnKeyEvent); +end; + +function TChromium.MustCreateDisplayHandler : boolean; +begin + Result := assigned(FOnAddressChange) or + assigned(FOnTitleChange) or + assigned(FOnFavIconUrlChange) or + assigned(FOnFullScreenModeChange) or + assigned(FOnTooltip) or + assigned(FOnStatusMessage) or + assigned(FOnConsoleMessage) or + assigned(FOnAutoResize); +end; + +function TChromium.MustCreateDownloadHandler : boolean; +begin + Result := assigned(FOnBeforeDownload) or + assigned(FOnDownloadUpdated); +end; + +function TChromium.MustCreateGeolocationHandler : boolean; +begin + Result := assigned(FOnRequestGeolocationPermission) or + assigned(FOnCancelGeolocationPermission); +end; + +function TChromium.MustCreateJsDialogHandler : boolean; +begin + Result := assigned(FOnJsdialog) or + assigned(FOnBeforeUnloadDialog) or + assigned(FOnResetDialogState) or + assigned(FOnDialogClosed); +end; + +function TChromium.MustCreateLifeSpanHandler : boolean; +begin + Result := assigned(FOnBeforePopup) or + assigned(FOnAfterCreated) or + assigned(FOnBeforeClose) or + assigned(FOnClose); +end; + +function TChromium.MustCreateRequestHandler : boolean; +begin + Result := assigned(FOnBeforeBrowse) or + assigned(FOnOpenUrlFromTab) or + assigned(FOnBeforeResourceLoad) or + assigned(FOnGetResourceHandler) or + assigned(FOnResourceRedirect) or + assigned(FOnResourceResponse) or + assigned(FOnGetResourceResponseFilter) or + assigned(FOnResourceLoadComplete) or + assigned(FOnGetAuthCredentials) or + assigned(FOnQuotaRequest) or + assigned(FOnProtocolExecution) or + assigned(FOnCertificateError) or + assigned(FOnSelectClientCertificate) or + assigned(FOnPluginCrashed) or + assigned(FOnRenderViewReady) or + assigned(FOnRenderProcessTerminated); +end; + +function TChromium.MustCreateDragHandler : boolean; +begin + Result := assigned(FOnDragEnter) or + assigned(FOnDraggableRegionsChanged); +end; + +function TChromium.MustCreateFindHandler : boolean; +begin + Result := assigned(FOnFindResult); +end; + procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage); begin if assigned(FOnPrefsAvailable) then FOnPrefsAvailable(self, (aMessage.WParam <> 0)); @@ -2678,6 +2818,17 @@ begin if Assigned(FOnBeforeContextMenu) then FOnBeforeContextMenu(Self, browser, frame, params, model); end; +function TChromium.doRunContextMenu(const browser : ICefBrowser; + const frame : ICefFrame; + const params : ICefContextMenuParams; + const model : ICefMenuModel; + const callback : ICefRunContextMenuCallback): Boolean; +begin + Result := False; + + if Assigned(FOnRunContextMenu) then FOnRunContextMenu(Self, browser, frame, params, model, callback, Result); +end; + procedure TChromium.doOnBeforeDownload(const browser : ICefBrowser; const downloadItem : ICefDownloadItem; const suggestedName : ustring; @@ -2949,9 +3100,13 @@ begin if not(Initialized) then suppressMessage := True else - if Assigned(FOnJsdialog) then - FOnJsdialog(Self, browser, originUrl, dialogType, messageText, - defaultPromptText, callback, suppressMessage, Result); + begin + suppressMessage := False; + + if Assigned(FOnJsdialog) then + FOnJsdialog(Self, browser, originUrl, dialogType, messageText, + defaultPromptText, callback, suppressMessage, Result); + end; end; function TChromium.doOnKeyEvent(const browser : ICefBrowser; diff --git a/source/uCEFChromiumEvents.pas b/source/uCEFChromiumEvents.pas index 3c462ecb..a818348c 100644 --- a/source/uCEFChromiumEvents.pas +++ b/source/uCEFChromiumEvents.pas @@ -55,25 +55,31 @@ uses uCEFTypes, uCEFInterfaces; type - TOnAccessibilityEvent = procedure(Sender: TObject; const value: ICefValue) of object; - TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : string) of object; - TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; - TOnPrefsAvailableEvent = procedure(Sender: TObject; aResultOK : boolean) of object; - TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object; - TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object; + // ICefClient TOnProcessMessageReceived = procedure(Sender: TObject; const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage; out Result: Boolean) of object; - TOnLoadingStateChange = procedure(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean) of object; + + // ICefLoadHandler TOnLoadStart = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType) of object; TOnLoadEnd = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer) of object; TOnLoadError = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring) of object; + TOnLoadingStateChange = procedure(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean) of object; + + // ICefFocusHandler TOnTakeFocus = procedure(Sender: TObject; const browser: ICefBrowser; next: Boolean) of object; TOnSetFocus = procedure(Sender: TObject; const browser: ICefBrowser; source: TCefFocusSource; out Result: Boolean) of object; TOnGotFocus = procedure(Sender: TObject; const browser: ICefBrowser) of object; + + // ICefContextMenuHandler TOnBeforeContextMenu = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel) of object; + TOnRunContextMenu = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback; var aResult : Boolean) of object; TOnContextMenuCommand = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: TCefEventFlags; out Result: Boolean) of object; TOnContextMenuDismissed = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame) of object; + + // ICefKeyboardHandler TOnPreKeyEvent = procedure(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean; out Result: Boolean) of object; TOnKeyEvent = procedure(Sender: TObject; const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out Result: Boolean) of object; + + // ICefDisplayHandler TOnAddressChange = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const url: ustring) of object; TOnTitleChange = procedure(Sender: TObject; const browser: ICefBrowser; const title: ustring) of object; TOnFavIconUrlChange = procedure(Sender: TObject; const browser: ICefBrowser; const iconUrls: TStrings) of object; @@ -82,18 +88,28 @@ type TOnStatusMessage = procedure(Sender: TObject; const browser: ICefBrowser; const value: ustring) of object; TOnConsoleMessage = procedure(Sender: TObject; const browser: ICefBrowser; const message, source: ustring; line: Integer; out Result: Boolean) of object; TOnAutoResize = procedure(Sender: TObject; const browser: ICefBrowser; const new_size: PCefSize; out Result: Boolean) of object; + + // ICefDownloadHandler TOnBeforeDownload = procedure(Sender: TObject; const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback) of object; TOnDownloadUpdated = procedure(Sender: TObject; const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback) of object; + + // ICefGeolocationHandler TOnRequestGeolocationPermission = procedure(Sender: TObject; const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback; out Result: Boolean) of object; TOnCancelGeolocationPermission = procedure(Sender: TObject; const browser: ICefBrowser; requestId: Integer) of object; + + // ICefJsDialogHandler TOnJsdialog = procedure(Sender: TObject; const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean; out Result: Boolean) of object; TOnBeforeUnloadDialog = procedure(Sender: TObject; const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback; out Result: Boolean) of object; TOnResetDialogState = procedure(Sender: TObject; const browser: ICefBrowser) of object; TOnDialogClosed = procedure(Sender: TObject; const browser: ICefBrowser) of object; + + // ICefLifeSpanHandler TOnBeforePopup = procedure(Sender: TObject; 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; out Result: Boolean) of object; TOnAfterCreated = procedure(Sender: TObject; const browser: ICefBrowser) of object; TOnBeforeClose = procedure(Sender: TObject; const browser: ICefBrowser) of object; TOnClose = procedure(Sender: TObject; const browser: ICefBrowser; out Result: Boolean) of object; + + // ICefRequestHandler TOnBeforeBrowse = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean; out Result: Boolean) of object; TOnOpenUrlFromTab = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean) of Object; TOnBeforeResourceLoad = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback; out Result: TCefReturnValue) of object; @@ -110,7 +126,11 @@ type TOnPluginCrashed = procedure(Sender: TObject; const browser: ICefBrowser; const pluginPath: ustring) of object; TOnRenderViewReady = procedure(Sender: Tobject; const browser: ICefBrowser) of Object; TOnRenderProcessTerminated = procedure(Sender: TObject; const browser: ICefBrowser; status: TCefTerminationStatus) of object; + + // ICefDialogHandler TOnFileDialog = procedure(Sender: TObject; const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback; out Result: Boolean) of Object; + + // ICefRenderHandler TOnGetAccessibilityHandler = procedure(Sender: TObject; var aAccessibilityHandler : ICefAccessibilityHandler) of Object; TOnGetRootScreenRect = procedure(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean) of Object; TOnGetViewRect = procedure(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean) of Object; @@ -124,10 +144,20 @@ type TOnUpdateDragCursor = procedure(Sender: TObject; const browser: ICefBrowser; operation: TCefDragOperation) of Object; TOnScrollOffsetChanged = procedure(Sender: TObject; const browser: ICefBrowser; x, y: Double) of Object; TOnIMECompositionRangeChanged = procedure(Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect) of Object; + + // ICefDragHandler TOnDragEnter = procedure(Sender: TObject; const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations; out Result: Boolean) of Object; TOnDraggableRegionsChanged = procedure(Sender: TObject; const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray)of Object; + + // ICefFindHandler TOnFindResult = procedure(Sender: TObject; const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean) of Object; + // Custom + TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : string) of object; + TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; + TOnPrefsAvailableEvent = procedure(Sender: TObject; aResultOK : boolean) of object; + TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object; + TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object; implementation diff --git a/source/uCEFClient.pas b/source/uCEFClient.pas index 473aaa8b..2c67d876 100644 --- a/source/uCEFClient.pas +++ b/source/uCEFClient.pas @@ -117,23 +117,30 @@ type FDragHandler : ICefDragHandler; FFindHandler : ICefFindHandler; - function GetContextMenuHandler: ICefContextMenuHandler; override; - function GetDialogHandler: ICefDialogHandler; override; - function GetDisplayHandler: ICefDisplayHandler; override; - function GetDownloadHandler: ICefDownloadHandler; override; - function GetDragHandler: ICefDragHandler; override; - function GetFindHandler: ICefFindHandler; override; - function GetFocusHandler: ICefFocusHandler; override; - function GetGeolocationHandler: ICefGeolocationHandler; override; - function GetJsdialogHandler: ICefJsdialogHandler; override; - function GetKeyboardHandler: ICefKeyboardHandler; override; - function GetLifeSpanHandler: ICefLifeSpanHandler; override; - function GetRenderHandler: ICefRenderHandler; override; - function GetLoadHandler: ICefLoadHandler; override; - function GetRequestHandler: ICefRequestHandler; override; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; override; + function GetContextMenuHandler: ICefContextMenuHandler; override; + function GetDialogHandler: ICefDialogHandler; override; + function GetDisplayHandler: ICefDisplayHandler; override; + function GetDownloadHandler: ICefDownloadHandler; override; + function GetDragHandler: ICefDragHandler; override; + function GetFindHandler: ICefFindHandler; override; + function GetFocusHandler: ICefFocusHandler; override; + function GetGeolocationHandler: ICefGeolocationHandler; override; + function GetJsdialogHandler: ICefJsdialogHandler; override; + function GetKeyboardHandler: ICefKeyboardHandler; override; + function GetLifeSpanHandler: ICefLifeSpanHandler; override; + function GetRenderHandler: ICefRenderHandler; override; + function GetLoadHandler: ICefLoadHandler; override; + function GetRequestHandler: ICefRequestHandler; override; + function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; override; + + procedure InitializeInterfaces; + public - constructor Create(const events: IChromiumEvents; renderer: Boolean); reintroduce; virtual; + constructor Create(const events: IChromiumEvents; + aCreateLoadHandler, aCreateFocusHandler, aCreateContextMenuHandler, aCreateDialogHandler, + aCreateKeyboardHandler, aCreateDisplayHandler, aCreateDownloadHandler, aCreateGeolocationHandler, + aCreateJsDialogHandler, aCreateLifeSpanHandler, aCreateRenderHandler, aCreateRequestHandler, + aCreateDragHandler, aCreateFindHandler : boolean); reintroduce; virtual; destructor Destroy; override; end; @@ -152,7 +159,7 @@ uses uCEFFindHandler, uCEFConstants, uCEFApplication; - // ****************************************************** +// ****************************************************** // ****************** TCefClientRef ********************* // ****************************************************** @@ -441,33 +448,55 @@ end; // ****************************************************** -constructor TCustomClientHandler.Create(const events: IChromiumEvents; renderer: Boolean); +constructor TCustomClientHandler.Create(const events : IChromiumEvents; + aCreateLoadHandler : boolean; + aCreateFocusHandler : boolean; + aCreateContextMenuHandler : boolean; + aCreateDialogHandler : boolean; + aCreateKeyboardHandler : boolean; + aCreateDisplayHandler : boolean; + aCreateDownloadHandler : boolean; + aCreateGeolocationHandler : boolean; + aCreateJsDialogHandler : boolean; + aCreateLifeSpanHandler : boolean; + aCreateRenderHandler : boolean; + aCreateRequestHandler : boolean; + aCreateDragHandler : boolean; + aCreateFindHandler : boolean); begin inherited Create; - FEvents := events; + InitializeInterfaces; - FLoadHandler := TCustomLoadHandler.Create(events); - FFocusHandler := TCustomFocusHandler.Create(events); - FContextMenuHandler := TCustomContextMenuHandler.Create(events); - FDialogHandler := TCustomDialogHandler.Create(events); - FKeyboardHandler := TCustomKeyboardHandler.Create(events); - FDisplayHandler := TCustomDisplayHandler.Create(events); - FDownloadHandler := TCustomDownloadHandler.Create(events); - FGeolocationHandler := TCustomGeolocationHandler.Create(events); - FJsDialogHandler := TCustomJsDialogHandler.Create(events); - FLifeSpanHandler := TCustomLifeSpanHandler.Create(events); - FRequestHandler := TCustomRequestHandler.Create(events); - FDragHandler := TCustomDragHandler.Create(events); - FFindHandler := TCustomFindHandler.Create(events); + FEvents := events; - if renderer then - FRenderHandler := TCustomRenderHandler.Create(events) - else - FRenderHandler := nil; + if (FEvents <> nil) then + begin + if aCreateLoadHandler then FLoadHandler := TCustomLoadHandler.Create(FEvents); + if aCreateFocusHandler then FFocusHandler := TCustomFocusHandler.Create(FEvents); + if aCreateContextMenuHandler then FContextMenuHandler := TCustomContextMenuHandler.Create(FEvents); + if aCreateDialogHandler then FDialogHandler := TCustomDialogHandler.Create(FEvents); + if aCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(FEvents); + if aCreateDisplayHandler then FDisplayHandler := TCustomDisplayHandler.Create(FEvents); + if aCreateDownloadHandler then FDownloadHandler := TCustomDownloadHandler.Create(FEvents); + if aCreateGeolocationHandler then FGeolocationHandler := TCustomGeolocationHandler.Create(FEvents); + if aCreateJsDialogHandler then FJsDialogHandler := TCustomJsDialogHandler.Create(FEvents); + if aCreateLifeSpanHandler then FLifeSpanHandler := TCustomLifeSpanHandler.Create(FEvents); + if aCreateRenderHandler then FRenderHandler := TCustomRenderHandler.Create(FEvents); + if aCreateRequestHandler then FRequestHandler := TCustomRequestHandler.Create(FEvents); + if aCreateDragHandler then FDragHandler := TCustomDragHandler.Create(FEvents); + if aCreateFindHandler then FFindHandler := TCustomFindHandler.Create(FEvents); + end; end; destructor TCustomClientHandler.Destroy; +begin + InitializeInterfaces; + + inherited Destroy; +end; + +procedure TCustomClientHandler.InitializeInterfaces; begin FLoadHandler := nil; FFocusHandler := nil; @@ -484,8 +513,6 @@ begin FDragHandler := nil; FFindHandler := nil; FEvents := nil; - - inherited Destroy; end; function TCustomClientHandler.GetContextMenuHandler: ICefContextMenuHandler; @@ -560,7 +587,7 @@ end; function TCustomClientHandler.OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; begin - if Assigned(FEvents) then + if (FEvents <> nil) then Result := FEvents.doOnProcessMessageReceived(browser, sourceProcess, message) else Result := False; diff --git a/source/uCEFConstants.pas b/source/uCEFConstants.pas index 32bcc251..59f9d0bb 100644 --- a/source/uCEFConstants.pas +++ b/source/uCEFConstants.pas @@ -166,10 +166,11 @@ const // /include/internal/cef_types.h (cef_urlrequest_flags_t) UR_FLAG_NONE = 0; UR_FLAG_SKIP_CACHE = 1 shl 0; - UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 shl 1; + UR_FLAG_ONLY_FROM_CACHE = 1 shl 1; + UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 shl 2; UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 shl 3; - UR_FLAG_NO_DOWNLOAD_DATA = 1 shl 6; - UR_FLAG_NO_RETRY_ON_5XX = 1 shl 7; + UR_FLAG_NO_DOWNLOAD_DATA = 1 shl 4; + UR_FLAG_NO_RETRY_ON_5XX = 1 shl 5; // /include/internal/cef_types.h (cef_dom_event_category_t) DOM_EVENT_CATEGORY_UNKNOWN = 0; diff --git a/source/uCEFContextMenuHandler.pas b/source/uCEFContextMenuHandler.pas index 6a701a38..3a371e48 100644 --- a/source/uCEFContextMenuHandler.pas +++ b/source/uCEFContextMenuHandler.pas @@ -66,6 +66,7 @@ type FEvent: IChromiumEvents; procedure OnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); override; + function RunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; override; function OnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: TCefEventFlags): Boolean; override; procedure OnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); override; @@ -180,6 +181,18 @@ begin if (FEvent <> nil) then FEvent.doOnBeforeContextMenu(browser, frame, params, model); end; +function TCustomContextMenuHandler.RunContextMenu(const browser : ICefBrowser; + const frame : ICefFrame; + const params : ICefContextMenuParams; + const model : ICefMenuModel; + const callback : ICefRunContextMenuCallback): Boolean; +begin + if (FEvent <> nil) then + Result := FEvent.doRunContextMenu(browser, frame, params, model, callback) + else + Result := inherited RunContextMenu(browser, frame, params, model, callback); +end; + function TCustomContextMenuHandler.OnContextMenuCommand(const browser : ICefBrowser; const frame : ICefFrame; const params : ICefContextMenuParams; diff --git a/source/uCEFInterfaces.pas b/source/uCEFInterfaces.pas index 86466f0e..ba16b446 100644 --- a/source/uCEFInterfaces.pas +++ b/source/uCEFInterfaces.pas @@ -526,10 +526,8 @@ type ICefDownloadHandler = interface(ICefBaseRefCounted) ['{3137F90A-5DC5-43C1-858D-A269F28EF4F1}'] - procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; - const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); - procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; - const callback: ICefDownloadItemCallback); + procedure OnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); + procedure OnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); end; ICefV8Exception = interface(ICefBaseRefCounted) @@ -1197,15 +1195,10 @@ type ICefLifeSpanHandler = interface(ICefBaseRefCounted) ['{0A3EB782-A319-4C35-9B46-09B2834D7169}'] - function OnBeforePopup(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; + function OnBeforePopup(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; procedure OnAfterCreated(const browser: ICefBrowser); procedure OnBeforeClose(const browser: ICefBrowser); - function DoClose(const browser: ICefBrowser): Boolean; + function DoClose(const browser: ICefBrowser): Boolean; end; @@ -1300,26 +1293,20 @@ type ICefFocusHandler = interface(ICefBaseRefCounted) ['{BB7FA3FA-7B1A-4ADC-8E50-12A24018DD90}'] procedure OnTakeFocus(const browser: ICefBrowser; next: Boolean); - function OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; + function OnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; procedure OnGotFocus(const browser: ICefBrowser); end; ICefKeyboardHandler = interface(ICefBaseRefCounted) ['{0512F4EC-ED88-44C9-90D3-5C6D03D3B146}'] - function OnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; - osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; - function OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; - osEvent: TCefEventHandle): Boolean; + function OnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; + function OnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; end; ICefJsDialogHandler = interface(ICefBaseRefCounted) ['{64E18F86-DAC5-4ED1-8589-44DE45B9DB56}'] - function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; - dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; - const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; - function OnBeforeUnloadDialog(const browser: ICefBrowser; - const messageText: ustring; isReload: Boolean; - const callback: ICefJsDialogCallback): Boolean; + function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; + function OnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; procedure OnResetDialogState(const browser: ICefBrowser); procedure OnDialogClosed(const browser: ICefBrowser); end; @@ -1332,14 +1319,9 @@ type ICefContextMenuHandler = interface(ICefBaseRefCounted) ['{C2951895-4087-49D5-BA18-4D9BA4F5EDD7}'] - procedure OnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; - const params: ICefContextMenuParams; const model: ICefMenuModel); - function RunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; - const params: ICefContextMenuParams; const model: ICefMenuModel; - const callback: ICefRunContextMenuCallback): Boolean; - function OnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; - const params: ICefContextMenuParams; commandId: Integer; - eventFlags: TCefEventFlags): Boolean; + procedure OnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); + function RunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; + function OnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: TCefEventFlags): Boolean; procedure OnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); end; @@ -1351,9 +1333,7 @@ type ICefDialogHandler = interface(ICefBaseRefCounted) ['{7763F4B2-8BE1-4E80-AC43-8B825850DC67}'] - function OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; - const title, defaultFilePath: ustring; acceptFilters: TStrings; - selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; + function OnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; end; ICefGeolocationCallback = interface(ICefBaseRefCounted) @@ -1363,7 +1343,7 @@ type ICefGeolocationHandler = interface(ICefBaseRefCounted) ['{1178EE62-BAE7-4E44-932B-EAAC7A18191C}'] - function OnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; + function OnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; procedure OnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); end; @@ -1482,17 +1462,13 @@ type ICefDragHandler = interface(ICefBaseRefCounted) ['{59A89579-5B18-489F-A25C-5CC25FF831FC}'] - function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; - mask: TCefDragOperations): Boolean; - procedure OnDraggableRegionsChanged(const browser: ICefBrowser; - regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); end; ICefFindHandler = interface(ICefBaseRefCounted) ['{F20DF234-BD43-42B3-A80B-D354A9E5B787}'] - procedure OnFindResult(const browser: ICefBrowser; - identifier, count: Integer; const selectionRect: PCefRect; - activeMatchOrdinal: Integer; finalUpdate: Boolean); + procedure OnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); end; ICefRequestContextHandler = interface(ICefBaseRefCounted) @@ -1718,134 +1694,106 @@ type IChromiumEvents = interface ['{0C139DB1-0349-4D7F-8155-76FEA6A0126D}'] procedure GetSettings(var settings: TCefBrowserSettings); - function doOnProcessMessageReceived(const browser: ICefBrowser; - sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; + // ICefClient + function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; + + // ICefLoadHandler procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); procedure doOnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); - procedure doOnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; - const errorText, failedUrl: ustring); + procedure doOnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); + // ICefFocusHandler procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); - function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; + function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; procedure doOnGotFocus(const browser: ICefBrowser); - procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; - const params: ICefContextMenuParams; const model: ICefMenuModel); - function doOnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; - const params: ICefContextMenuParams; commandId: Integer; - eventFlags: TCefEventFlags): Boolean; + // ICefContextMenuHandler + procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); + function doRunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; + function doOnContextMenuCommand(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: TCefEventFlags): Boolean; procedure doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); - function doOnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; - osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; - function doOnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; - osEvent: TCefEventHandle): Boolean; + // ICefKeyboardHandler + function doOnPreKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; + function doOnKeyEvent(const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: TCefEventHandle): Boolean; + // ICefDisplayHandler procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); procedure doOnFaviconUrlChange(const browser: ICefBrowser; iconUrls: TStrings); procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); - function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; + function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); - function doOnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean; - function doOnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; + function doOnConsoleMessage(const browser: ICefBrowser; const message, source: ustring; line: Integer): Boolean; + function doOnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; - function doOnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; + // ICefDownloadHandler + procedure doOnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); + procedure doOnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const callback: ICefDownloadItemCallback); + + // ICefGeolocationHandler + function doOnRequestGeolocationPermission(const browser: ICefBrowser; const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback): Boolean; procedure doOnCancelGeolocationPermission(const browser: ICefBrowser; requestId: Integer); - procedure doOnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; - const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); - procedure doOnDownloadUpdated(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; - const callback: ICefDownloadItemCallback); - - function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; - dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; - const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; - function doOnBeforeUnloadDialog(const browser: ICefBrowser; - const messageText: ustring; isReload: Boolean; - const callback: ICefJsDialogCallback): Boolean; + // ICefJsDialogHandler + function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; + function doOnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; procedure doOnResetDialogState(const browser: ICefBrowser); procedure doOnDialogClosed(const browser: ICefBrowser); - 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; + // 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; procedure doOnAfterCreated(const browser: ICefBrowser); procedure doOnBeforeClose(const browser: ICefBrowser); - function doOnClose(const browser: ICefBrowser): Boolean; + function doOnClose(const browser: ICefBrowser): Boolean; - function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest; isRedirect: Boolean): Boolean; - function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; - const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; - userGesture: Boolean): Boolean; - function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; - function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest): ICefResourceHandler; - procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); - function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest; const response: ICefResponse): Boolean; - function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; - procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; - const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; - receivedContentLength: Int64); - function doOnGetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; - isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; - const callback: ICefAuthCallback): Boolean; - function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; - newSize: Int64; const callback: ICefRequestCallback): Boolean; + // ICefRequestHandler + function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; isRedirect: Boolean): Boolean; + function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; + function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; + function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; + procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); + function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; + function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; + procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); + function doOnGetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); - function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; - const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; + function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); procedure doOnRenderViewReady(const browser: ICefBrowser); procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); + // ICefDialogHandler + function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; - function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; - const title, defaultFilePath: ustring; acceptFilters: TStrings; - selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; - + // ICefRenderHandler procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); - function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; - function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; - function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; - var screenX, screenY: Integer): Boolean; - function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; + function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; + function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; + function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; + function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); - procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; - dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; - const buffer: Pointer; width, height: Integer); - procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; - cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); - function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; - allowedOps: TCefDragOperations; x, y: Integer): Boolean; + procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); + procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); + function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); - procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; - const selected_range: PCefRange; - character_boundsCount: NativeUInt; - const character_bounds: PCefRect); + procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); - function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; - mask: TCefDragOperations): Boolean; - procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; - regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + // ICefDragHandler + function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; + procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); - procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; - const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); + // ICefFindHandler + procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); end; + ICefServer = interface(ICefBaseRefCounted) ['{41D41764-A74B-4552-B166-C77E70549047}'] function GetTaskRunner : ICefTaskRunner; @@ -1857,7 +1805,7 @@ type procedure SendHttp200response(connection_id: Integer; const content_type: ustring; const data: Pointer; data_size: NativeUInt); procedure SendHttp404response(connection_id: Integer); procedure SendHttp500response(connection_id: Integer; const error_message: ustring); - procedure SendHttpResponse(connection_id, response_code: Integer; const content_type: ustring; content_length: int64; headerMap: TCefStringMultimap); + procedure SendHttpResponse(connection_id, response_code: Integer; const content_type: ustring; content_length: int64; const headerMap: ICefStringMultimap); procedure SendRawData(connection_id: Integer; const data: Pointer; data_size: NativeUInt); procedure CloseConnection(connection_id: Integer); procedure SendWebSocketMessage(connection_id: Integer; const data: Pointer; data_size: NativeUInt); @@ -1875,6 +1823,18 @@ type procedure OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); end; + IServerEvents = interface + ['{06A1B3C6-0967-4F6C-A751-8AA3A29E2FF5}'] + procedure doOnServerCreated(const server: ICefServer); + procedure doOnServerDestroyed(const server: ICefServer); + procedure doOnClientConnected(const server: ICefServer; connection_id: Integer); + procedure doOnClientDisconnected(const server: ICefServer; connection_id: Integer); + procedure doOnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); + procedure doOnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); + procedure doOnWebSocketConnected(const server: ICefServer; connection_id: Integer); + procedure doOnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); + end; + implementation end. diff --git a/source/uCEFJsDialogCallback.pas b/source/uCEFJsDialogCallback.pas index b3ffe294..ea68733c 100644 --- a/source/uCEFJsDialogCallback.pas +++ b/source/uCEFJsDialogCallback.pas @@ -51,10 +51,10 @@ uses type TCefJsDialogCallbackRef = class(TCefBaseRefCountedRef, ICefJsDialogCallback) - protected - procedure Cont(success: Boolean; const userInput: ustring); - public - class function UnWrap(data: Pointer): ICefJsDialogCallback; + protected + procedure Cont(success: Boolean; const userInput: ustring); + public + class function UnWrap(data: Pointer): ICefJsDialogCallback; end; @@ -63,8 +63,7 @@ implementation uses uCEFMiscFunctions, uCEFLibFunctions; -procedure TCefJsDialogCallbackRef.Cont(success: Boolean; - const userInput: ustring); +procedure TCefJsDialogCallbackRef.Cont(success: Boolean; const userInput: ustring); var ui: TCefString; begin @@ -72,11 +71,11 @@ begin PCefJsDialogCallback(FData).cont(PCefJsDialogCallback(FData), Ord(success), @ui); end; -class function TCefJsDialogCallbackRef.UnWrap( - data: Pointer): ICefJsDialogCallback; +class function TCefJsDialogCallbackRef.UnWrap(data: Pointer): ICefJsDialogCallback; begin - if data <> nil then - Result := Create(data) as ICefJsDialogCallback else + if (data <> nil) then + Result := Create(data) as ICefJsDialogCallback + else Result := nil; end; diff --git a/source/uCEFJsDialogHandler.pas b/source/uCEFJsDialogHandler.pas index 663d1892..ceea4edc 100644 --- a/source/uCEFJsDialogHandler.pas +++ b/source/uCEFJsDialogHandler.pas @@ -52,8 +52,8 @@ uses type TCefJsDialogHandlerOwn = class(TCefBaseRefCountedOwn, ICefJsDialogHandler) protected - function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; virtual; - function OnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; virtual; + function OnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; virtual; + function OnBeforeUnloadDialog(const browser: ICefBrowser; const messageText: ustring; isReload: Boolean; const callback: ICefJsDialogCallback): Boolean; virtual; procedure OnResetDialogState(const browser: ICefBrowser); virtual; procedure OnDialogClosed(const browser: ICefBrowser); virtual; @@ -80,18 +80,28 @@ implementation uses uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFJsDialogCallback; -function cef_jsdialog_handler_on_jsdialog(self: PCefJsDialogHandler; - browser: PCefBrowser; const origin_url: PCefString; - dialog_type: TCefJsDialogType; const message_text, default_prompt_text: PCefString; - callback: PCefJsDialogCallback; suppress_message: PInteger): Integer; stdcall; +function cef_jsdialog_handler_on_jsdialog(self : PCefJsDialogHandler; + browser : PCefBrowser; + const origin_url : PCefString; + dialog_type : TCefJsDialogType; + const message_text : PCefString; + const default_prompt_text : PCefString; + callback : PCefJsDialogCallback; + suppress_message : PInteger): Integer; stdcall; var sm: Boolean; begin sm := suppress_message^ <> 0; + with TCefJsDialogHandlerOwn(CefGetObject(self)) do - Result := Ord(OnJsdialog(TCefBrowserRef.UnWrap(browser), CefString(origin_url), - dialog_type, CefString(message_text), CefString(default_prompt_text), - TCefJsDialogCallbackRef.UnWrap(callback), sm)); + Result := Ord(OnJsdialog(TCefBrowserRef.UnWrap(browser), + CefString(origin_url), + dialog_type, + CefString(message_text), + CefString(default_prompt_text), + TCefJsDialogCallbackRef.UnWrap(callback), + sm)); + suppress_message^ := Ord(sm); end; @@ -136,7 +146,8 @@ function TCefJsDialogHandlerOwn.OnJsdialog(const browser: ICefBrowser; const callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; begin - Result := False; + Result := False; + suppressMessage := False; end; function TCefJsDialogHandlerOwn.OnBeforeUnloadDialog(const browser: ICefBrowser; @@ -197,6 +208,8 @@ function TCustomJsDialogHandler.OnJsdialog(const browser : ICefBrowser const callback : ICefJsDialogCallback; out suppressMessage : Boolean): Boolean; begin + suppressMessage := False; + if (FEvent <> nil) then Result := FEvent.doOnJsdialog(browser, originUrl, dialogType, messageText, defaultPromptText, callback, suppressMessage) else diff --git a/source/uCEFMiscFunctions.pas b/source/uCEFMiscFunctions.pas index 63576af8..33be73ae 100644 --- a/source/uCEFMiscFunctions.pas +++ b/source/uCEFMiscFunctions.pas @@ -138,11 +138,12 @@ function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersion function SplitLongString(aSrcString : string) : string; function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean; -function CheckLocales(const aLocalesDirPath : string; const aLocalesRequired : string = '') : boolean; -function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean = True) : boolean; -function CheckDLLs(const aFrameworkDirPath : string) : boolean; +function CheckLocales(const aLocalesDirPath : string; var aMissingFiles : string; const aLocalesRequired : string = '') : boolean; +function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean = True) : boolean; +function CheckDLLs(const aFrameworkDirPath : string; var aMissingFiles : string) : boolean; function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean; function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string; +function CheckFilesExist(var aList : TStringList; var aMissingFiles : string) : boolean; function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean; function CefCreateUrl(var parts: TUrlParts): ustring; @@ -604,42 +605,26 @@ begin end; end; -function CheckLocaleFile(const aLocalesDirPath, aLocale : string) : boolean; +function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean; begin - Result := FileExists(aLocalesDirPath + aLocale + '.pak'); + Result := True; + + if (length(aSrcPath) > 0) then + begin + aRsltPath := IncludeTrailingPathDelimiter(aSrcPath); + + if DirectoryExists(aSrcPath) then + begin + if CustomPathIsRelative(aRsltPath) then aRsltPath := GetModulePath + aRsltPath; + end + else + Result := False; + end + else + aRsltPath := ''; end; -function CheckLocaleFiles(const aLocalesDirPath, aLocalesRequired : string) : boolean; -var - TempLocaleList : TStrings; - TempLocale : string; - i, j : integer; -begin - Result := True; - TempLocaleList := TStringList.Create; - - try - TempLocaleList.CommaText := aLocalesRequired; - - i := 0; - j := TempLocaleList.Count; - - while (i < j) and Result do - begin - TempLocale := trim(TempLocaleList[i]); - - // avoid typing mistakes - if (Length(TempLocale) > 0) then - Result := Result and CheckLocaleFile(aLocalesDirPath, TempLocale); - - inc(i); - end; - finally - FreeAndNil(TempLocaleList); - end; -end; - -function CheckLocales(const aLocalesDirPath, aLocalesRequired : string) : boolean; +function CheckLocales(const aLocalesDirPath : string; var aMissingFiles : string; const aLocalesRequired : string) : boolean; const LOCALES_REQUIRED_DEFAULT = 'am,' + @@ -696,100 +681,152 @@ const 'zh-CN,' + 'zh-TW'; var - TempDir : string; - TempLocalesRequired : string; + i : integer; + TempDir : string; + TempList : TStringList; begin - Result := False; + Result := False; + TempList := nil; try - if (length(aLocalesDirPath) > 0) then - TempDir := aLocalesDirPath - else - TempDir := 'locales'; - - if DirectoryExists(TempDir) then - begin - TempDir := IncludeTrailingPathDelimiter(TempDir); - - if (length(aLocalesRequired) > 0) then - TempLocalesRequired := aLocalesRequired - else - TempLocalesRequired := LOCALES_REQUIRED_DEFAULT; - - Result := CheckLocaleFiles(TempDir, TempLocalesRequired); - end; - except - on e : exception do - if CustomExceptionHandler('CheckLocales', e) then raise; - end; -end; - -function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean; -begin - Result := True; - - if (length(aSrcPath) > 0) then - begin - if DirectoryExists(aSrcPath) then - begin - aRsltPath := IncludeTrailingPathDelimiter(aSrcPath); - if CustomPathIsRelative(aRsltPath) then aRsltPath := GetModulePath + aRsltPath; - end + try + if (length(aLocalesDirPath) > 0) then + TempDir := IncludeTrailingPathDelimiter(aLocalesDirPath) else - Result := False; - end - else - aRsltPath := ''; + TempDir := 'locales\'; + + TempList := TStringList.Create; + + if (length(aLocalesRequired) > 0) then + TempList.CommaText := aLocalesRequired + else + TempList.CommaText := LOCALES_REQUIRED_DEFAULT; + + i := 0; + while (i < TempList.Count) do + begin + TempList[i] := TempDir + TempList[i] + '.pak'; + inc(i); + end; + + if DirectoryExists(TempDir) then + Result := CheckFilesExist(TempList, aMissingFiles) + else + aMissingFiles := trim(aMissingFiles) + CRLF + TempList.Text; + except + on e : exception do + if CustomExceptionHandler('CheckLocales', e) then raise; + end; + finally + if (TempList <> nil) then FreeAndNil(TempList); + end; end; -function CheckResources(const aResourcesDirPath : string; aCheckDevResources: boolean) : boolean; +function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean) : boolean; var - TempDir : string; + TempDir : string; + TempList : TStringList; + TempExists : boolean; begin Result := False; try - Result := GetAbsoluteDirPath(aResourcesDirPath, TempDir) and - FileExists(TempDir + 'natives_blob.bin') and - FileExists(TempDir + 'snapshot_blob.bin') and - FileExists(TempDir + 'v8_context_snapshot.bin') and - FileExists(TempDir + 'cef.pak') and - FileExists(TempDir + 'cef_100_percent.pak') and - FileExists(TempDir + 'cef_200_percent.pak') and - FileExists(TempDir + 'cef_extensions.pak') and - (not(aCheckDevResources) or FileExists(TempDir + 'devtools_resources.pak')); - except - on e : exception do - if CustomExceptionHandler('CheckResources', e) then raise; + try + TempExists := GetAbsoluteDirPath(aResourcesDirPath, TempDir); + + TempList := TStringList.Create; + TempList.Add(TempDir + 'natives_blob.bin'); + TempList.Add(TempDir + 'snapshot_blob.bin'); + TempList.Add(TempDir + 'v8_context_snapshot.bin'); + TempList.Add(TempDir + 'cef.pak'); + TempList.Add(TempDir + 'cef_100_percent.pak'); + TempList.Add(TempDir + 'cef_200_percent.pak'); + TempList.Add(TempDir + 'cef_extensions.pak'); + + if aCheckDevResources then TempList.Add(TempDir + 'devtools_resources.pak'); + + if TempExists then + Result := CheckFilesExist(TempList, aMissingFiles) + else + aMissingFiles := trim(aMissingFiles) + CRLF + TempList.Text; + except + on e : exception do + if CustomExceptionHandler('CheckResources', e) then raise; + end; + finally + if (TempList <> nil) then FreeAndNil(TempList); end; end; -function CheckDLLs(const aFrameworkDirPath : string) : boolean; +function CheckDLLs(const aFrameworkDirPath : string; var aMissingFiles : string) : boolean; var - TempDir : string; + TempDir : string; + TempList : TStringList; + TempExists : boolean; begin - Result := False; + Result := False; + TempList := nil; try - // The icudtl.dat file must be placed next to libcef.dll - // http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=14503#p32263 - Result := GetAbsoluteDirPath(aFrameworkDirPath, TempDir) and - FileExists(TempDir + CHROMEELF_DLL) and - FileExists(TempDir + LIBCEF_DLL) and - FileExists(TempDir + 'd3dcompiler_43.dll') and - FileExists(TempDir + 'd3dcompiler_47.dll') and - FileExists(TempDir + 'libEGL.dll') and - FileExists(TempDir + 'libGLESv2.dll') and - FileExists(TempDir + 'swiftshader\libEGL.dll') and - FileExists(TempDir + 'swiftshader\libGLESv2.dll') and - FileExists(TempDir + 'icudtl.dat') and - FileExists(TempDir + 'widevinecdmadapter.dll'); - except - on e : exception do - if CustomExceptionHandler('CheckDLLs', e) then raise; + try + TempExists := GetAbsoluteDirPath(aFrameworkDirPath, TempDir); + + // The icudtl.dat file must be placed next to libcef.dll + // http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=14503#p32263 + + TempList := TStringList.Create; + TempList.Add(TempDir + CHROMEELF_DLL); + TempList.Add(TempDir + LIBCEF_DLL); + TempList.Add(TempDir + 'd3dcompiler_43.dll'); + TempList.Add(TempDir + 'd3dcompiler_47.dll'); + TempList.Add(TempDir + 'libEGL.dll'); + TempList.Add(TempDir + 'libGLESv2.dll'); + TempList.Add(TempDir + 'swiftshader\libEGL.dll'); + TempList.Add(TempDir + 'swiftshader\libGLESv2.dll'); + TempList.Add(TempDir + 'icudtl.dat'); + TempList.Add(TempDir + 'widevinecdmadapter.dll'); + + if TempExists then + Result := CheckFilesExist(TempList, aMissingFiles) + else + aMissingFiles := trim(aMissingFiles) + CRLF + TempList.Text; + except + on e : exception do + if CustomExceptionHandler('CheckDLLs', e) then raise; + end; + finally + if (TempList <> nil) then FreeAndNil(TempList); end; end; +function CheckFilesExist(var aList : TStringList; var aMissingFiles : string) : boolean; +var + i : integer; +begin + Result := True; + + try + if (aList <> nil) then + begin + i := 0; + + while (i < aList.Count) do + begin + if (length(aList[i]) > 0) and not(FileExists(aList[i])) then + begin + Result := False; + aMissingFiles := aMissingFiles + aList[i] + CRLF; + end; + + inc(i); + end; + end; + except + on e : exception do + if CustomExceptionHandler('CheckFilesExist', e) then raise; + end; +end; + procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo); begin aVersionInfo.MajorVer := uint16(aVersion shr 48); diff --git a/source/uCEFRegisterComponents.pas b/source/uCEFRegisterComponents.pas index b06be6a9..7bff2834 100644 --- a/source/uCEFRegisterComponents.pas +++ b/source/uCEFRegisterComponents.pas @@ -53,11 +53,13 @@ uses {$ELSE} Classes, {$ENDIF} - uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler; + uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler, + uCEFServerComponent; procedure Register; begin - RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, TCEFWorkScheduler]); + RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, + TCEFWorkScheduler, TCEFServerComponent]); end; end. diff --git a/source/uCEFServer.pas b/source/uCEFServer.pas new file mode 100644 index 00000000..95b91e9a --- /dev/null +++ b/source/uCEFServer.pas @@ -0,0 +1,164 @@ +// ************************************************************************ +// ***************************** 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 uCEFServer; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCEFServerRef = class(TCefBaseRefCountedRef, ICefServer) + protected + function GetTaskRunner : ICefTaskRunner; virtual; + procedure Shutdown; virtual; + function IsRunning : boolean; virtual; + function GetAddress : ustring; virtual; + function HasConnection : boolean; virtual; + function IsValidConnection(connection_id: Integer) : boolean; virtual; + procedure SendHttp200response(connection_id: Integer; const content_type: ustring; const data: Pointer; data_size: NativeUInt); virtual; + procedure SendHttp404response(connection_id: Integer); virtual; + procedure SendHttp500response(connection_id: Integer; const error_message: ustring); virtual; + procedure SendHttpResponse(connection_id, response_code: Integer; const content_type: ustring; content_length: int64; const headerMap: ICefStringMultimap); virtual; + procedure SendRawData(connection_id: Integer; const data: Pointer; data_size: NativeUInt); virtual; + procedure CloseConnection(connection_id: Integer); virtual; + procedure SendWebSocketMessage(connection_id: Integer; const data: Pointer; data_size: NativeUInt); virtual; + + public + class function UnWrap(data: Pointer): ICefServer; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFTaskRunner; + +// ****************************************************** +// ****************** TCEFServerRef ********************* +// ****************************************************** + +class function TCEFServerRef.UnWrap(data: Pointer): ICefServer; +begin + if (data <> nil) then + Result := Create(data) as ICefServer + else + Result := nil; +end; + +function TCEFServerRef.GetTaskRunner : ICefTaskRunner; +begin + Result := TCefTaskRunnerRef.UnWrap(PCefServer(FData).get_task_runner(PCefServer(FData))); +end; + +procedure TCEFServerRef.Shutdown; +begin + PCefServer(FData).shutdown(PCefServer(FData)); +end; + +function TCEFServerRef.IsRunning : boolean; +begin + Result := PCefServer(FData).is_running(PCefServer(FData)) <> 0; +end; + +function TCEFServerRef.GetAddress : ustring; +begin + Result := CefStringFreeAndGet(PCefServer(FData).get_address(PCefServer(FData))); +end; + +function TCEFServerRef.HasConnection : boolean; +begin + Result := PCefServer(FData).has_connection(PCefServer(FData)) <> 0; +end; + +function TCEFServerRef.IsValidConnection(connection_id: Integer) : boolean; +begin + Result := PCefServer(FData).is_valid_connection(PCefServer(FData), connection_id) <> 0; +end; + +procedure TCEFServerRef.SendHttp200response(connection_id: Integer; const content_type: ustring; const data: Pointer; data_size: NativeUInt); +var + TempContentType : TCefString; +begin + TempContentType := CefString(content_type); + PCefServer(FData).send_http200response(PCefServer(FData), connection_id, @TempContentType, data, data_size); +end; + +procedure TCEFServerRef.SendHttp404response(connection_id: Integer); +begin + PCefServer(FData).send_http404response(PCefServer(FData), connection_id); +end; + +procedure TCEFServerRef.SendHttp500response(connection_id: Integer; const error_message: ustring); +var + TempError : TCefString; +begin + TempError := CefString(error_message); + PCefServer(FData).send_http500response(PCefServer(FData), connection_id, @TempError); +end; + +procedure TCEFServerRef.SendHttpResponse(connection_id, response_code: Integer; const content_type: ustring; content_length: int64; const headerMap: ICefStringMultimap); +var + TempContentType : TCefString; +begin + TempContentType := CefString(content_type); + PCefServer(FData).send_http_response(PCefServer(FData), connection_id, response_code, @TempContentType, content_length, headerMap.Handle); +end; + +procedure TCEFServerRef.SendRawData(connection_id: Integer; const data: Pointer; data_size: NativeUInt); +begin + PCefServer(FData).send_raw_data(PCefServer(FData), connection_id, data, data_size); +end; + +procedure TCEFServerRef.CloseConnection(connection_id: Integer); +begin + PCefServer(FData).close_connection(PCefServer(FData), connection_id); +end; + +procedure TCEFServerRef.SendWebSocketMessage(connection_id: Integer; const data: Pointer; data_size: NativeUInt); +begin + PCefServer(FData).send_web_socket_message(PCefServer(FData), connection_id, data, data_size); +end; + +end. diff --git a/source/uCEFServerComponent.pas b/source/uCEFServerComponent.pas new file mode 100644 index 00000000..e573d428 --- /dev/null +++ b/source/uCEFServerComponent.pas @@ -0,0 +1,325 @@ +// ************************************************************************ +// ***************************** 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 uCEFServerComponent; + +{$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, System.Math, + {$ELSE} + Windows, Messages, Classes, Controls, Graphics, Forms, ActiveX, Math, + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFServer, uCEFServerEvents, uCEFServerHandler; + +const + DEFAULT_CEFSERVER_ADDRESS = '127.0.0.1'; + DEFAULT_CEFSERVER_PORT = 8099; + DEFAULT_CEFSERVER_BACKLOG = 10; + +type + TCEFServerComponent = class(TComponent, IServerEvents) + protected + FHandler : ICefServerHandler; + FServer : ICefServer; + FInitialized : boolean; + + // IServerEvents + FOnServerCreated : TOnServerCreated; + FOnServerDestroyed : TOnServerDestroyed; + FOnClientConnected : TOnClientConnected; + FOnClientDisconnected : TOnClientDisconnected; + FOnHttpRequest : TOnHttpRequest; + FOnWebSocketRequest : TOnWebSocketRequest; + FOnWebSocketConnected : TOnWebSocketConnected; + FOnWebSocketMessage : TOnWebSocketMessage; + + function GetInitialized : boolean; + function GetIsRunning : boolean; + function GetAddress : ustring; + function GetHasConnection : boolean; + + // IServerEvents + procedure doOnServerCreated(const server: ICefServer); virtual; + procedure doOnServerDestroyed(const server: ICefServer); virtual; + procedure doOnClientConnected(const server: ICefServer; connection_id: Integer); virtual; + procedure doOnClientDisconnected(const server: ICefServer; connection_id: Integer); virtual; + procedure doOnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); virtual; + procedure doOnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); virtual; + procedure doOnWebSocketConnected(const server: ICefServer; connection_id: Integer); virtual; + procedure doOnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); virtual; + + procedure InitializeEvents; + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + procedure CreateServer(const address : ustring = DEFAULT_CEFSERVER_ADDRESS; port : uint16 = DEFAULT_CEFSERVER_PORT; backlog : Integer = DEFAULT_CEFSERVER_BACKLOG); + procedure Shutdown; + function IsValidConnection(connection_id: Integer) : boolean; + procedure SendHttp200response(connection_id: Integer; const content_type: ustring; const data: Pointer; data_size: NativeUInt); + procedure SendHttp404response(connection_id: Integer); + procedure SendHttp500response(connection_id: Integer; const error_message: ustring); + procedure SendHttpResponse(connection_id, response_code: Integer; const content_type: ustring; content_length: int64; const headerMap: ICefStringMultimap); + procedure SendRawData(connection_id: Integer; const data: Pointer; data_size: NativeUInt); + procedure CloseConnection(connection_id: Integer); + procedure SendWebSocketMessage(connection_id: Integer; const data: Pointer; data_size: NativeUInt); + + property Initialized : boolean read GetInitialized; + property IsRunning : boolean read GetIsRunning; + property Address : ustring read GetAddress; + property HasConnection : boolean read GetHasConnection; + + published + property OnServerCreated : TOnServerCreated read FOnServerCreated write FOnServerCreated; + property OnServerDestroyed : TOnServerDestroyed read FOnServerDestroyed write FOnServerDestroyed; + property OnClientConnected : TOnClientConnected read FOnClientConnected write FOnClientConnected; + property OnClientDisconnected : TOnClientDisconnected read FOnClientDisconnected write FOnClientDisconnected; + property OnHttpRequest : TOnHttpRequest read FOnHttpRequest write FOnHttpRequest; + property OnWebSocketRequest : TOnWebSocketRequest read FOnWebSocketRequest write FOnWebSocketRequest; + property OnWebSocketConnected : TOnWebSocketConnected read FOnWebSocketConnected write FOnWebSocketConnected; + property OnWebSocketMessage : TOnWebSocketMessage read FOnWebSocketMessage write FOnWebSocketMessage; + end; + +implementation + +uses + uCEFLibFunctions, uCEFApplication, uCEFMiscFunctions; + +// For more information about the TCEFServerComponent properties and functions +// read the code comments in the CEF3 source file /include/capi/cef_server_cap.h + +constructor TCEFServerComponent.Create(AOwner: TComponent); +begin + inherited Create(aOwner); + + FHandler := nil; + FServer := nil; + FInitialized := False; + + InitializeEvents; +end; + +destructor TCEFServerComponent.Destroy; +begin + FServer := nil; + FHandler := nil; + + inherited Destroy; +end; + +procedure TCEFServerComponent.InitializeEvents; +begin + FOnServerCreated := nil; + FOnServerDestroyed := nil; + FOnClientConnected := nil; + FOnClientDisconnected := nil; + FOnHttpRequest := nil; + FOnWebSocketRequest := nil; + FOnWebSocketConnected := nil; + FOnWebSocketMessage := nil; +end; + +function TCEFServerComponent.GetInitialized : boolean; +begin + Result := FInitialized and (FHandler <> nil) and (FServer <> nil); +end; + +function TCEFServerComponent.GetIsRunning : boolean; +begin + Result := Initialized and FServer.IsRunning; +end; + +function TCEFServerComponent.GetAddress : ustring; +begin + if Initialized then + Result := FServer.GetAddress + else + Result := ''; +end; + +function TCEFServerComponent.GetHasConnection : boolean; +begin + Result := Initialized and FServer.HasConnection; +end; + +procedure TCEFServerComponent.doOnServerCreated(const server: ICefServer); +begin + if (FServer = nil) and + (server <> nil) and + server.IsRunning and + not(server.HasConnection) then + begin + FServer := server; + FInitialized := True; + end; + + if assigned(FOnServerCreated) then FOnServerCreated(self, server); +end; + +procedure TCEFServerComponent.doOnServerDestroyed(const server: ICefServer); +begin + if assigned(FOnServerDestroyed) then FOnServerDestroyed(self, server); + + FServer := nil; + FInitialized := False; +end; + +procedure TCEFServerComponent.doOnClientConnected(const server: ICefServer; connection_id: Integer); +begin + if assigned(FOnClientConnected) then FOnClientConnected(self, server, connection_id); +end; + +procedure TCEFServerComponent.doOnClientDisconnected(const server: ICefServer; connection_id: Integer); +begin + if assigned(FOnClientDisconnected) then FOnClientDisconnected(self, server, connection_id); +end; + +procedure TCEFServerComponent.doOnHttpRequest(const server : ICefServer; + connection_id : Integer; + const client_address : ustring; + const request : ICefRequest); +begin + if assigned(FOnHttpRequest) then FOnHttpRequest(self, server, connection_id, client_address, request); +end; + +procedure TCEFServerComponent.doOnWebSocketRequest(const server : ICefServer; + connection_id : Integer; + const client_address : ustring; + const request : ICefRequest; + const callback : ICefCallback); +begin + if assigned(FOnWebSocketRequest) then FOnWebSocketRequest(self, server, connection_id, client_address, request, callback); +end; + +procedure TCEFServerComponent.doOnWebSocketConnected(const server: ICefServer; connection_id: Integer); +begin + if assigned(FOnWebSocketConnected) then FOnWebSocketConnected(self, server, connection_id); +end; + +procedure TCEFServerComponent.doOnWebSocketMessage(const server : ICefServer; + connection_id : Integer; + const data : Pointer; + data_size : NativeUInt); +begin + if assigned(FOnWebSocketMessage) then FOnWebSocketMessage(self, server, connection_id, data, data_size); +end; + +procedure TCEFServerComponent.CreateServer(const address : ustring; port : uint16; backlog : Integer); +const + CEFSERVER_MIN_PORT = 1025; + CEFSERVER_MAX_PORT = 65535; +var + TempAddress : TCefString; + TempPort : integer; +begin + if (GlobalCEFApp <> nil) and + (GlobalCEFApp.Status = asInitialized) and + not(Initialized) and + (length(address) > 0) then + begin + if (FHandler = nil) then FHandler := TCustomServerHandler.Create(self); + + TempPort := max(CEFSERVER_MIN_PORT, min(CEFSERVER_MAX_PORT, port)); + TempAddress := CefString(address); + + cef_server_create(@TempAddress, TempPort, backlog, FHandler.Wrap); + end; +end; + +procedure TCEFServerComponent.Shutdown; +begin + if Initialized then FServer.shutdown; +end; + +function TCEFServerComponent.IsValidConnection(connection_id: Integer) : boolean; +begin + Result := Initialized and FServer.IsValidConnection(connection_id); +end; + +procedure TCEFServerComponent.SendHttp200response(connection_id : Integer; + const content_type : ustring; + const data : Pointer; + data_size : NativeUInt); +begin + if Initialized then FServer.SendHttp200response(connection_id, content_type, data, data_size); +end; + +procedure TCEFServerComponent.SendHttp404response(connection_id: Integer); +begin + if Initialized then FServer.SendHttp404response(connection_id); +end; + +procedure TCEFServerComponent.SendHttp500response(connection_id: Integer; const error_message: ustring); +begin + if Initialized then FServer.SendHttp500response(connection_id, error_message); +end; + +procedure TCEFServerComponent.SendHttpResponse(connection_id : Integer; + response_code : Integer; + const content_type : ustring; + content_length : int64; + const headerMap : ICefStringMultimap); +begin + if Initialized then FServer.SendHttpResponse(connection_id, response_code, content_type, content_length, headerMap); +end; + +procedure TCEFServerComponent.SendRawData(connection_id: Integer; const data: Pointer; data_size: NativeUInt); +begin + if Initialized then FServer.SendRawData(connection_id, data, data_size); +end; + +procedure TCEFServerComponent.CloseConnection(connection_id: Integer); +begin + if Initialized then FServer.CloseConnection(connection_id); +end; + +procedure TCEFServerComponent.SendWebSocketMessage(connection_id: Integer; const data: Pointer; data_size: NativeUInt); +begin + if Initialized then FServer.SendWebSocketMessage(connection_id, data, data_size); +end; + +end. diff --git a/source/uCEFServerEvents.pas b/source/uCEFServerEvents.pas new file mode 100644 index 00000000..3dc592d7 --- /dev/null +++ b/source/uCEFServerEvents.pas @@ -0,0 +1,69 @@ +// ************************************************************************ +// ***************************** 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 uCEFServerEvents; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, + {$ELSE} + Classes, + {$ENDIF} + uCEFTypes, uCEFInterfaces; + +type + TOnServerCreated = procedure(Sender: TObject; const server: ICefServer) of object; + TOnServerDestroyed = procedure(Sender: TObject; const server: ICefServer) of object; + TOnClientConnected = procedure(Sender: TObject; const server: ICefServer; connection_id: Integer) of object; + TOnClientDisconnected = procedure(Sender: TObject; const server: ICefServer; connection_id: Integer) of object; + TOnHttpRequest = procedure(Sender: TObject; const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest) of object; + TOnWebSocketRequest = procedure(Sender: TObject; const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback) of object; + TOnWebSocketConnected = procedure(Sender: TObject; const server: ICefServer; connection_id: Integer) of object; + TOnWebSocketMessage = procedure(Sender: TObject; const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt) of object; + +implementation + +end. diff --git a/source/uCEFServerHandler.pas b/source/uCEFServerHandler.pas new file mode 100644 index 00000000..7e6f9f86 --- /dev/null +++ b/source/uCEFServerHandler.pas @@ -0,0 +1,289 @@ +// ************************************************************************ +// ***************************** 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 uCEFServerHandler; + +{$IFNDEF CPUX64} + {$ALIGN ON} + {$MINENUMSIZE 4} +{$ENDIF} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCEFServerHandlerOwn = class(TCefBaseRefCountedOwn, ICefServerHandler) + protected + procedure OnServerCreated(const server: ICefServer); virtual; + procedure OnServerDestroyed(const server: ICefServer); virtual; + procedure OnClientConnected(const server: ICefServer; connection_id: Integer); virtual; + procedure OnClientDisconnected(const server: ICefServer; connection_id: Integer); virtual; + procedure OnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); virtual; + procedure OnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); virtual; + procedure OnWebSocketConnected(const server: ICefServer; connection_id: Integer); virtual; + procedure OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); virtual; + + public + constructor Create; virtual; + end; + + TCustomServerHandler = class(TCEFServerHandlerOwn) + protected + FEvents : IServerEvents; + + procedure OnServerCreated(const server: ICefServer); override; + procedure OnServerDestroyed(const server: ICefServer); override; + procedure OnClientConnected(const server: ICefServer; connection_id: Integer); override; + procedure OnClientDisconnected(const server: ICefServer; connection_id: Integer); override; + procedure OnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); override; + procedure OnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); override; + procedure OnWebSocketConnected(const server: ICefServer; connection_id: Integer); override; + procedure OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); override; + + public + constructor Create(const events: IServerEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFServer, uCEFRequest, uCEFCallback; + +// ************************************************************** +// ******************** TCEFServerHandlerOwn ******************** +// ************************************************************** + +procedure cef_load_handler_on_server_created(self : PCefServerHandler; + server : PCefServer); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnServerCreated(TCEFServerRef.UnWrap(server)); +end; + +procedure cef_load_handler_on_server_destroyed(self : PCefServerHandler; + server : PCefServer); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnServerDestroyed(TCEFServerRef.UnWrap(server)); +end; + +procedure cef_load_handler_on_client_connected(self : PCefServerHandler; + server : PCefServer; + connection_id : Integer); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnClientConnected(TCEFServerRef.UnWrap(server), connection_id); +end; + +procedure cef_load_handler_on_client_disconnected(self : PCefServerHandler; + server : PCefServer; + connection_id : Integer); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnClientDisconnected(TCEFServerRef.UnWrap(server), connection_id); +end; + +procedure cef_load_handler_on_http_request(self : PCefServerHandler; + server : PCefServer; + connection_id : Integer; + const client_address : PCefString; + request : PCefRequest); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnHttpRequest(TCEFServerRef.UnWrap(server), + connection_id, + CefString(client_address), + TCefRequestRef.UnWrap(request)); +end; + +procedure cef_load_handler_on_web_socket_request(self : PCefServerHandler; + server : PCefServer; + connection_id : Integer; + const client_address : PCefString; + request : PCefRequest; + callback : PCefCallback); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnWebSocketRequest(TCEFServerRef.UnWrap(server), + connection_id, + CefString(client_address), + TCefRequestRef.UnWrap(request), + TCefCallbackRef.UnWrap(callback)); +end; + +procedure cef_load_handler_on_web_socket_connected(self : PCefServerHandler; + server : PCefServer; + connection_id : Integer); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnWebSocketConnected(TCEFServerRef.UnWrap(server), connection_id); +end; + +procedure cef_load_handler_on_web_socket_message(self : PCefServerHandler; + server : PCefServer; + connection_id : Integer; + const data : Pointer; + data_size : NativeUInt); stdcall; +begin + with TCEFServerHandlerOwn(CefGetObject(self)) do + OnWebSocketMessage(TCEFServerRef.UnWrap(server), + connection_id, + data, + data_size); +end; + +constructor TCEFServerHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCEFServerHandler)); + + with PCEFServerHandler(FData)^ do + begin + on_server_created := cef_load_handler_on_server_created; + on_server_destroyed := cef_load_handler_on_server_destroyed; + on_client_connected := cef_load_handler_on_client_connected; + on_client_disconnected := cef_load_handler_on_client_disconnected; + on_http_request := cef_load_handler_on_http_request; + on_web_socket_request := cef_load_handler_on_web_socket_request; + on_web_socket_connected := cef_load_handler_on_web_socket_connected; + on_web_socket_message := cef_load_handler_on_web_socket_message; + end; +end; + +procedure TCEFServerHandlerOwn.OnServerCreated(const server: ICefServer); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnServerDestroyed(const server: ICefServer); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnClientConnected(const server: ICefServer; connection_id: Integer); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnClientDisconnected(const server: ICefServer; connection_id: Integer); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnWebSocketConnected(const server: ICefServer; connection_id: Integer); +begin + // +end; + +procedure TCEFServerHandlerOwn.OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); +begin + // +end; + +// ************************************************************************ +// ************************* TCustomServerHandler ************************* +// ************************************************************************ + +constructor TCustomServerHandler.Create(const events: IServerEvents); +begin + inherited Create; + + FEvents := events; +end; + +destructor TCustomServerHandler.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCustomServerHandler.OnServerCreated(const server: ICefServer); +begin + if (FEvents <> nil) then FEvents.doOnServerCreated(server); +end; + +procedure TCustomServerHandler.OnServerDestroyed(const server: ICefServer); +begin + if (FEvents <> nil) then FEvents.doOnServerDestroyed(server); +end; + +procedure TCustomServerHandler.OnClientConnected(const server: ICefServer; connection_id: Integer); +begin + if (FEvents <> nil) then FEvents.doOnClientConnected(server, connection_id); +end; + +procedure TCustomServerHandler.OnClientDisconnected(const server: ICefServer; connection_id: Integer); +begin + if (FEvents <> nil) then FEvents.doOnClientDisconnected(server, connection_id); +end; + +procedure TCustomServerHandler.OnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); +begin + if (FEvents <> nil) then FEvents.doOnHttpRequest(server, connection_id, client_address, request); +end; + +procedure TCustomServerHandler.OnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); +begin + if (FEvents <> nil) then FEvents.doOnWebSocketRequest(server, connection_id, client_address, request, callback); +end; + +procedure TCustomServerHandler.OnWebSocketConnected(const server: ICefServer; connection_id: Integer); +begin + if (FEvents <> nil) then FEvents.doOnWebSocketConnected(server, connection_id); +end; + +procedure TCustomServerHandler.OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); +begin + if (FEvents <> nil) then FEvents.doOnWebSocketMessage(server, connection_id, data, data_size); +end; + +end. diff --git a/source/uCEFTypes.pas b/source/uCEFTypes.pas index 82e58836..b6dae3fb 100644 --- a/source/uCEFTypes.pas +++ b/source/uCEFTypes.pas @@ -289,6 +289,16 @@ type TCefProcessType = (ptBrowser, ptRenderer, ptZygote, ptOther); + TCefAplicationStatus = (asLoading, + asLoaded, + asInitialized, + asUnloaded, + asErrorMissingFiles, + asErrorDLLVersion, + asErrorLoadingLibrary, + asErrorInitializingLibrary, + asErrorExecutingProcess); + TCefWebRTCHandlingPolicy = ( hpDefault, hpDefaultPublicAndPrivateInterfaces, diff --git a/source/uCEFWindowParent.pas b/source/uCEFWindowParent.pas index d5cfcc0b..47f64bc8 100644 --- a/source/uCEFWindowParent.pas +++ b/source/uCEFWindowParent.pas @@ -160,7 +160,7 @@ begin if (TempHWND <> 0) then begin - Winapi.Windows.GetClientRect(TempHWND, TempRect); + {$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect); TempDC := GetDC(TempHWND); TempWidth := TempRect.Right - TempRect.Left; TempHeight := TempRect.Bottom - TempRect.Top;