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:
Marshall Greenblatt
2024-11-08 19:05:04 -05:00
parent b660522983
commit e513077eac
45 changed files with 773 additions and 109 deletions

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=3883fd2aca10df181da30759fcce351fed62d43d$
// $hash=b3844320e2d708a582a4bc2e3d5f2f143de8f514$
//
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
@ -29,6 +29,7 @@ int CEF_CALLBACK life_span_handler_on_before_popup(
struct _cef_life_span_handler_t* self,
cef_browser_t* browser,
cef_frame_t* frame,
int popup_id,
const cef_string_t* target_url,
const cef_string_t* target_frame_name,
cef_window_open_disposition_t target_disposition,
@ -128,7 +129,7 @@ int CEF_CALLBACK life_span_handler_on_before_popup(
// Execute
bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), popup_id,
CefString(target_url), CefString(target_frame_name), target_disposition,
user_gesture ? true : false, popupFeaturesVal, windowInfoObj, clientPtr,
settingsObj, extra_infoPtr, &no_javascript_accessBool);
@ -170,6 +171,29 @@ int CEF_CALLBACK life_span_handler_on_before_popup(
return _retval;
}
void CEF_CALLBACK
life_span_handler_on_before_popup_aborted(struct _cef_life_span_handler_t* self,
cef_browser_t* browser,
int popup_id) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self) {
return;
}
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser) {
return;
}
// Execute
CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopupAborted(
CefBrowserCToCpp::Wrap(browser), popup_id);
}
void CEF_CALLBACK life_span_handler_on_before_dev_tools_popup(
struct _cef_life_span_handler_t* self,
cef_browser_t* browser,
@ -365,6 +389,8 @@ life_span_handler_on_before_close(struct _cef_life_span_handler_t* self,
CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC() {
GetStruct()->on_before_popup = life_span_handler_on_before_popup;
GetStruct()->on_before_popup_aborted =
life_span_handler_on_before_popup_aborted;
GetStruct()->on_before_dev_tools_popup =
life_span_handler_on_before_dev_tools_popup;
GetStruct()->on_after_created = life_span_handler_on_after_created;