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 b91be9fcc9
commit 1a99a3abc5
45 changed files with 773 additions and 109 deletions

View File

@@ -209,6 +209,19 @@ class RootWindow
// Returns true if this window is using windowless rendering (osr).
virtual bool WithWindowlessRendering() const = 0;
// Returns true if this object has been initialized.
bool IsInitialized() const { return initialized_; }
// Returns true if the platform window has been created.
bool IsWindowCreated() const;
// Used to uniquely identify popup windows.
void SetPopupId(int opener_browser_id, int popup_id);
// If |popup_id| is -1 only match |opener_browser_id|.
bool IsPopupIdMatch(int opener_browser_id, int popup_id) const;
int opener_browser_id() const { return opener_browser_id_; }
int popup_id() const { return popup_id_; }
protected:
// Allow deletion via scoped_refptr only.
friend struct DeleteOnMainThread;
@@ -217,10 +230,19 @@ class RootWindow
explicit RootWindow(bool use_alloy_style);
virtual ~RootWindow();
// Members set during initialization. Safe to access from any thread.
Delegate* delegate_ = nullptr;
bool initialized_ = false;
// Only accessed on the main thread.
bool window_created_ = false;
private:
const bool use_alloy_style_;
// Members set during initialization. Safe to access from any thread.
int opener_browser_id_ = 0;
int popup_id_ = 0;
};
} // namespace client