mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add notification for aborted popups (fixes #3776)
Pass a new |popup_id| parameter to OnBeforePopup and call a new OnBeforePopupAborted callback if the popup is aborted before OnAfterCreated is called for the popup browser. Add new CefBrowserHost::GetBrowserByIdentifier and GetOpenerIdentifier methods to assist with retrieval of associated browsers. In cefclient, clean up state when a popup is aborted and close any associated popup browsers when the opener browser is closed. This also works when running with `--use-default-popup`.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=2319d794dd3a38c448908114d1b4ea37b34f89dd$
|
||||
// $hash=02fc65eec44894d136e5c5ed139927c675a84c6e$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||
@@ -79,6 +79,20 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
return CefBrowserCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefBrowser> CefBrowserHost::GetBrowserByIdentifier(int browser_id) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_browser_t* _retval =
|
||||
cef_browser_host_get_browser_by_identifier(browser_id);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefBrowserCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
@@ -198,6 +212,23 @@ CefWindowHandle CefBrowserHostCToCpp::GetOpenerWindowHandle() {
|
||||
return _retval;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") int CefBrowserHostCToCpp::GetOpenerIdentifier() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_browser_host_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_opener_identifier)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->get_opener_identifier(_struct);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall") bool CefBrowserHostCToCpp::HasView() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=73d8659f17a4ae3319b5bf20807d5c69a1759c04$
|
||||
// $hash=f3902d95b54a26c99f532f6d04ce7e8027c86830$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
||||
@@ -45,6 +45,7 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted<CefBrowserHostCToCpp,
|
||||
void SetFocus(bool focus) override;
|
||||
CefWindowHandle GetWindowHandle() override;
|
||||
CefWindowHandle GetOpenerWindowHandle() override;
|
||||
int GetOpenerIdentifier() override;
|
||||
bool HasView() override;
|
||||
CefRefPtr<CefClient> GetClient() override;
|
||||
CefRefPtr<CefRequestContext> GetRequestContext() override;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=f8686b23625810a3c7ceab1097eced10acec16ce$
|
||||
// $hash=fb1397bef33af6e40385469551b2037eeed8c390$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
|
||||
@@ -26,6 +26,7 @@ NO_SANITIZE("cfi-icall")
|
||||
bool CefLifeSpanHandlerCToCpp::OnBeforePopup(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int popup_id,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
WindowOpenDisposition target_disposition,
|
||||
@@ -81,9 +82,9 @@ bool CefLifeSpanHandlerCToCpp::OnBeforePopup(
|
||||
// Execute
|
||||
int _retval = _struct->on_before_popup(
|
||||
_struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
|
||||
target_url.GetStruct(), target_frame_name.GetStruct(), target_disposition,
|
||||
user_gesture, &popupFeatures, &windowInfo, &clientStruct, &settings,
|
||||
&extra_infoStruct, &no_javascript_accessInt);
|
||||
popup_id, target_url.GetStruct(), target_frame_name.GetStruct(),
|
||||
target_disposition, user_gesture, &popupFeatures, &windowInfo,
|
||||
&clientStruct, &settings, &extra_infoStruct, &no_javascript_accessInt);
|
||||
|
||||
// Restore param:client; type: refptr_same_byref
|
||||
if (clientStruct) {
|
||||
@@ -110,6 +111,30 @@ bool CefLifeSpanHandlerCToCpp::OnBeforePopup(
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefLifeSpanHandlerCToCpp::OnBeforePopupAborted(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
int popup_id) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_life_span_handler_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_before_popup_aborted)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->on_before_popup_aborted(_struct, CefBrowserCppToC::Wrap(browser),
|
||||
popup_id);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefLifeSpanHandlerCToCpp::OnBeforeDevToolsPopup(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=787463118d294d6a9b1004b54fb26b05c9f0a47b$
|
||||
// $hash=2e0ae9e4f7e647e43dc4d28fde904298550349e6$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_LIFE_SPAN_HANDLER_CTOCPP_H_
|
||||
@@ -39,6 +39,7 @@ class CefLifeSpanHandlerCToCpp
|
||||
// CefLifeSpanHandler methods.
|
||||
bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int popup_id,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
WindowOpenDisposition target_disposition,
|
||||
@@ -49,6 +50,8 @@ class CefLifeSpanHandlerCToCpp
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue>& extra_info,
|
||||
bool* no_javascript_access) override;
|
||||
void OnBeforePopupAborted(CefRefPtr<CefBrowser> browser,
|
||||
int popup_id) override;
|
||||
void OnBeforeDevToolsPopup(CefRefPtr<CefBrowser> browser,
|
||||
CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient>& client,
|
||||
|
Reference in New Issue
Block a user