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

@ -68,10 +68,23 @@ index 21967547790ca..7bdf48b830a21 100644
std::vector<base::FilePath>
diff --git content/public/browser/content_browser_client.h content/public/browser/content_browser_client.h
index 0f6781dc459e1..8d8deaba4e049 100644
index 0f6781dc459e1..3f3095cce2ba6 100644
--- content/public/browser/content_browser_client.h
+++ content/public/browser/content_browser_client.h
@@ -2188,7 +2188,7 @@ class CONTENT_EXPORT ContentBrowserClient {
@@ -1329,6 +1329,12 @@ class CONTENT_EXPORT ContentBrowserClient {
bool opener_suppressed,
bool* no_javascript_access);
+ // Called to report the result of new window creation after CanCreateWindow()
+ // returns true. There are cases where the new window may still be canceled.
+ virtual void CreateWindowResult(
+ RenderFrameHost* opener,
+ bool success) {}
+
// Allows the embedder to return a delegate for the SpeechRecognitionManager.
// The delegate will be owned by the manager. It's valid to return nullptr.
virtual SpeechRecognitionManagerDelegate*
@@ -2188,7 +2194,7 @@ class CONTENT_EXPORT ContentBrowserClient {
//
// If |relative_partition_path| is the empty string, it means this needs to
// create the default NetworkContext for the BrowserContext.
@ -80,7 +93,7 @@ index 0f6781dc459e1..8d8deaba4e049 100644
BrowserContext* context,
bool in_memory,
const base::FilePath& relative_partition_path,
@@ -2412,6 +2412,22 @@ class CONTENT_EXPORT ContentBrowserClient {
@@ -2412,6 +2418,22 @@ class CONTENT_EXPORT ContentBrowserClient {
const net::IsolationInfo& isolation_info,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory);
@ -103,7 +116,7 @@ index 0f6781dc459e1..8d8deaba4e049 100644
// Creates an OverlayWindow to be used for video or Picture-in-Picture.
// This window will house the content shown when in Picture-in-Picture mode.
// This will return a new OverlayWindow.
@@ -2472,6 +2488,10 @@ class CONTENT_EXPORT ContentBrowserClient {
@@ -2472,6 +2494,10 @@ class CONTENT_EXPORT ContentBrowserClient {
// Used as part of the user agent string.
virtual std::string GetProduct();

View File

@ -1,8 +1,25 @@
diff --git content/browser/renderer_host/render_frame_host_impl.cc content/browser/renderer_host/render_frame_host_impl.cc
index 98c865765c57d..7694cd4516dc9 100644
index 98c865765c57d..f31210f9c3070 100644
--- content/browser/renderer_host/render_frame_host_impl.cc
+++ content/browser/renderer_host/render_frame_host_impl.cc
@@ -11466,6 +11466,7 @@ void RenderFrameHostImpl::CommitNavigation(
@@ -9125,6 +9125,16 @@ void RenderFrameHostImpl::CreateNewWindow(
return;
}
+ callback = base::BindOnce(
+ [](RenderFrameHostImpl* self,
+ CreateNewWindowCallback callback,
+ mojom::CreateNewWindowStatus status,
+ mojom::CreateNewWindowReplyPtr reply) {
+ GetContentClient()->browser()->CreateWindowResult(
+ self, status == mojom::CreateNewWindowStatus::kSuccess);
+ std::move(callback).Run(status, std::move(reply));
+ }, base::Unretained(this), std::move(callback));
+
// Otherwise, consume user activation before we proceed. In particular, it is
// important to do this before we return from the |opener_suppressed| case
// below.
@@ -11466,6 +11476,7 @@ void RenderFrameHostImpl::CommitNavigation(
auto browser_calc_origin_to_commit =
navigation_request->GetOriginToCommitWithDebugInfo();
if (!process_lock.is_error_page() && !is_mhtml_subframe &&