chrome: Use default Browser creation for picture-in-picture popups (see issue #3448)

This commit is contained in:
Marshall Greenblatt
2023-02-09 13:15:15 -05:00
parent 371f7f3409
commit 82dc13a870
11 changed files with 176 additions and 93 deletions

View File

@ -70,7 +70,7 @@ index 03a6d3a2ee5e8..a19224279243c 100644
]
}
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
index 08ac5f0afd874..480986df48aa6 100644
index 08ac5f0afd874..9248d822a3745 100644
--- chrome/browser/ui/browser.cc
+++ chrome/browser/ui/browser.cc
@@ -264,6 +264,25 @@
@ -177,23 +177,7 @@ index 08ac5f0afd874..480986df48aa6 100644
NavigateParams nav_params(this, params.url, params.transition);
nav_params.FillNavigateParamsFromOpenURLParams(params);
nav_params.source_contents = source;
@@ -1712,6 +1770,15 @@ void Browser::AddNewContents(
return;
}
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef_browser_delegate_) {
+ cef_browser_delegate_->AddNewContents(
+ source, std::move(new_contents), target_url, disposition,
+ window_features, user_gesture, was_blocked);
+ return;
+ }
+#endif
+
chrome::AddWebContents(this, source, std::move(new_contents), target_url,
disposition, window_features, window_action);
}
@@ -1730,6 +1797,8 @@ void Browser::LoadingStateChanged(WebContents* source,
@@ -1730,6 +1788,8 @@ void Browser::LoadingStateChanged(WebContents* source,
bool should_show_loading_ui) {
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
UpdateWindowForLoadingStateChanged(source, should_show_loading_ui);
@ -202,7 +186,7 @@ index 08ac5f0afd874..480986df48aa6 100644
}
void Browser::CloseContents(WebContents* source) {
@@ -1757,6 +1826,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
@@ -1757,6 +1817,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
}
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
@ -211,7 +195,7 @@ index 08ac5f0afd874..480986df48aa6 100644
if (!GetStatusBubble())
return;
@@ -1764,6 +1835,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
@@ -1764,6 +1826,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
GetStatusBubble()->SetURL(url);
}
@ -229,7 +213,7 @@ index 08ac5f0afd874..480986df48aa6 100644
void Browser::ContentsMouseEvent(WebContents* source,
bool motion,
bool exited) {
@@ -1788,6 +1870,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) {
@@ -1788,6 +1861,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) {
return false;
}
@ -249,7 +233,7 @@ index 08ac5f0afd874..480986df48aa6 100644
void Browser::BeforeUnloadFired(WebContents* web_contents,
bool proceed,
bool* proceed_to_fire_unload) {
@@ -1880,6 +1975,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
@@ -1880,6 +1966,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
// Make the tab show up in the task manager.
task_manager::WebContentsTags::CreateForTabContents(new_contents);
@ -260,7 +244,7 @@ index 08ac5f0afd874..480986df48aa6 100644
}
void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) {
@@ -1991,11 +2090,15 @@ void Browser::EnterFullscreenModeForTab(
@@ -1991,11 +2081,15 @@ void Browser::EnterFullscreenModeForTab(
const blink::mojom::FullscreenOptions& options) {
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
requesting_frame, options.display_id);
@ -276,7 +260,7 @@ index 08ac5f0afd874..480986df48aa6 100644
}
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
@@ -2189,6 +2292,15 @@ void Browser::RequestMediaAccessPermission(
@@ -2189,6 +2283,15 @@ void Browser::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) {
@ -292,7 +276,7 @@ index 08ac5f0afd874..480986df48aa6 100644
const extensions::Extension* extension =
GetExtensionForOrigin(profile_, request.security_origin);
MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
@@ -2725,13 +2837,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
@@ -2725,13 +2828,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
// Browser, Getters for UI (private):
StatusBubble* Browser::GetStatusBubble() {
@ -314,7 +298,7 @@ index 08ac5f0afd874..480986df48aa6 100644
return window_ ? window_->GetStatusBubble() : nullptr;
}
@@ -2863,6 +2982,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
@@ -2863,6 +2973,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
web_contents_collection_.StopObserving(web_contents);
}
@ -444,7 +428,7 @@ index dda3f5ba7f9a3..67b0eaaddfd3b 100644
// tab helpers, so the entire set of tab helpers needs to be set up
// immediately.
diff --git chrome/browser/ui/browser_tabstrip.cc chrome/browser/ui/browser_tabstrip.cc
index a3dbf97b6f943..6d8e521e9f189 100644
index a3dbf97b6f943..799a64e17fca5 100644
--- chrome/browser/ui/browser_tabstrip.cc
+++ chrome/browser/ui/browser_tabstrip.cc
@@ -33,9 +33,13 @@ void AddTabAt(Browser* browser,
@ -462,3 +446,20 @@ index a3dbf97b6f943..6d8e521e9f189 100644
params.disposition = foreground ? WindowOpenDisposition::NEW_FOREGROUND_TAB
: WindowOpenDisposition::NEW_BACKGROUND_TAB;
params.tabstrip_index = idx;
@@ -71,6 +75,16 @@ void AddWebContents(Browser* browser,
// Can't create a new contents for the current tab - invalid case.
DCHECK(disposition != WindowOpenDisposition::CURRENT_TAB);
+#if BUILDFLAG(ENABLE_CEF)
+ if (browser && browser->cef_delegate() && new_contents) {
+ new_contents = browser->cef_delegate()->AddWebContents(
+ std::move(new_contents));
+ if (!new_contents) {
+ return;
+ }
+ }
+#endif
+
NavigateParams params(browser, std::move(new_contents));
params.source_contents = source_contents;
params.url = target_url;