You've already forked CEF4Delphi
							
							
				mirror of
				https://github.com/salvadordf/CEF4Delphi.git
				synced 2025-10-30 23:07:52 +02:00 
			
		
		
		
	Added TCEFSentinel component
- Added TCEFSentinel to MiniBrowser, TabbedBrowser, ToolBoxBrowser and SimpleBrowser2.
This commit is contained in:
		| @@ -395,4 +395,9 @@ object MiniBrowserFrm: TMiniBrowserFrm | ||||
|     Left = 32 | ||||
|     Top = 344 | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     Left = 32 | ||||
|     Top = 408 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -51,7 +51,7 @@ uses | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, AppEvnts, ActiveX, ShlObj, | ||||
|   {$ENDIF} | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants, | ||||
|   uCEFWinControl; | ||||
|   uCEFWinControl, uCEFSentinel; | ||||
|  | ||||
| const | ||||
|   MINIBROWSER_SHOWDEVTOOLS    = WM_APP + $101; | ||||
| @@ -126,6 +126,7 @@ type | ||||
|     Downloadimage1: TMenuItem; | ||||
|     Simulatekeyboardpresses1: TMenuItem; | ||||
|     Flushcookies1: TMenuItem; | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     procedure FormShow(Sender: TObject); | ||||
|     procedure BackBtnClick(Sender: TObject); | ||||
|     procedure ForwardBtnClick(Sender: TObject); | ||||
| @@ -226,6 +227,7 @@ type | ||||
|     procedure Simulatekeyboardpresses1Click(Sender: TObject); | ||||
|     procedure Flushcookies1Click(Sender: TObject); | ||||
|     procedure Chromium1CookiesFlushed(Sender: TObject); | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|  | ||||
|   protected | ||||
|     FResponse   : TStringList; | ||||
| @@ -331,6 +333,12 @@ begin | ||||
|   if (length(TempURL) > 0) then Chromium1.ResolveHost(TempURL); | ||||
| end; | ||||
|  | ||||
| procedure TMiniBrowserFrm.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TMiniBrowserFrm.Chromium1AddressChange(Sender: TObject; | ||||
|   const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); | ||||
| begin | ||||
| @@ -348,11 +356,7 @@ end; | ||||
| procedure TMiniBrowserFrm.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); | ||||
| begin | ||||
|   // The main browser is being destroyed | ||||
|   if (Chromium1.BrowserId = 0) then | ||||
|     begin | ||||
|       FCanClose := True; | ||||
|       PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|     end; | ||||
|   if (Chromium1.BrowserId = 0) then CEFSentinel1.Start; | ||||
| end; | ||||
|  | ||||
| procedure TMiniBrowserFrm.Chromium1BeforeContextMenu(Sender: TObject; | ||||
|   | ||||
| @@ -77,4 +77,9 @@ object Form1: TForm1 | ||||
|     Left = 56 | ||||
|     Top = 152 | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     Left = 56 | ||||
|     Top = 224 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -50,7 +50,7 @@ uses | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls, | ||||
|   {$ENDIF} | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes, | ||||
|   uCEFWinControl; | ||||
|   uCEFWinControl, uCEFSentinel; | ||||
|  | ||||
| type | ||||
|   TForm1 = class(TForm) | ||||
| @@ -60,6 +60,7 @@ type | ||||
|     Timer1: TTimer; | ||||
|     Chromium1: TChromium; | ||||
|     CEFWindowParent1: TCEFWindowParent; | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     procedure GoBtnClick(Sender: TObject); | ||||
|     procedure FormShow(Sender: TObject); | ||||
|     procedure Timer1Timer(Sender: TObject); | ||||
| @@ -84,6 +85,7 @@ type | ||||
|       const targetUrl: ustring; | ||||
|       targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; | ||||
|       out Result: Boolean); | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|   protected | ||||
|     // Variables to control when can we destroy the form safely | ||||
|     FCanClose : boolean;  // Set to True in TChromium.OnBeforeClose | ||||
| @@ -162,6 +164,12 @@ begin | ||||
|   if not(Chromium1.CreateBrowser(CEFWindowParent1)) then Timer1.Enabled := True; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); | ||||
| begin | ||||
|   // Now the browser is fully initialized we can send a message to the main form to load the initial web page. | ||||
| @@ -171,8 +179,7 @@ end; | ||||
| procedure TForm1.Chromium1BeforeClose(Sender: TObject; | ||||
|   const browser: ICefBrowser); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|   CEFSentinel1.Start; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Chromium1BeforePopup(Sender: TObject; | ||||
|   | ||||
| @@ -39,7 +39,7 @@ program TabBrowser; | ||||
|  | ||||
| {$I cef.inc} | ||||
|  | ||||
| uses | ||||
| uses           | ||||
|   {$IFDEF DELPHI16_UP} | ||||
|   Vcl.Forms, | ||||
|   WinApi.Windows, | ||||
|   | ||||
| @@ -202,4 +202,9 @@ object MainForm: TMainForm | ||||
|     TabOrder = 1 | ||||
|     OnChange = PageControl1Change | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     Left = 344 | ||||
|     Top = 104 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -49,7 +49,8 @@ uses | ||||
|   Windows, Messages, SysUtils, Variants, Classes, Graphics, | ||||
|   Controls, Forms, Dialogs, ComCtrls, Buttons, ExtCtrls, StdCtrls, | ||||
|   {$ENDIF} | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants; | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants, | ||||
|   uCEFSentinel; | ||||
|  | ||||
| const | ||||
|   CEFBROWSER_DESTROYWNDPARENT = WM_APP + $100; | ||||
| @@ -72,6 +73,7 @@ type | ||||
|     URLCbx: TComboBox; | ||||
|     AddTabBtn: TButton; | ||||
|     RemoveTabBtn: TButton; | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     procedure AddTabBtnClick(Sender: TObject); | ||||
|     procedure RemoveTabBtnClick(Sender: TObject); | ||||
|     procedure FormShow(Sender: TObject); | ||||
| @@ -83,6 +85,7 @@ type | ||||
|     procedure StopBtnClick(Sender: TObject); | ||||
|     procedure GoBtnClick(Sender: TObject); | ||||
|     procedure FormCreate(Sender: TObject); | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|  | ||||
|   protected | ||||
|     FClosingTab : boolean; | ||||
| @@ -349,11 +352,7 @@ begin | ||||
|     begin | ||||
|       PageControl1.Pages[aMessage.lParam].Tag := 1; | ||||
|  | ||||
|       if AllTabSheetsAreTagged then | ||||
|         begin | ||||
|           FCanClose := True; | ||||
|           PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|         end; | ||||
|       if AllTabSheetsAreTagged then CEFSentinel1.Start; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| @@ -575,4 +574,10 @@ begin | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| end. | ||||
|   | ||||
| @@ -45,4 +45,8 @@ object MainForm: TMainForm | ||||
|       OnClick = Button1Click | ||||
|     end | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     Left = 224 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -44,11 +44,12 @@ 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; | ||||
|   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, | ||||
|   {$ELSE} | ||||
|   Windows, Messages, SysUtils, Variants, Classes, Graphics, | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls; | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls, | ||||
|   {$ENDIF} | ||||
|   uCEFSentinel; | ||||
|  | ||||
| const | ||||
|   CEFBROWSER_CREATED          = WM_APP + $100; | ||||
| @@ -61,9 +62,11 @@ type | ||||
|     ButtonPnl: TPanel; | ||||
|     Edit1: TEdit; | ||||
|     Button1: TButton; | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     procedure FormCreate(Sender: TObject); | ||||
|     procedure Button1Click(Sender: TObject); | ||||
|     procedure FormShow(Sender: TObject); | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|   private | ||||
|     // Variables to control when can we destroy the form safely | ||||
|     FCanClose : boolean;  // Set to True when all the child forms are closed | ||||
| @@ -206,11 +209,7 @@ end; | ||||
| procedure TMainForm.ChildDestroyedMsg(var aMessage : TMessage); | ||||
| begin | ||||
|   // If there are no more child forms we can destroy the main form | ||||
|   if FClosing and (ChildFormCount = 0) then | ||||
|     begin | ||||
|       FCanClose := True; | ||||
|       PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|     end; | ||||
|   if FClosing and (ChildFormCount = 0) then CEFSentinel1.Start; | ||||
| end; | ||||
|  | ||||
| function TMainForm.CloseQuery: Boolean; | ||||
| @@ -241,6 +240,12 @@ begin | ||||
|   cursor            := crDefault; | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.FormShow(Sender: TObject); | ||||
| begin | ||||
|   if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then | ||||
|   | ||||
| @@ -22,12 +22,12 @@ | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <TopLine Value="1205"/> | ||||
|         <CursorPos X="36" Y="1231"/> | ||||
|         <TopLine Value="383"/> | ||||
|         <CursorPos Y="400"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <Bookmarks Count="2"> | ||||
|           <Item0 X="3" Y="985" ID="1"/> | ||||
|           <Item1 X="66" Y="989" ID="2"/> | ||||
|           <Item0 X="41" Y="989" ID="1"/> | ||||
|           <Item1 Y="400" ID="2"/> | ||||
|         </Bookmarks> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
| @@ -83,123 +83,123 @@ | ||||
|     <JumpHistory Count="30" HistoryIndex="29"> | ||||
|       <Position1> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="310" Column="64" TopLine="305"/> | ||||
|         <Caret Line="769" Column="69" TopLine="750"/> | ||||
|       </Position1> | ||||
|       <Position2> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="310" Column="64" TopLine="305"/> | ||||
|         <Caret Line="768" Column="69" TopLine="749"/> | ||||
|       </Position2> | ||||
|       <Position3> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="182" Column="15" TopLine="160"/> | ||||
|         <Caret Line="162" Column="61" TopLine="143"/> | ||||
|       </Position3> | ||||
|       <Position4> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="763" Column="26" TopLine="756"/> | ||||
|         <Caret Line="601" Column="52" TopLine="573"/> | ||||
|       </Position4> | ||||
|       <Position5> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="768" Column="69" TopLine="749"/> | ||||
|         <Caret Line="590" Column="20" TopLine="573"/> | ||||
|       </Position5> | ||||
|       <Position6> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="769" Column="69" TopLine="750"/> | ||||
|         <Filename Value="MiniBrowser.lpr"/> | ||||
|         <Caret Line="54" TopLine="46"/> | ||||
|       </Position6> | ||||
|       <Position7> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="768" Column="69" TopLine="749"/> | ||||
|         <Caret Line="261" Column="11" TopLine="245"/> | ||||
|       </Position7> | ||||
|       <Position8> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="162" Column="61" TopLine="143"/> | ||||
|         <Caret Line="290" Column="76" TopLine="277"/> | ||||
|       </Position8> | ||||
|       <Position9> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="601" Column="52" TopLine="573"/> | ||||
|         <Caret Line="1032" Column="50" TopLine="1015"/> | ||||
|       </Position9> | ||||
|       <Position10> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="590" Column="20" TopLine="573"/> | ||||
|         <Caret Line="1044" Column="93" TopLine="1031"/> | ||||
|       </Position10> | ||||
|       <Position11> | ||||
|         <Filename Value="MiniBrowser.lpr"/> | ||||
|         <Caret Line="54" TopLine="46"/> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1045" Column="93" TopLine="1032"/> | ||||
|       </Position11> | ||||
|       <Position12> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="261" Column="11" TopLine="245"/> | ||||
|         <Caret Line="1046" Column="93" TopLine="1033"/> | ||||
|       </Position12> | ||||
|       <Position13> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="290" Column="76" TopLine="277"/> | ||||
|         <Caret Line="1053" Column="93" TopLine="1040"/> | ||||
|       </Position13> | ||||
|       <Position14> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1032" Column="50" TopLine="1015"/> | ||||
|         <Caret Line="307" Column="55" TopLine="299"/> | ||||
|       </Position14> | ||||
|       <Position15> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1044" Column="93" TopLine="1031"/> | ||||
|         <Caret Line="342" Column="9" TopLine="314"/> | ||||
|       </Position15> | ||||
|       <Position16> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1045" Column="93" TopLine="1032"/> | ||||
|         <Caret Line="350" TopLine="345"/> | ||||
|       </Position16> | ||||
|       <Position17> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1046" Column="93" TopLine="1033"/> | ||||
|         <Caret Line="982" Column="56" TopLine="980"/> | ||||
|       </Position17> | ||||
|       <Position18> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1053" Column="93" TopLine="1040"/> | ||||
|         <Caret Line="1015" Column="66" TopLine="994"/> | ||||
|       </Position18> | ||||
|       <Position19> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="307" Column="55" TopLine="299"/> | ||||
|         <Caret Line="258" Column="5" TopLine="251"/> | ||||
|       </Position19> | ||||
|       <Position20> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="342" Column="9" TopLine="314"/> | ||||
|         <Caret Line="988" Column="62" TopLine="980"/> | ||||
|       </Position20> | ||||
|       <Position21> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="350" TopLine="345"/> | ||||
|         <Caret Line="246" Column="77" TopLine="245"/> | ||||
|       </Position21> | ||||
|       <Position22> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="982" Column="56" TopLine="980"/> | ||||
|         <Caret Line="388" Column="5" TopLine="364"/> | ||||
|       </Position22> | ||||
|       <Position23> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="1015" Column="66" TopLine="994"/> | ||||
|         <Caret Line="988" Column="26" TopLine="969"/> | ||||
|       </Position23> | ||||
|       <Position24> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="258" Column="5" TopLine="251"/> | ||||
|         <Caret Line="258" Column="93" TopLine="245"/> | ||||
|       </Position24> | ||||
|       <Position25> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="988" Column="62" TopLine="980"/> | ||||
|         <Caret Line="288" Column="76" TopLine="276"/> | ||||
|       </Position25> | ||||
|       <Position26> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="246" Column="77" TopLine="245"/> | ||||
|         <Caret Line="1221" Column="70" TopLine="1205"/> | ||||
|       </Position26> | ||||
|       <Position27> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="388" Column="5" TopLine="364"/> | ||||
|         <Caret Line="1228" Column="70" TopLine="1212"/> | ||||
|       </Position27> | ||||
|       <Position28> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="988" Column="26" TopLine="969"/> | ||||
|         <Caret Line="992" Column="5" TopLine="1038"/> | ||||
|       </Position28> | ||||
|       <Position29> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="258" Column="93" TopLine="245"/> | ||||
|         <Caret Line="401" TopLine="396"/> | ||||
|       </Position29> | ||||
|       <Position30> | ||||
|         <Filename Value="uMiniBrowser.pas"/> | ||||
|         <Caret Line="288" Column="76" TopLine="276"/> | ||||
|         <Caret Line="989" Column="44" TopLine="989"/> | ||||
|       </Position30> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|   | ||||
| @@ -365,4 +365,9 @@ object MiniBrowserFrm: TMiniBrowserFrm | ||||
|     left = 32 | ||||
|     top = 344 | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     left = 32 | ||||
|     top = 404 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -45,7 +45,7 @@ uses | ||||
|   Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus, | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, ActiveX, ShlObj, | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants, | ||||
|   uCEFWinControl, uCEFChromiumEvents; | ||||
|   uCEFWinControl, uCEFChromiumEvents, uCEFSentinel; | ||||
|  | ||||
| const | ||||
|   MINIBROWSER_SHOWDEVTOOLS    = WM_APP + $101; | ||||
| @@ -82,6 +82,7 @@ type | ||||
|   { TMiniBrowserFrm } | ||||
|  | ||||
|   TMiniBrowserFrm = class(TForm) | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     MenuItem1: TMenuItem; | ||||
|     MenuItem2: TMenuItem; | ||||
|     MenuItem3: TMenuItem; | ||||
| @@ -123,6 +124,7 @@ type | ||||
|     OpenfilewithaDAT1: TMenuItem; | ||||
|     N5: TMenuItem; | ||||
|     Memoryinfo1: TMenuItem; | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|     procedure Chromium1CookiesFlushed(Sender: TObject); | ||||
|     procedure Chromium1DownloadImageFinished(Sender: TObject; | ||||
|       const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); | ||||
| @@ -394,11 +396,7 @@ end; | ||||
| procedure TMiniBrowserFrm.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); | ||||
| begin | ||||
|   // The main browser is being destroyed | ||||
|   if (Chromium1.BrowserId = 0) then | ||||
|     begin | ||||
|       FCanClose := True; | ||||
|       PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|     end; | ||||
|   if (Chromium1.BrowserId = 0) then CEFSentinel1.Start; | ||||
| end; | ||||
|  | ||||
| procedure TMiniBrowserFrm.Chromium1BeforeContextMenu(Sender: TObject; | ||||
| @@ -985,6 +983,12 @@ begin | ||||
|   PostMessage(Handle, MINIBROWSER_COOKIESFLUSHED, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TMiniBrowserFrm.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TMiniBrowserFrm.CookiesFlushedMsg(var aMessage : TMessage);   | ||||
| begin | ||||
|   showmessage('The cookies were flushed successfully'); | ||||
|   | ||||
| @@ -22,8 +22,8 @@ | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <TopLine Value="141"/> | ||||
|         <CursorPos Y="149"/> | ||||
|         <TopLine Value="320"/> | ||||
|         <CursorPos X="17" Y="344"/> | ||||
|         <UsageCount Value="22"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
| @@ -36,8 +36,8 @@ | ||||
|         <HasResources Value="True"/> | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <EditorIndex Value="2"/> | ||||
|         <TopLine Value="150"/> | ||||
|         <CursorPos X="72" Y="165"/> | ||||
|         <TopLine Value="82"/> | ||||
|         <CursorPos Y="184"/> | ||||
|         <UsageCount Value="22"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
| @@ -80,119 +80,127 @@ | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit7> | ||||
|     </Units> | ||||
|     <JumpHistory Count="28" HistoryIndex="27"> | ||||
|     <JumpHistory Count="30" HistoryIndex="29"> | ||||
|       <Position1> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="292" TopLine="280"/> | ||||
|         <Caret Line="295" Column="27" TopLine="280"/> | ||||
|       </Position1> | ||||
|       <Position2> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="294" TopLine="280"/> | ||||
|         <Caret Line="298" Column="15" TopLine="280"/> | ||||
|       </Position2> | ||||
|       <Position3> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="295" Column="27" TopLine="280"/> | ||||
|         <Caret Line="86" Column="15" TopLine="75"/> | ||||
|       </Position3> | ||||
|       <Position4> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="298" Column="15" TopLine="280"/> | ||||
|         <Caret Line="223" Column="26" TopLine="203"/> | ||||
|       </Position4> | ||||
|       <Position5> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="86" Column="15" TopLine="75"/> | ||||
|         <Caret Line="224" Column="25" TopLine="204"/> | ||||
|       </Position5> | ||||
|       <Position6> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="223" Column="26" TopLine="203"/> | ||||
|         <Caret Line="277" Column="13" TopLine="257"/> | ||||
|       </Position6> | ||||
|       <Position7> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="224" Column="25" TopLine="204"/> | ||||
|         <Caret Line="292" Column="19" TopLine="272"/> | ||||
|       </Position7> | ||||
|       <Position8> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="277" Column="13" TopLine="257"/> | ||||
|         <Caret Line="294" Column="19" TopLine="274"/> | ||||
|       </Position8> | ||||
|       <Position9> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="292" Column="19" TopLine="272"/> | ||||
|         <Caret Line="295" Column="19" TopLine="275"/> | ||||
|       </Position9> | ||||
|       <Position10> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="294" Column="19" TopLine="274"/> | ||||
|         <Caret Line="298" Column="15" TopLine="278"/> | ||||
|       </Position10> | ||||
|       <Position11> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="295" Column="19" TopLine="275"/> | ||||
|         <Caret Line="86" Column="15" TopLine="75"/> | ||||
|       </Position11> | ||||
|       <Position12> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="298" Column="15" TopLine="278"/> | ||||
|         <Caret Line="223" Column="26" TopLine="203"/> | ||||
|       </Position12> | ||||
|       <Position13> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="86" Column="15" TopLine="75"/> | ||||
|         <Caret Line="224" Column="25" TopLine="204"/> | ||||
|       </Position13> | ||||
|       <Position14> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="223" Column="26" TopLine="203"/> | ||||
|         <Caret Line="277" Column="13" TopLine="257"/> | ||||
|       </Position14> | ||||
|       <Position15> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="224" Column="25" TopLine="204"/> | ||||
|         <Caret Line="292" TopLine="281"/> | ||||
|       </Position15> | ||||
|       <Position16> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="277" Column="13" TopLine="257"/> | ||||
|         <Caret Line="295" TopLine="281"/> | ||||
|       </Position16> | ||||
|       <Position17> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="292" TopLine="281"/> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="62" Column="23" TopLine="54"/> | ||||
|       </Position17> | ||||
|       <Position18> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="295" TopLine="281"/> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="222" Column="3" TopLine="220"/> | ||||
|       </Position18> | ||||
|       <Position19> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="62" Column="23" TopLine="54"/> | ||||
|         <Caret Line="77" Column="22" TopLine="48"/> | ||||
|       </Position19> | ||||
|       <Position20> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="222" Column="3" TopLine="220"/> | ||||
|       </Position20> | ||||
|       <Position21> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="77" Column="22" TopLine="48"/> | ||||
|       </Position21> | ||||
|       <Position22> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="286" Column="54" TopLine="260"/> | ||||
|       </Position22> | ||||
|       <Position23> | ||||
|       </Position20> | ||||
|       <Position21> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="98" Column="33" TopLine="77"/> | ||||
|       </Position23> | ||||
|       <Position24> | ||||
|       </Position21> | ||||
|       <Position22> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="78" Column="22" TopLine="71"/> | ||||
|       </Position22> | ||||
|       <Position23> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="253" Column="14" TopLine="231"/> | ||||
|       </Position23> | ||||
|       <Position24> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="76" Column="384" TopLine="70"/> | ||||
|       </Position24> | ||||
|       <Position25> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="253" Column="14" TopLine="231"/> | ||||
|         <Caret Line="250" Column="32" TopLine="223"/> | ||||
|       </Position25> | ||||
|       <Position26> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="76" Column="384" TopLine="70"/> | ||||
|       </Position26> | ||||
|       <Position27> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="250" Column="32" TopLine="223"/> | ||||
|       </Position27> | ||||
|       <Position28> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="62" Column="384" TopLine="51"/> | ||||
|       </Position26> | ||||
|       <Position27> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="199" Column="59" TopLine="183"/> | ||||
|       </Position27> | ||||
|       <Position28> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="344" Column="17" TopLine="320"/> | ||||
|       </Position28> | ||||
|       <Position29> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="346" Column="19" TopLine="322"/> | ||||
|       </Position29> | ||||
|       <Position30> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="197" Column="72" TopLine="182"/> | ||||
|       </Position30> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|       <FormatVersion Value="2"/> | ||||
|   | ||||
| @@ -165,7 +165,6 @@ begin | ||||
|       if not(FClosingMainForm) then | ||||
|         begin | ||||
|           FClosingMainForm := True; | ||||
|           Visible          := False; | ||||
|           Chromium1.CloseBrowser(True); | ||||
|         end; | ||||
|     end; | ||||
|   | ||||
| @@ -4,11 +4,12 @@ | ||||
|     <PathDelim Value="\"/> | ||||
|     <Version Value="11"/> | ||||
|     <BuildModes Active="Default"/> | ||||
|     <Units Count="3"> | ||||
|     <Units Count="8"> | ||||
|       <Unit0> | ||||
|         <Filename Value="PostInspectorBrowser.lpr"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <TopLine Value="41"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <TopLine Value="37"/> | ||||
|         <CursorPos Y="73"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Loaded Value="True"/> | ||||
| @@ -20,13 +21,10 @@ | ||||
|         <ComponentName Value="Form1"/> | ||||
|         <HasResources Value="True"/> | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <TopLine Value="135"/> | ||||
|         <CursorPos Y="152"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="34"/> | ||||
|         <CursorPos X="80" Y="157"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
|       </Unit1> | ||||
|       <Unit2> | ||||
| @@ -36,111 +34,48 @@ | ||||
|         <CursorPos X="15" Y="873"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit2> | ||||
|       <Unit3> | ||||
|         <Filename Value="C:\lazarus\fpc\3.0.4\source\packages\fcl-base\src\syncobjs.pp"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="24"/> | ||||
|         <CursorPos X="4" Y="42"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit3> | ||||
|       <Unit4> | ||||
|         <Filename Value="..\..\..\source\uCEFSentinel.pas"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="27"/> | ||||
|         <CursorPos X="77" Y="119"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit4> | ||||
|       <Unit5> | ||||
|         <Filename Value="C:\lazarus\lcl\lcltype.pp"/> | ||||
|         <UnitName Value="LCLType"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="50"/> | ||||
|         <CursorPos X="3" Y="68"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit5> | ||||
|       <Unit6> | ||||
|         <Filename Value="..\..\..\packages\cef4delphi_lazarus.pas"/> | ||||
|         <UnitName Value="CEF4Delphi_Lazarus"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="36"/> | ||||
|         <CursorPos X="64" Y="66"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit6> | ||||
|       <Unit7> | ||||
|         <Filename Value="..\..\..\source\uCEFUrlRequestClientComponent.pas"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="79"/> | ||||
|         <CursorPos Y="110"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit7> | ||||
|     </Units> | ||||
|     <JumpHistory Count="26" HistoryIndex="25"> | ||||
|     <JumpHistory Count="1"> | ||||
|       <Position1> | ||||
|         <Filename Value="PostInspectorBrowser.lpr"/> | ||||
|       </Position1> | ||||
|       <Position2> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="311" Column="52" TopLine="290"/> | ||||
|       </Position2> | ||||
|       <Position3> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="122" Column="8" TopLine="91"/> | ||||
|       </Position3> | ||||
|       <Position4> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="78" Column="43" TopLine="68"/> | ||||
|       </Position4> | ||||
|       <Position5> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="292" Column="59" TopLine="263"/> | ||||
|       </Position5> | ||||
|       <Position6> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="113" Column="79" TopLine="100"/> | ||||
|       </Position6> | ||||
|       <Position7> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="281" Column="40" TopLine="257"/> | ||||
|       </Position7> | ||||
|       <Position8> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="287" Column="103" TopLine="263"/> | ||||
|       </Position8> | ||||
|       <Position9> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="353" TopLine="325"/> | ||||
|       </Position9> | ||||
|       <Position10> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="331" TopLine="315"/> | ||||
|       </Position10> | ||||
|       <Position11> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="332" TopLine="315"/> | ||||
|       </Position11> | ||||
|       <Position12> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="334" TopLine="315"/> | ||||
|       </Position12> | ||||
|       <Position13> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="336" TopLine="315"/> | ||||
|       </Position13> | ||||
|       <Position14> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="337" TopLine="315"/> | ||||
|       </Position14> | ||||
|       <Position15> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="338" TopLine="315"/> | ||||
|       </Position15> | ||||
|       <Position16> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="331" TopLine="315"/> | ||||
|       </Position16> | ||||
|       <Position17> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="332" TopLine="315"/> | ||||
|       </Position17> | ||||
|       <Position18> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="330" Column="61" TopLine="322"/> | ||||
|       </Position18> | ||||
|       <Position19> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="331" TopLine="322"/> | ||||
|       </Position19> | ||||
|       <Position20> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="333" TopLine="322"/> | ||||
|       </Position20> | ||||
|       <Position21> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="331" TopLine="322"/> | ||||
|       </Position21> | ||||
|       <Position22> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="333" TopLine="322"/> | ||||
|       </Position22> | ||||
|       <Position23> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="335" TopLine="322"/> | ||||
|       </Position23> | ||||
|       <Position24> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="336" TopLine="322"/> | ||||
|       </Position24> | ||||
|       <Position25> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="331" Column="86" TopLine="322"/> | ||||
|       </Position25> | ||||
|       <Position26> | ||||
|         <Filename Value="uPostInspectorBrowser.pas"/> | ||||
|         <Caret Line="340" TopLine="322"/> | ||||
|       </Position26> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|       <FormatVersion Value="2"/> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| object Form1: TForm1 | ||||
|   Left = 71 | ||||
|   Left = 670 | ||||
|   Height = 699 | ||||
|   Top = 65 | ||||
|   Top = 69 | ||||
|   Width = 1038 | ||||
|   Caption = 'Initializing browser. Please wait...' | ||||
|   ClientHeight = 699 | ||||
|   | ||||
| @@ -35,8 +35,8 @@ | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <UnitName Value="uSimpleLazarusBrowser"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <TopLine Value="106"/> | ||||
|         <CursorPos Y="131"/> | ||||
|         <TopLine Value="147"/> | ||||
|         <CursorPos X="22" Y="167"/> | ||||
|         <UsageCount Value="43"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
| @@ -423,7 +423,7 @@ | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit54> | ||||
|     </Units> | ||||
|     <JumpHistory Count="8" HistoryIndex="7"> | ||||
|     <JumpHistory Count="10" HistoryIndex="9"> | ||||
|       <Position1> | ||||
|         <Filename Value="usimplelazarusbrowser.pas"/> | ||||
|         <Caret Line="67" Column="29" TopLine="57"/> | ||||
| @@ -456,6 +456,14 @@ | ||||
|         <Filename Value="SimpleBrowser2.lpr"/> | ||||
|         <Caret Line="26" Column="34"/> | ||||
|       </Position8> | ||||
|       <Position9> | ||||
|         <Filename Value="usimplelazarusbrowser.pas"/> | ||||
|         <Caret Line="131" TopLine="136"/> | ||||
|       </Position9> | ||||
|       <Position10> | ||||
|         <Filename Value="usimplelazarusbrowser.pas"/> | ||||
|         <Caret Line="133" TopLine="133"/> | ||||
|       </Position10> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|       <FormatVersion Value="2"/> | ||||
|   | ||||
| @@ -66,4 +66,9 @@ object Form1: TForm1 | ||||
|     left = 40 | ||||
|     top = 136 | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     left = 40 | ||||
|     top = 216 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -42,19 +42,21 @@ unit uSimpleLazarusBrowser; | ||||
| interface | ||||
|  | ||||
| uses | ||||
|   Windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, | ||||
|   StdCtrls, LMessages, | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFChromiumEvents; | ||||
|   Windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, | ||||
|   ExtCtrls, StdCtrls, LMessages, uCEFChromium, uCEFWindowParent, uCEFInterfaces, | ||||
|   uCEFConstants, uCEFTypes, uCEFChromiumEvents, uCEFSentinel; | ||||
|  | ||||
| type | ||||
|   { TForm1 } | ||||
|   TForm1 = class(TForm) | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     CEFWindowParent1: TCEFWindowParent; | ||||
|     Chromium1: TChromium; | ||||
|     GoBtn: TButton; | ||||
|     AddressEdt: TEdit; | ||||
|     AddressPnl: TPanel; | ||||
|     Timer1: TTimer; | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|     procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser | ||||
|       ); | ||||
|     procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); | ||||
| @@ -154,12 +156,17 @@ begin | ||||
|   PostMessage(Handle, CEF_AFTERCREATED, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); | ||||
| procedure TForm1.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); | ||||
| begin | ||||
|   CEFSentinel1.Start; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Chromium1BeforePopup(Sender: TObject; | ||||
|   const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, | ||||
|   targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; | ||||
|   | ||||
| @@ -22,15 +22,18 @@ | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <TopLine Value="137"/> | ||||
|         <CursorPos Y="159"/> | ||||
|         <TopLine Value="348"/> | ||||
|         <CursorPos Y="365"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <Bookmarks Count="1"> | ||||
|           <Item0 Y="365" ID="1"/> | ||||
|         </Bookmarks> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
|       </Unit1> | ||||
|     </Units> | ||||
|     <JumpHistory Count="5" HistoryIndex="4"> | ||||
|     <JumpHistory Count="10" HistoryIndex="9"> | ||||
|       <Position1> | ||||
|         <Filename Value="TabBrowser.lpr"/> | ||||
|       </Position1> | ||||
| @@ -50,6 +53,26 @@ | ||||
|         <Filename Value="TabBrowser.lpr"/> | ||||
|         <Caret Line="53" Column="3" TopLine="41"/> | ||||
|       </Position5> | ||||
|       <Position6> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="159" TopLine="137"/> | ||||
|       </Position6> | ||||
|       <Position7> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="165" TopLine="143"/> | ||||
|       </Position7> | ||||
|       <Position8> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="365" Column="16" TopLine="340"/> | ||||
|       </Position8> | ||||
|       <Position9> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="196" Column="21" TopLine="196"/> | ||||
|       </Position9> | ||||
|       <Position10> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="366" Column="16" TopLine="348"/> | ||||
|       </Position10> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|       <FormatVersion Value="2"/> | ||||
|   | ||||
| @@ -193,4 +193,9 @@ object MainForm: TMainForm | ||||
|     TabOrder = 1 | ||||
|     OnChange = PageControl1Change | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     left = 160 | ||||
|     top = 121 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -49,7 +49,8 @@ uses | ||||
|   Windows, Messages, SysUtils, Variants, Classes, Graphics, | ||||
|   Controls, Forms, Dialogs, ComCtrls, Buttons, ExtCtrls, StdCtrls, | ||||
|   {$ENDIF} | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants; | ||||
|   uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, | ||||
|   uCEFConstants, uCEFSentinel; | ||||
|  | ||||
| const | ||||
|   CEFBROWSER_DESTROYWNDPARENT = WM_APP + $100; | ||||
| @@ -58,7 +59,11 @@ const | ||||
|   CEFBROWSER_CHECKTAGGEDTABS  = WM_APP + $103; | ||||
|  | ||||
| type | ||||
|  | ||||
|   { TMainForm } | ||||
|  | ||||
|   TMainForm = class(TForm) | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     PageControl1: TPageControl; | ||||
|     ButtonPnl: TPanel; | ||||
|     NavButtonPnl: TPanel; | ||||
| @@ -73,6 +78,7 @@ type | ||||
|     AddTabBtn: TButton; | ||||
|     RemoveTabBtn: TButton; | ||||
|     procedure AddTabBtnClick(Sender: TObject); | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|     procedure RemoveTabBtnClick(Sender: TObject); | ||||
|     procedure FormShow(Sender: TObject); | ||||
|     procedure PageControl1Change(Sender: TObject); | ||||
| @@ -187,6 +193,12 @@ begin | ||||
|   TempChromium.CreateBrowser(TempWindowParent, ''); | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.RemoveTabBtnClick(Sender: TObject); | ||||
| var | ||||
|   TempChromium : TChromium; | ||||
| @@ -349,11 +361,7 @@ begin | ||||
|     begin | ||||
|       PageControl1.Pages[aMessage.lParam].Tag := 1; | ||||
|  | ||||
|       if AllTabSheetsAreTagged then | ||||
|         begin | ||||
|           FCanClose := True; | ||||
|           PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|         end; | ||||
|       if AllTabSheetsAreTagged then CEFSentinel1.Start; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
|   | ||||
| @@ -4,13 +4,13 @@ | ||||
|     <PathDelim Value="\"/> | ||||
|     <Version Value="11"/> | ||||
|     <BuildModes Active="Default"/> | ||||
|     <Units Count="3"> | ||||
|     <Units Count="5"> | ||||
|       <Unit0> | ||||
|         <Filename Value="ToolBoxBrowser.lpr"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <TopLine Value="41"/> | ||||
|         <CursorPos X="17" Y="58"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
|       </Unit0> | ||||
| @@ -22,9 +22,13 @@ | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <TopLine Value="113"/> | ||||
|         <CursorPos Y="117"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <TopLine Value="204"/> | ||||
|         <CursorPos X="68" Y="221"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Bookmarks Count="2"> | ||||
|           <Item0 X="42" Y="143" ID="1"/> | ||||
|           <Item1 X="65" Y="222" ID="2"/> | ||||
|         </Bookmarks> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
| @@ -36,15 +40,29 @@ | ||||
|         <HasResources Value="True"/> | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <EditorIndex Value="2"/> | ||||
|         <TopLine Value="134"/> | ||||
|         <TopLine Value="50"/> | ||||
|         <CursorPos X="39" Y="140"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
|       </Unit2> | ||||
|       <Unit3> | ||||
|         <Filename Value="..\..\..\source\uCEFChromium.pas"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="54"/> | ||||
|         <CursorPos X="3" Y="69"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit3> | ||||
|       <Unit4> | ||||
|         <Filename Value="..\..\..\source\uCEFApplication.pas"/> | ||||
|         <EditorIndex Value="-1"/> | ||||
|         <TopLine Value="453"/> | ||||
|         <CursorPos X="35" Y="462"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit4> | ||||
|     </Units> | ||||
|     <JumpHistory Count="3" HistoryIndex="2"> | ||||
|     <JumpHistory Count="8" HistoryIndex="7"> | ||||
|       <Position1> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|       </Position1> | ||||
| @@ -56,6 +74,26 @@ | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="93" Column="25" TopLine="66"/> | ||||
|       </Position3> | ||||
|       <Position4> | ||||
|         <Filename Value="uChildForm.pas"/> | ||||
|         <Caret Line="140" Column="39" TopLine="47"/> | ||||
|       </Position4> | ||||
|       <Position5> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="117" TopLine="113"/> | ||||
|       </Position5> | ||||
|       <Position6> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="122" TopLine="118"/> | ||||
|       </Position6> | ||||
|       <Position7> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="223" TopLine="208"/> | ||||
|       </Position7> | ||||
|       <Position8> | ||||
|         <Filename Value="uMainForm.pas"/> | ||||
|         <Caret Line="140" Column="38" TopLine="124"/> | ||||
|       </Position8> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|       <FormatVersion Value="2"/> | ||||
|   | ||||
| @@ -45,4 +45,8 @@ object MainForm: TMainForm | ||||
|       TabOrder = 1 | ||||
|     end | ||||
|   end | ||||
|   object CEFSentinel1: TCEFSentinel | ||||
|     OnClose = CEFSentinel1Close | ||||
|     left = 232 | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -49,7 +49,7 @@ uses | ||||
|   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; | ||||
|   {$ELSE} | ||||
|   LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls; | ||||
|   Controls, Forms, Dialogs, StdCtrls, ExtCtrls, uCEFSentinel; | ||||
|   {$ENDIF} | ||||
|  | ||||
| const | ||||
| @@ -59,10 +59,15 @@ const | ||||
|   CEFBROWSER_INITIALIZED      = WM_APP + $103; | ||||
|  | ||||
| type | ||||
|  | ||||
|   { TMainForm } | ||||
|  | ||||
|   TMainForm = class(TForm) | ||||
|     ButtonPnl: TPanel; | ||||
|     CEFSentinel1: TCEFSentinel; | ||||
|     Edit1: TEdit; | ||||
|     Button1: TButton; | ||||
|     procedure CEFSentinel1Close(Sender: TObject); | ||||
|     procedure FormCreate(Sender: TObject); | ||||
|     procedure Button1Click(Sender: TObject); | ||||
|     procedure FormShow(Sender: TObject); | ||||
| @@ -132,6 +137,12 @@ begin | ||||
|   FClosing  := False; | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.CEFSentinel1Close(Sender: TObject); | ||||
| begin | ||||
|   FCanClose := True; | ||||
|   PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TMainForm.CloseAllChildForms; | ||||
| var | ||||
|   i : integer; | ||||
| @@ -207,12 +218,8 @@ end; | ||||
|  | ||||
| procedure TMainForm.ChildDestroyedMsg(var aMessage : TMessage); | ||||
| begin | ||||
|   // If there are no more child forms we can destroy the main form | ||||
|   if FClosing and (ChildFormCount = 0) then | ||||
|     begin | ||||
|       FCanClose := True; | ||||
|       PostMessage(Handle, WM_CLOSE, 0, 0); | ||||
|     end; | ||||
|   // If there are no more child forms we start the sentinel | ||||
|   if FClosing and (ChildFormCount = 0) then CEFSentinel1.Start; | ||||
| end; | ||||
|  | ||||
| function TMainForm.CloseQuery: Boolean; | ||||
|   | ||||
| @@ -4,13 +4,13 @@ | ||||
|     <PathDelim Value="\"/> | ||||
|     <Version Value="11"/> | ||||
|     <BuildModes Active="Default"/> | ||||
|     <Units Count="3"> | ||||
|     <Units Count="6"> | ||||
|       <Unit0> | ||||
|         <Filename Value="URLRequest.lpr"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <TopLine Value="44"/> | ||||
|         <CursorPos X="17" Y="59"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
|       </Unit0> | ||||
| @@ -20,11 +20,10 @@ | ||||
|         <ComponentName Value="URLRequestFrm"/> | ||||
|         <HasResources Value="True"/> | ||||
|         <ResourceBaseClass Value="Form"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <TopLine Value="133"/> | ||||
|         <CursorPos X="58" Y="148"/> | ||||
|         <UsageCount Value="20"/> | ||||
|         <TopLine Value="223"/> | ||||
|         <CursorPos Y="204"/> | ||||
|         <UsageCount Value="21"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <LoadedDesigner Value="True"/> | ||||
|         <DefaultSyntaxHighlighter Value="Delphi"/> | ||||
| @@ -36,8 +35,33 @@ | ||||
|         <CursorPos X="54" Y="55"/> | ||||
|         <UsageCount Value="10"/> | ||||
|       </Unit2> | ||||
|       <Unit3> | ||||
|         <Filename Value="..\..\..\source\uCEFUrlRequestClientComponent.pas"/> | ||||
|         <EditorIndex Value="2"/> | ||||
|         <TopLine Value="187"/> | ||||
|         <CursorPos Y="208"/> | ||||
|         <UsageCount Value="10"/> | ||||
|         <Loaded Value="True"/> | ||||
|       </Unit3> | ||||
|       <Unit4> | ||||
|         <Filename Value="..\..\..\source\uCEFInterfaces.pas"/> | ||||
|         <EditorIndex Value="4"/> | ||||
|         <TopLine Value="1857"/> | ||||
|         <CursorPos X="3" Y="1872"/> | ||||
|         <UsageCount Value="10"/> | ||||
|         <Loaded Value="True"/> | ||||
|       </Unit4> | ||||
|       <Unit5> | ||||
|         <Filename Value="..\..\..\source\uCEFSentinel.pas"/> | ||||
|         <IsVisibleTab Value="True"/> | ||||
|         <EditorIndex Value="3"/> | ||||
|         <TopLine Value="266"/> | ||||
|         <CursorPos X="23" Y="292"/> | ||||
|         <UsageCount Value="10"/> | ||||
|         <Loaded Value="True"/> | ||||
|       </Unit5> | ||||
|     </Units> | ||||
|     <JumpHistory Count="2" HistoryIndex="1"> | ||||
|     <JumpHistory Count="16" HistoryIndex="15"> | ||||
|       <Position1> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|       </Position1> | ||||
| @@ -45,6 +69,62 @@ | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="147" Column="3" TopLine="133"/> | ||||
|       </Position2> | ||||
|       <Position3> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="107" Column="15" TopLine="93"/> | ||||
|       </Position3> | ||||
|       <Position4> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="228" Column="3" TopLine="226"/> | ||||
|       </Position4> | ||||
|       <Position5> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="313" Column="3" TopLine="311"/> | ||||
|       </Position5> | ||||
|       <Position6> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="330" Column="3" TopLine="311"/> | ||||
|       </Position6> | ||||
|       <Position7> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="344" Column="3" TopLine="55"/> | ||||
|       </Position7> | ||||
|       <Position8> | ||||
|         <Filename Value="..\..\..\source\uCEFUrlRequestClientComponent.pas"/> | ||||
|         <Caret Line="94" Column="30" TopLine="77"/> | ||||
|       </Position8> | ||||
|       <Position9> | ||||
|         <Filename Value="..\..\..\source\uCEFUrlRequestClientComponent.pas"/> | ||||
|         <Caret Line="149" Column="3" TopLine="134"/> | ||||
|       </Position9> | ||||
|       <Position10> | ||||
|         <Filename Value="..\..\..\source\uCEFUrlRequestClientComponent.pas"/> | ||||
|         <Caret Line="159" Column="11" TopLine="134"/> | ||||
|       </Position10> | ||||
|       <Position11> | ||||
|         <Filename Value="..\..\..\source\uCEFUrlRequestClientComponent.pas"/> | ||||
|         <Caret Line="69" Column="7" TopLine="54"/> | ||||
|       </Position11> | ||||
|       <Position12> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="69" Column="39" TopLine="55"/> | ||||
|       </Position12> | ||||
|       <Position13> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="195" Column="40" TopLine="171"/> | ||||
|       </Position13> | ||||
|       <Position14> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="251" Column="73" TopLine="227"/> | ||||
|       </Position14> | ||||
|       <Position15> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="301" Column="77" TopLine="277"/> | ||||
|       </Position15> | ||||
|       <Position16> | ||||
|         <Filename Value="uURLRequest.pas"/> | ||||
|         <Caret Line="413" Column="61" TopLine="390"/> | ||||
|       </Position16> | ||||
|     </JumpHistory> | ||||
|     <RunParams> | ||||
|       <FormatVersion Value="2"/> | ||||
|   | ||||
| @@ -144,8 +144,8 @@ uses | ||||
| procedure CreateGlobalCEFApp; | ||||
| begin | ||||
|   GlobalCEFApp                 := TCefApplication.Create; | ||||
|   //GlobalCEFApp.LogFile          := 'cef.log'; | ||||
|   //GlobalCEFApp.LogSeverity      := LOGSEVERITY_VERBOSE; | ||||
|   GlobalCEFApp.LogFile          := 'cef.log'; | ||||
|   GlobalCEFApp.LogSeverity      := LOGSEVERITY_VERBOSE; | ||||
| end; | ||||
|  | ||||
| procedure TURLRequestFrm.DownloadBtnClick(Sender: TObject); | ||||
|   | ||||
| @@ -171,7 +171,8 @@ contains | ||||
|   uCEFCookieAccessFilter in '..\source\uCEFCookieAccessFilter.pas', | ||||
|   uCEFResourceRequestHandler in '..\source\uCEFResourceRequestHandler.pas', | ||||
|   uCEFResourceSkipCallback in '..\source\uCEFResourceSkipCallback.pas', | ||||
|   uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas'; | ||||
|   uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas', | ||||
|   uCEFSentinel in '..\source\uCEFSentinel.pas'; | ||||
|  | ||||
| end. | ||||
|  | ||||
|   | ||||
| @@ -266,6 +266,7 @@ | ||||
|         <DCCReference Include="..\source\uCEFResourceRequestHandler.pas"/> | ||||
|         <DCCReference Include="..\source\uCEFResourceSkipCallback.pas"/> | ||||
|         <DCCReference Include="..\source\uCEFResourceReadCallback.pas"/> | ||||
|         <DCCReference Include="..\source\uCEFSentinel.pas"/> | ||||
|         <BuildConfiguration Include="Base"> | ||||
|             <Key>Base</Key> | ||||
|         </BuildConfiguration> | ||||
| @@ -301,13 +302,13 @@ | ||||
|                 <DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule"/> | ||||
|                 <DeployFile LocalName="..\..\..\..\..\..\..\Public\Documents\Embarcadero\Studio\17.0\Bpl\CEF4Delphi.bpl" Configuration="Debug" Class="ProjectOutput"/> | ||||
|                 <DeployFile LocalName="$(BDS)\Redist\iossimulator\libPCRE.dylib" Class="DependencyModule"/> | ||||
|                 <DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule"/> | ||||
|                 <DeployFile LocalName="..\..\..\..\..\..\..\Public\Documents\Embarcadero\Studio\20.0\Bpl\CEF4Delphi.bpl" Configuration="Debug" Class="ProjectOutput"> | ||||
|                     <Platform Name="Win32"> | ||||
|                         <RemoteName>CEF4Delphi.bpl</RemoteName> | ||||
|                         <Overwrite>true</Overwrite> | ||||
|                     </Platform> | ||||
|                 </DeployFile> | ||||
|                 <DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule"/> | ||||
|                 <DeployClass Name="AdditionalDebugSymbols"> | ||||
|                     <Platform Name="OSX32"> | ||||
|                         <Operation>1</Operation> | ||||
|   | ||||
| @@ -168,6 +168,7 @@ contains | ||||
|   uCEFCookieAccessFilter in '..\source\uCEFCookieAccessFilter.pas', | ||||
|   uCEFResourceRequestHandler in '..\source\uCEFResourceRequestHandler.pas', | ||||
|   uCEFResourceSkipCallback in '..\source\uCEFResourceSkipCallback.pas', | ||||
|   uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas'; | ||||
|   uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas', | ||||
|   uCEFSentinel in '..\source\uCEFSentinel.pas'; | ||||
|  | ||||
| end. | ||||
|   | ||||
| @@ -50,13 +50,13 @@ implementation | ||||
| uses | ||||
|   Classes, | ||||
|   uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, uCEFWorkScheduler, | ||||
|   uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent; | ||||
|   uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, uCEFSentinel; | ||||
|  | ||||
| procedure Register; | ||||
| begin | ||||
|   RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, | ||||
|                                   TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent, | ||||
| 				  TCEFUrlRequestClientComponent]); | ||||
| 				  TCEFUrlRequestClientComponent, TCEFSentinel]); | ||||
| end; | ||||
|  | ||||
| end. | ||||
|   | ||||
| @@ -176,7 +176,8 @@ contains | ||||
|   uCEFCookieAccessFilter in '..\source\uCEFCookieAccessFilter.pas', | ||||
|   uCEFResourceRequestHandler in '..\source\uCEFResourceRequestHandler.pas', | ||||
|   uCEFResourceSkipCallback in '..\source\uCEFResourceSkipCallback.pas', | ||||
|   uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas'; | ||||
|   uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas', | ||||
|   uCEFSentinel in '..\source\uCEFSentinel.pas'; | ||||
|  | ||||
| end. | ||||
|  | ||||
|   | ||||
| @@ -292,6 +292,7 @@ | ||||
|         <DCCReference Include="..\source\uCEFResourceRequestHandler.pas"/> | ||||
|         <DCCReference Include="..\source\uCEFResourceSkipCallback.pas"/> | ||||
|         <DCCReference Include="..\source\uCEFResourceReadCallback.pas"/> | ||||
|         <DCCReference Include="..\source\uCEFSentinel.pas"/> | ||||
|         <BuildConfiguration Include="Base"> | ||||
|             <Key>Base</Key> | ||||
|         </BuildConfiguration> | ||||
|   | ||||
| @@ -51,7 +51,8 @@ uses | ||||
|   System.Classes, | ||||
|   uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, | ||||
|   uCEFWorkScheduler, uCEFFMXBufferPanel, uCEFFMXChromium, uCEFFMXWorkScheduler, | ||||
|   uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent; | ||||
|   uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, | ||||
|   uCEFSentinel; | ||||
|  | ||||
| procedure Register; | ||||
| begin | ||||
| @@ -59,7 +60,8 @@ begin | ||||
|                                   TBufferPanel, TFMXBufferPanel, TFMXChromium, | ||||
|                                   TFMXWorkScheduler, TCEFWorkScheduler, | ||||
|                                   TCEFServerComponent, TCEFLinkedWindowParent, | ||||
|                                   TCEFUrlRequestClientComponent]); | ||||
|                                   TCEFUrlRequestClientComponent, | ||||
|                                   TCEFSentinel]); | ||||
| end; | ||||
|  | ||||
| end. | ||||
|   | ||||
| @@ -54,13 +54,13 @@ uses | ||||
|   Classes, | ||||
|   {$ENDIF} | ||||
|   uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, uCEFWorkScheduler, | ||||
|   uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent; | ||||
|   uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, uCEFSentinel; | ||||
|  | ||||
| procedure Register; | ||||
| begin | ||||
|   RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, | ||||
|                                   TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent, | ||||
| 				  TCEFUrlRequestClientComponent]); | ||||
|                         				  TCEFUrlRequestClientComponent, TCEFSentinel]); | ||||
| end; | ||||
|  | ||||
| end. | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
|     <Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/> | ||||
|     <License Value="MPL 1.1"/> | ||||
|     <Version Major="77" Minor="1" Release="12"/> | ||||
|     <Files Count="142"> | ||||
|     <Files Count="144"> | ||||
|       <Item1> | ||||
|         <Filename Value="..\source\uCEFAccessibilityHandler.pas"/> | ||||
|         <UnitName Value="uCEFAccessibilityHandler"/> | ||||
| @@ -599,6 +599,15 @@ | ||||
|         <Filename Value="..\source\uCEFResourceSkipCallback.pas"/> | ||||
|         <UnitName Value="uCEFResourceSkipCallback"/> | ||||
|       </Item142> | ||||
|       <Item143> | ||||
|         <Filename Value="..\source\res\tcefsentinel.lrs"/> | ||||
|         <Type Value="LRS"/> | ||||
|       </Item143> | ||||
|       <Item144> | ||||
|         <Filename Value="..\source\uCEFSentinel.pas"/> | ||||
|         <HasRegisterProc Value="True"/> | ||||
|         <UnitName Value="uCEFSentinel"/> | ||||
|       </Item144> | ||||
|     </Files> | ||||
|     <RequiredPkgs Count="3"> | ||||
|       <Item1> | ||||
|   | ||||
| @@ -49,7 +49,7 @@ uses | ||||
|   uCEFLinkedWindowParent, uCEFUrlRequestClientEvents,  | ||||
|   uCEFUrlRequestClientComponent, uCEFOSRIMEHandler, uCEFCookieAccessFilter,  | ||||
|   uCEFResourceReadCallback, uCEFResourceRequestHandler,  | ||||
|   uCEFResourceSkipCallback, LazarusPackageIntf; | ||||
|   uCEFResourceSkipCallback, uCEFSentinel, LazarusPackageIntf; | ||||
|  | ||||
| implementation | ||||
|  | ||||
| @@ -64,6 +64,7 @@ begin | ||||
|   RegisterUnit('uCEFLinkedWindowParent', @uCEFLinkedWindowParent.Register); | ||||
|   RegisterUnit('uCEFUrlRequestClientComponent',  | ||||
|     @uCEFUrlRequestClientComponent.Register); | ||||
|   RegisterUnit('uCEFSentinel', @uCEFSentinel.Register); | ||||
| end; | ||||
|  | ||||
| initialization | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| @@ -8,4 +8,5 @@ TFMXBufferPanel BITMAP "bufferpanel.bmp" | ||||
| TCEFWorkScheduler BITMAP "workscheduler.bmp" | ||||
| TFMXWorkScheduler BITMAP "workscheduler.bmp" | ||||
| TCEFServerComponent BITMAP "server.bmp" | ||||
| TCEFUrlRequestClientComponent BITMAP "tcefurlrequestclientcomponent.bmp" | ||||
| TCEFUrlRequestClientComponent BITMAP "tcefurlrequestclientcomponent.bmp" | ||||
| TCEFSentinel BITMAP "tcefsentinel.bmp" | ||||
							
								
								
									
										
											BIN
										
									
								
								packages/res/tcefsentinel.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								packages/res/tcefsentinel.bmp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								packages/res/tcefsentinel.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								packages/res/tcefsentinel.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.3 KiB | 
							
								
								
									
										59
									
								
								source/res/tcefsentinel.lrs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								source/res/tcefsentinel.lrs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| LazarusResources.Add('tcefsentinel','PNG',[ | ||||
|   #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 | ||||
|   +#0#5#6'IDATx^'#181#211'[l\G'#29#128#241'o'#206#236#185#236'9{'#214#235#181 | ||||
|   +#157#198#137#227#144#218#169#9#165'$'#144#134'DEA\[B+E@i'#27'E'#225#5#137'B' | ||||
|   +#218'*'#8#132#130'P'#145#130'J'#11#15#180'@_'#10'<'#18'*5\BRPE'#220#10#25#169 | ||||
|   +#165'PH'#8'%u'#28#223#18'_c'#27';'#190#236#174#247'\g'#224#201'N'#240#241'#?' | ||||
|   +'i'#164'y'#251#230#175#191'F'#140']{'#147',37'#150#136#162#152#186#200#209 | ||||
|   +#209#218'Dei'#145' L'#208#128'm'#230'('#20'\'#174'W'#2#140'0'#192#0#220#188 | ||||
|   +'E'#22#131#255#171#245#3#18'8'#13'h'#224'I'#0#192#7'.'#0'!p'#4#0#216#10#244#3 | ||||
|   +'s'#192#17'2'#228'N'#158#250'#'#25'>'#178#235#238'w}fnz'#28#175#212'~7'#173 | ||||
|   +'M'#31#13#162'xG_'#127#255#206'(H'#140#214'M-'#135#186#182'wNX'#136#206#190 | ||||
|   +#225#193#219'[JR'#14#214#236#199'O'#191#244#234#201'5'#129#201#153#217#204 | ||||
|   +#240'ng+'#229#22#143'B'#222'9X'#171#215#14#166'ZcX'#2#223#206'a:'#242'@'#16 | ||||
|   +#135#7#156#156#162#212'hSjv'#24#156#158#181#1#1#232'['#2'hE'#22'i'#154'4'#183 | ||||
|   +#182'Q'#143#18'f'#230#199#240'\'#155#174';'#218#136#162#4#12#201#244#220#4 | ||||
|   +#142'#'#217#220#182#17#215'31'#196#156#150#134'\'#251#210'4'#213'd'#137'bE' | ||||
|   +#156#24'D'#145'&MM'#22'+`'#153#9'1'#6':'#138#145#134'M=V'#132'I'#136'WtH'#21 | ||||
|   +' '#196#218#128'a'#8#178'('#13#210#148#4#243#26#223#183#169#135#9#181'@'#227 | ||||
|   +'z9ja'#130#151#183'Hu'#130'V'#138'0'#21'$'#177'B(2&H'#20#217'$'#210#243')' | ||||
|   +#182#184'@'#130#231'H'#148'V'#196'IL'#243#198#18#203#181#16#19'I./'#137#132 | ||||
|   +#129#22#8#141'Z'#187#3#149'$d'#232'{'#163#231#31'W'#154'J'#162#203#182#243',' | ||||
|   +'U'#3#194'j'#130#237#26#184'y'#135#197#197':i'#172'h'#185#173'H'#148#212'IR' | ||||
|   +#147#153#235#213#179#128'Z3'#1#217'F'#22#230#166'z6'#149#203']/'#254#228#12 | ||||
|   +#31#188#231'Nv'#237#220'F'#239#229#171#156#237#249#23#135#14#127#18#179#168 | ||||
|   +'8'#249#179'3'#28'<'#184#15#225'5'#167#19#163'S'#167#132#153#177#131'B'#227 | ||||
|   +#218#198#179'O?'#15#240#229#211'/?'#247#232#133#243#19#236#221#191#135'm];' | ||||
|   +#184#220'?'#207#165#139#147'l'#127#186#147#249#217'e'#254'z~'#140#195'G'#238 | ||||
|   +''''#191#161#145#151'~'#241'l/'#192#131#143'<tk@k'#201'z'#10'~'#158#207#31 | ||||
|   +#250#4#157#29'['#169'.'#196'l'#217#212#202'#_'#184#151'$Q8'#182#203#195#15'}' | ||||
|   +#154#141#155'7'#16#136#213'G'#26'2wk'#224#185'g~'#184#18'8'#246#205#175'r3E' | ||||
|   +#158#175#28#187#143' '#208#160#20'w'#237#222#194#206'=m,U'#18#252#13#146#175 | ||||
|   +#29'?'#128'D'#210'7'#182#176#18#8#131'h'#253#29#252#248#251'?'#226'f'#150#173 | ||||
|   +#176'm'#15#165#3','#203'Bk'#205#194'R'#136#239#251',W#\/G.g!'#13'c%p'#246'7' | ||||
|   +#191#206#10'd'#19#194' '#136#4#134#244#176#243#30#13#141'6'#229#219' M#T'#156 | ||||
|   +#146'F1Z'#5#228'='#151#245#172#164#179#162'I'#224'`'#155#18#203'qy'#251#226#0 | ||||
|   +#221#175#188#197#200#224#0#231'~'#247'w&&'#171#164'H'#234'1'#132#245'T'#176 | ||||
|   +'J'#172#23#16#128#252#231#240'+'#223#248#210'wo'#215#143'~'#251#179'Z'#202#2 | ||||
|   +#228'$'#210'*'#240#231'W'#255#196#137'/>'#201#177#207'='#206#247#158'8'#193 | ||||
|   +#244#204#20'ab'#162'S'#143'J50X'#229#220#28'1'#186#187#187#249#239#1#144#245 | ||||
|   +#160#178#235#167'?'#127#230#235'gN'#141'`'#231'|'#26#202#22#203'aH'#144#166 | ||||
|   +#188#247'='#219'y'#224#195'['#248#208#251';'#216#183#163'H'#177'a#'#11#11')N' | ||||
|   +#193'B'#24#146#195#199';'#245'k'#231#159'?'#167'Q[Vw'#187'z'#17#19#227#147 | ||||
|   +#214#181#241#190#206#201#201#177'r'#131'P'#220#24']'#166#161#201'e'#254#154 | ||||
|   +'I'#177#0#197'&'#137'%%HA'#177#152#167#185#201'E[PY'#142#137#130'<'#127#235 | ||||
|   +#25#162'V'#127#234'^['#181#31#232'h'#221#247#194'J'#224#232#209#163#0'ttt' | ||||
|   +#202'T'#197#11'-]~m'#239'}'#237#133'2-'#140'_'#139'i,'#22#144#194'ajl'#145 | ||||
|   +#235#163#163'8'#133'"'#245'j'#194#236'\H'#185#165#132'-M'#202'%'#147#246#210 | ||||
|   +#30#230#134#7'x'#234#196#15#2#17#251#198#255'N'#160#187#187#207#197#192#200 | ||||
|   +#190'd'#243';'#31#127#184'}oci'#129#129#161'q'#194'z'#140#176#167#232#235#159 | ||||
|   +#196'h'#220'L'#185#173#149'@'#141'sud'#154#185#217'"'#166'3@'#221'|'#139#7#31 | ||||
|   +#187#139#151'_'#188'1'#248#135'_'#189#241#186#214#168#149#192#208#208#16#0'@' | ||||
|   +#4'\'#181#253#220#191#135'/'#207'Q'#173#245#242#169#7':'#185#227#206#143'Q' | ||||
|   +#240#203#236#222#191#23#183#208#192#185#215#191#195#219#151'fX'#206#247#240 | ||||
|   +#238#174'm'#252#242#183'/p'#229'R/'#239#251'@'#23#165#13#254',Z'#140#130#142 | ||||
|   +#178#254#129#2#194#137#193#197#191#136#208#191#223'kh'#162#191#247'5q'#225 | ||||
|   +#205'n]r'#247'/'#162','#25'%'#149#220#149#193#223#231#227#154#162':t'#145#225 | ||||
|   +'K'#223'"'#172'('#220'd'#19'c'#23#151#169#4'I'#5#168#176#138#255#0#174#140#28 | ||||
|   +'#'#173#140#155#148#0#0#0#0'IEND'#174'B`'#130 | ||||
| ]); | ||||
| @@ -589,6 +589,8 @@ const | ||||
|   CEF_DOONBEFORECLOSE    = WM_APP + $A07;    | ||||
|   CEF_PENDINGINVALIDATE  = WM_APP + $A08; | ||||
|   CEF_IMERANGECHANGED    = WM_APP + $A09; | ||||
|   CEF_SENTINEL_START     = WM_APP + $A0A; | ||||
|   CEF_SENTINEL_DOCLOSE   = WM_APP + $A0B; | ||||
|   {$ENDIF} | ||||
|  | ||||
|   CEF_TIMER_MINIMUM            = $0000000A; | ||||
|   | ||||
							
								
								
									
										318
									
								
								source/uCEFSentinel.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										318
									
								
								source/uCEFSentinel.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,318 @@ | ||||
| // ************************************************************************ | ||||
| // ***************************** 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 � 2019 Salvador Diaz Fau. All rights reserved. | ||||
| // | ||||
| // ************************************************************************ | ||||
| // ************ vvvv Original license and comments below vvvv ************* | ||||
| // ************************************************************************ | ||||
| (* | ||||
|  *                       Delphi Chromium Embedded 3 | ||||
|  * | ||||
|  * Usage allowed under the restrictions of the Lesser GNU General Public License | ||||
|  * or alternatively the restrictions of the Mozilla Public License 1.1 | ||||
|  * | ||||
|  * Software distributed under the License is distributed on an "AS IS" basis, | ||||
|  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for | ||||
|  * the specific language governing rights and limitations under the License. | ||||
|  * | ||||
|  * Unit owner : Henri Gourvest <hgourvest@gmail.com> | ||||
|  * 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. | ||||
|  * | ||||
|  *) | ||||
|  | ||||
|  // Attribution : | ||||
|  // TCEFSentinel icon made by Everaldo Coelho | ||||
|  // https://www.iconfinder.com/icons/17914/castle_fortress_tower_war_icon | ||||
|  // http://www.everaldo.com/ | ||||
|  | ||||
| unit uCEFSentinel; | ||||
|  | ||||
| {$IFDEF FPC} | ||||
|   {$MODE OBJFPC}{$H+} | ||||
| {$ENDIF} | ||||
|  | ||||
| {$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} | ||||
| {$MINENUMSIZE 4} | ||||
|  | ||||
| {$I cef.inc} | ||||
|  | ||||
| interface | ||||
|  | ||||
| uses | ||||
|   {$IFDEF DELPHI16_UP} | ||||
|     {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} | ||||
|     System.Classes, Vcl.Controls, Vcl.ExtCtrls, System.SysUtils, System.SyncObjs, System.Math, | ||||
|   {$ELSE} | ||||
|     {$IFDEF MSWINDOWS}Windows, {$ENDIF} Classes, Controls, ExtCtrls, SysUtils, SyncObjs, Math, | ||||
|     {$IFDEF FPC} | ||||
|     LCLProc, LCLIntf, LResources, LMessages, InterfaceBase, | ||||
|     {$ELSE} | ||||
|     Messages, | ||||
|     {$ENDIF} | ||||
|   {$ENDIF} | ||||
|   uCEFTypes, uCEFInterfaces; | ||||
|  | ||||
| const | ||||
|   CEFSENTINEL_DEFAULT_DELAYPERPROCMS = 200; | ||||
|   CEFSENTINEL_DEFAULT_MININITDELAYMS = 1500; | ||||
|   CEFSENTINEL_DEFAULT_FINALDELAYMS   = 100; | ||||
|   CEFSENTINEL_DEFAULT_MINCHILDPROCS  = 2; | ||||
|   CEFSENTINEL_DEFAULT_MAXCHECKCOUNTS = 10; | ||||
|  | ||||
| type | ||||
|   TSentinelStatus = (ssIdle, ssInitialDelay, ssCheckingChildren, ssClosing); | ||||
|  | ||||
|   {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} | ||||
|   TCEFSentinel = class(TComponent) | ||||
|     protected | ||||
|       FCompHandle             : HWND; | ||||
|       FStatus                 : TSentinelStatus; | ||||
|       FStatusCS               : TCriticalSection; | ||||
|       FDelayPerProcMs         : cardinal; | ||||
|       FMinInitDelayMs         : cardinal; | ||||
|       FFinalDelayMs           : cardinal; | ||||
|       FMinChildProcs          : integer; | ||||
|       FMaxCheckCount          : integer; | ||||
|       FCheckCount             : integer; | ||||
|       FOnClose                : TNotifyEvent; | ||||
|       FTimer                  : TTimer; | ||||
|  | ||||
|       function  GetStatus : TSentinelStatus; | ||||
|       function  GetChildProcCount : integer; | ||||
|  | ||||
|       {$IFDEF MSWINDOWS} | ||||
|       procedure WndProc(var aMessage: TMessage); | ||||
|       procedure doStartMsg(var aMessage : TMessage); virtual; | ||||
|       procedure doCloseMsg(var aMessage : TMessage); virtual; | ||||
|       {$ENDIF} | ||||
|       function  SendCompMessage(aMsg : cardinal) : boolean; | ||||
|       function  CanClose : boolean; virtual; | ||||
|  | ||||
|       procedure Timer_OnTimer(Sender: TObject); virtual; | ||||
|  | ||||
|     public | ||||
|       constructor Create(AOwner: TComponent); override; | ||||
|       destructor  Destroy; override; | ||||
|       procedure   AfterConstruction; override; | ||||
|       procedure   Start; virtual; | ||||
|  | ||||
|       property Status          : TSentinelStatus  read GetStatus; | ||||
|       property ChildProcCount  : integer          read GetChildProcCount; | ||||
|  | ||||
|     published | ||||
|       property DelayPerProcMs  : cardinal         read FDelayPerProcMs   write FDelayPerProcMs  default CEFSENTINEL_DEFAULT_DELAYPERPROCMS; | ||||
|       property MinInitDelayMs  : cardinal         read FMinInitDelayMs   write FMinInitDelayMs  default CEFSENTINEL_DEFAULT_MININITDELAYMS; | ||||
|       property FinalDelayMs    : cardinal         read FFinalDelayMs     write FFinalDelayMs    default CEFSENTINEL_DEFAULT_FINALDELAYMS; | ||||
|       property MinChildProcs   : integer          read FMinChildProcs    write FMinChildProcs   default CEFSENTINEL_DEFAULT_MINCHILDPROCS; | ||||
|       property MaxCheckCount   : integer          read FMaxCheckCount    write FMaxCheckCount   default CEFSENTINEL_DEFAULT_MAXCHECKCOUNTS; | ||||
|  | ||||
|       property OnClose         : TNotifyEvent     read FOnClose          write FOnClose; | ||||
|   end; | ||||
|  | ||||
| {$IFDEF FPC} | ||||
| procedure Register; | ||||
| {$ENDIF} | ||||
|  | ||||
| implementation | ||||
|  | ||||
| uses | ||||
|   uCEFLibFunctions, uCEFApplication, uCEFMiscFunctions, uCEFConstants; | ||||
|  | ||||
| constructor TCEFSentinel.Create(AOwner: TComponent); | ||||
| begin | ||||
|   inherited Create(aOwner); | ||||
|  | ||||
|   FCompHandle             := 0; | ||||
|   FDelayPerProcMs         := CEFSENTINEL_DEFAULT_DELAYPERPROCMS; | ||||
|   FMinInitDelayMs         := CEFSENTINEL_DEFAULT_MININITDELAYMS; | ||||
|   FFinalDelayMs           := CEFSENTINEL_DEFAULT_FINALDELAYMS; | ||||
|   FMinChildProcs          := CEFSENTINEL_DEFAULT_MINCHILDPROCS; | ||||
|   FMaxCheckCount          := CEFSENTINEL_DEFAULT_MAXCHECKCOUNTS; | ||||
|   FOnClose                := nil; | ||||
|   FTimer                  := nil; | ||||
|   FStatusCS               := nil; | ||||
|   FStatus                 := ssIdle; | ||||
|   FCheckCount             := 0; | ||||
| end; | ||||
|  | ||||
| procedure TCEFSentinel.AfterConstruction; | ||||
| {$IFDEF FPC} | ||||
| var | ||||
|   TempWndMethod : TWndMethod; | ||||
| {$ENDIF} | ||||
| begin | ||||
|   inherited AfterConstruction; | ||||
|  | ||||
|   if not(csDesigning in ComponentState) then | ||||
|     begin | ||||
|       {$IFDEF FPC} | ||||
|       {$IFDEF MSWINDOWS} | ||||
|       TempWndMethod    := @WndProc; | ||||
|       FCompHandle      := AllocateHWnd(TempWndMethod); | ||||
|       {$ENDIF} | ||||
|       {$ELSE} | ||||
|       FCompHandle      := AllocateHWnd(WndProc); | ||||
|       {$ENDIF} | ||||
|  | ||||
|       FStatusCS        := TCriticalSection.Create; | ||||
|       FTimer           := TTimer.Create(nil); | ||||
|       FTimer.Enabled   := False; | ||||
|       FTimer.OnTimer   := {$IFDEF FPC}@{$ENDIF}Timer_OnTimer; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| destructor TCEFSentinel.Destroy; | ||||
| begin | ||||
|   try | ||||
|     {$IFDEF MSWINDOWS} | ||||
|     if (FCompHandle <> 0) then | ||||
|       begin | ||||
|         DeallocateHWnd(FCompHandle); | ||||
|         FCompHandle := 0; | ||||
|       end; | ||||
|     {$ENDIF} | ||||
|  | ||||
|     if (FTimer    <> nil) then FreeAndNil(FTimer); | ||||
|     if (FStatusCS <> nil) then FreeAndNil(FStatusCS); | ||||
|   finally | ||||
|     inherited Destroy; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| {$IFDEF MSWINDOWS} | ||||
| procedure TCEFSentinel.WndProc(var aMessage: TMessage); | ||||
| begin | ||||
|   case aMessage.Msg of | ||||
|     CEF_SENTINEL_START   : doStartMsg(aMessage); | ||||
|     CEF_SENTINEL_DOCLOSE : doCloseMsg(aMessage); | ||||
|  | ||||
|     else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam); | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| procedure TCEFSentinel.doStartMsg(var aMessage : TMessage); | ||||
| begin | ||||
|   if (FTimer <> nil) then | ||||
|     begin | ||||
|       FTimer.Interval := max(ChildProcCount * CEFSENTINEL_DEFAULT_DELAYPERPROCMS, FMinInitDelayMs); | ||||
|       FTimer.Enabled  := True; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure TCEFSentinel.doCloseMsg(var aMessage : TMessage); | ||||
| begin | ||||
|   if assigned(FOnClose) then FOnClose(self); | ||||
| end; | ||||
| {$ENDIF} | ||||
|  | ||||
| function TCEFSentinel.SendCompMessage(aMsg : cardinal) : boolean; | ||||
| begin | ||||
|   Result := (FCompHandle <> 0) and PostMessage(FCompHandle, aMsg, 0, 0); | ||||
| end; | ||||
|  | ||||
| procedure TCEFSentinel.Start; | ||||
| begin | ||||
|   try | ||||
|     if (FStatusCS <> nil) then FStatusCS.Acquire; | ||||
|  | ||||
|     if (FStatus = ssIdle) then | ||||
|       begin | ||||
|         FStatus := ssInitialDelay; | ||||
|         SendCompMessage(CEF_SENTINEL_START); | ||||
|       end; | ||||
|   finally | ||||
|     if (FStatusCS <> nil) then FStatusCS.Release; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| function TCEFSentinel.GetStatus : TSentinelStatus; | ||||
| begin | ||||
|   Result := ssIdle; | ||||
|  | ||||
|   if (FStatusCS <> nil) then | ||||
|     try | ||||
|       FStatusCS.Acquire; | ||||
|       Result := FStatus; | ||||
|     finally | ||||
|       FStatusCS.Release; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| function TCEFSentinel.GetChildProcCount : integer; | ||||
| begin | ||||
|   if (GlobalCEFApp <> nil) then | ||||
|     Result := GlobalCEFApp.ChildProcessesCount | ||||
|    else | ||||
|     Result := 0; | ||||
| end; | ||||
|  | ||||
| function TCEFSentinel.CanClose : boolean; | ||||
| begin | ||||
|   Result := (FCheckCount >= FMaxCheckCount) or | ||||
|             (GlobalCEFApp = nil) or | ||||
|             (ChildProcCount <= FMinChildProcs); | ||||
| end; | ||||
|  | ||||
| procedure TCEFSentinel.Timer_OnTimer(Sender: TObject); | ||||
| begin | ||||
|   FTimer.Enabled := False; | ||||
|  | ||||
|   try | ||||
|     if (FStatusCS <> nil) then FStatusCS.Acquire; | ||||
|  | ||||
|     case FStatus of | ||||
|       ssInitialDelay : | ||||
|         if CanClose then | ||||
|           begin | ||||
|             FStatus := ssClosing; | ||||
|             SendCompMessage(CEF_SENTINEL_DOCLOSE); | ||||
|           end | ||||
|          else | ||||
|           begin | ||||
|             FStatus         := ssCheckingChildren; | ||||
|             FCheckCount     := 0; | ||||
|             FTimer.Interval := FFinalDelayMs; | ||||
|             FTimer.Enabled  := True; | ||||
|           end; | ||||
|  | ||||
|       ssCheckingChildren : | ||||
|         if CanClose then | ||||
|           begin | ||||
|             FStatus := ssClosing; | ||||
|             SendCompMessage(CEF_SENTINEL_DOCLOSE); | ||||
|           end | ||||
|          else | ||||
|           begin | ||||
|             inc(FCheckCount); | ||||
|             FTimer.Enabled := True; | ||||
|           end; | ||||
|     end; | ||||
|   finally | ||||
|     if (FStatusCS <> nil) then FStatusCS.Release; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| {$IFDEF FPC} | ||||
| procedure Register; | ||||
| begin | ||||
|   {$I res/tcefsentinel.lrs} | ||||
|   RegisterComponents('Chromium', [TCEFSentinel]); | ||||
| end; | ||||
| {$ENDIF} | ||||
|  | ||||
| end. | ||||
| @@ -1,8 +1,8 @@ | ||||
| { | ||||
|   "UpdateLazPackages" : [ | ||||
|     { | ||||
|       "ForceNotify" : false, | ||||
|       "InternalVersion" : 40, | ||||
|       "ForceNotify" : true, | ||||
|       "InternalVersion" : 41, | ||||
|       "Name" : "cef4delphi_lazarus.lpk", | ||||
|       "Version" : "77.1.12.0" | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user