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:
@ -27,6 +27,7 @@ CefRefPtr<DefaultClientHandler> DefaultClientHandler::GetForClient(
|
||||
bool DefaultClientHandler::OnBeforePopup(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int popup_id,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
|
||||
@ -52,11 +53,27 @@ bool DefaultClientHandler::OnBeforePopup(
|
||||
// created asynchronously.
|
||||
MainContext::Get()->GetRootWindowManager()->CreateRootWindowAsPopup(
|
||||
config.use_views, use_alloy_style_, config.with_controls,
|
||||
/*is_osr=*/false, /*is_devtools=*/false, popupFeatures, windowInfo,
|
||||
client, settings);
|
||||
/*is_osr=*/false, browser->GetIdentifier(), popup_id,
|
||||
/*is_devtools=*/false, popupFeatures, windowInfo, client, settings);
|
||||
|
||||
// Allow popup creation.
|
||||
return false;
|
||||
}
|
||||
|
||||
void DefaultClientHandler::OnBeforePopupAborted(CefRefPtr<CefBrowser> browser,
|
||||
int popup_id) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
MainContext::Get()->GetRootWindowManager()->AbortOrClosePopup(
|
||||
browser->GetIdentifier(), popup_id);
|
||||
}
|
||||
|
||||
void DefaultClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Close all popups that have this browser as the opener.
|
||||
OnBeforePopupAborted(browser, /*popup_id=*/-1);
|
||||
|
||||
BaseClientHandler::OnBeforeClose(browser);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
Reference in New Issue
Block a user