diff --git a/demos/Lazarus_Windows/PopupBrowser/uChildForm.lfm b/demos/Lazarus_Windows/PopupBrowser/uChildForm.lfm index 15c15940..f1857746 100644 --- a/demos/Lazarus_Windows/PopupBrowser/uChildForm.lfm +++ b/demos/Lazarus_Windows/PopupBrowser/uChildForm.lfm @@ -11,15 +11,14 @@ object ChildForm: TChildForm Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' + Position = poScreenCenter + ShowInTaskBar = stAlways OnClose = FormClose OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnDestroy = FormDestroy OnHide = FormHide OnShow = FormShow - Position = poScreenCenter - ShowInTaskBar = stAlways - LCLVersion = '3.4.0.0' object Panel1: TBufferPanel Left = 0 Height = 256 @@ -50,6 +49,7 @@ object ChildForm: TChildForm OnCursorChange = chrmosrCursorChange OnBeforePopup = chrmosrBeforePopup OnBeforeClose = chrmosrBeforeClose + OnOpenUrlFromTab = chrmosrOpenUrlFromTab OnGetViewRect = chrmosrGetViewRect OnGetScreenPoint = chrmosrGetScreenPoint OnGetScreenInfo = chrmosrGetScreenInfo diff --git a/demos/Lazarus_Windows/PopupBrowser/uChildForm.pas b/demos/Lazarus_Windows/PopupBrowser/uChildForm.pas index 1df35d11..c35fab6b 100644 --- a/demos/Lazarus_Windows/PopupBrowser/uChildForm.pas +++ b/demos/Lazarus_Windows/PopupBrowser/uChildForm.pas @@ -52,10 +52,11 @@ type procedure chrmosrPopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect); procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser); procedure chrmosrTooltip(Sender: TObject; const browser: ICefBrowser; var aText: ustring; out Result: Boolean); - procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean); + procedure chrmosrBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; popup_id: Integer; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean); procedure chrmosrTitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring); procedure chrmosrBeforeClose(Sender: TObject; const browser: ICefBrowser); procedure chrmosrCanFocus(Sender: TObject); + procedure chrmosrOpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean); protected FPopUpBitmap : TBitmap; @@ -177,20 +178,6 @@ begin end; end; -procedure TChildForm.chrmosrBeforePopup(Sender: TObject; - const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, - targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; - userGesture: Boolean; const popupFeatures: TCefPopupFeatures; - var windowInfo: TCefWindowInfo; var client: ICefClient; - var settings: TCefBrowserSettings; - var extra_info: ICefDictionaryValue; - var noJavascriptAccess: Boolean; - var Result: Boolean); -begin - // For simplicity, this demo blocks all popup windows and new tabs - Result := (targetDisposition in [CEF_WOD_NEW_FOREGROUND_TAB, CEF_WOD_NEW_BACKGROUND_TAB, CEF_WOD_NEW_POPUP, CEF_WOD_NEW_WINDOW]); -end; - procedure TChildForm.chrmosrCursorChange( Sender : TObject; const browser : ICefBrowser; cursor_ : TCefCursorHandle; @@ -556,14 +543,19 @@ end; procedure TChildForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin - CanClose := FCanClose; - - if not(FClosing) then + if FClientInitialized then begin - FClosing := True; - Visible := False; - chrmosr.CloseBrowser(True); - end; + CanClose := FCanClose; + + if not(FClosing) then + begin + FClosing := True; + Visible := False; + chrmosr.CloseBrowser(True); + end; + end + else + CanClose := True; end; procedure TChildForm.FormCreate(Sender: TObject); @@ -747,6 +739,28 @@ begin chrmosr.SetFocus(True); end; +procedure TChildForm.chrmosrBeforePopup(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; popup_id: Integer; + const targetUrl, targetFrameName: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; + const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; + var client: ICefClient; var settings: TCefBrowserSettings; + var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; + var Result: Boolean); +begin + // For simplicity, this demo blocks all popup windows and new tabs + Result := (targetDisposition in [CEF_WOD_NEW_FOREGROUND_TAB, CEF_WOD_NEW_BACKGROUND_TAB, CEF_WOD_NEW_POPUP, CEF_WOD_NEW_WINDOW]); +end; + +procedure TChildForm.chrmosrOpenUrlFromTab(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out + Result: Boolean); +begin + // For simplicity, this demo blocks all popup windows and new tabs + Result := (targetDisposition in [CEF_WOD_NEW_FOREGROUND_TAB, CEF_WOD_NEW_BACKGROUND_TAB, CEF_WOD_NEW_POPUP, CEF_WOD_NEW_WINDOW]); +end; + procedure TChildForm.chrmosrCanFocus(Sender: TObject); begin // The browser required some time to create associated internal objects @@ -826,7 +840,7 @@ end; procedure TChildForm.FormClose(Sender: TObject; var aAction: TCloseAction); begin - aAction := caFree; + aAction := TCloseAction.caFree; end; procedure TChildForm.ShowChildMsg(var aMessage : TMessage); diff --git a/demos/Lazarus_Windows/PopupBrowser/uMainForm.lfm b/demos/Lazarus_Windows/PopupBrowser/uMainForm.lfm index c657d92a..2273c540 100644 --- a/demos/Lazarus_Windows/PopupBrowser/uMainForm.lfm +++ b/demos/Lazarus_Windows/PopupBrowser/uMainForm.lfm @@ -10,12 +10,11 @@ object MainForm: TMainForm Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' + Position = poScreenCenter OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnDestroy = FormDestroy OnShow = FormShow - Position = poScreenCenter - LCLVersion = '3.4.0.0' object AddressPnl: TPanel Left = 0 Height = 21 @@ -68,6 +67,7 @@ object MainForm: TMainForm OnAfterCreated = Chromium1AfterCreated OnBeforeClose = Chromium1BeforeClose OnClose = Chromium1Close + OnOpenUrlFromTab = Chromium1OpenUrlFromTab Left = 56 Top = 152 end diff --git a/demos/Lazarus_Windows/PopupBrowser/uMainForm.pas b/demos/Lazarus_Windows/PopupBrowser/uMainForm.pas index 070bfc62..33725b91 100644 --- a/demos/Lazarus_Windows/PopupBrowser/uMainForm.pas +++ b/demos/Lazarus_Windows/PopupBrowser/uMainForm.pas @@ -39,6 +39,7 @@ type procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; popup_id: Integer; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean); procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction); + procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean); protected FChildForm : TChildForm; @@ -303,6 +304,15 @@ begin Chromium1.LoadURL(UTF8Decode(AddressEdt.Text)); end; +procedure TMainForm.Chromium1OpenUrlFromTab(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; + targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out + Result: Boolean); +begin + // For simplicity, this demo blocks all popup windows and new tabs + Result := (targetDisposition in [CEF_WOD_NEW_FOREGROUND_TAB, CEF_WOD_NEW_BACKGROUND_TAB, CEF_WOD_NEW_POPUP, CEF_WOD_NEW_WINDOW]); +end; + procedure TMainForm.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); begin FCanClose := True; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index b671b0af..ce401322 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 794, + "InternalVersion" : 795, "Name" : "cef4delphi_lazarus.lpk", "Version" : "140.1.14" }