Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1132)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2797473005: Fix interstitials on OOPIF-based guests. (Closed)
Patch Set: null check webcontents Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 1e665328a2f9847dee7d56cf9b84206ab0031d0a..f22d5c23645383f2aec7f25ff6b1f2345fcbc544 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1925,16 +1925,28 @@ RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost(
if (receiving_widget != GetMainFrame()->GetRenderWidgetHost())
return receiving_widget;
- // If the focused WebContents is a guest WebContents, then get the focused
- // frame in the embedder WebContents instead.
FrameTreeNode* focused_frame = nullptr;
WebContentsImpl* focused_contents = GetFocusedWebContents();
+
+ // If the focused WebContents is showing an interstitial, return the
+ // interstitial's widget.
+ if (focused_contents->ShowingInterstitialPage()) {
+ return static_cast<RenderFrameHostImpl*>(
+ focused_contents->GetRenderManager()
+ ->interstitial_page()
+ ->GetMainFrame())
+ ->GetRenderWidgetHost();
+ }
+
+ // If the focused WebContents is a guest WebContents, then get the focused
+ // frame in the embedder WebContents instead.
if (focused_contents->browser_plugin_guest_ &&
!GuestMode::IsCrossProcessFrameGuest(focused_contents)) {
focused_frame = frame_tree_.GetFocusedFrame();
} else {
focused_frame = GetFocusedWebContents()->frame_tree_.GetFocusedFrame();
}
+
if (!focused_frame)
return receiving_widget;
@@ -1950,6 +1962,16 @@ RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost(
}
RenderWidgetHostImpl* WebContentsImpl::GetRenderWidgetHostWithPageFocus() {
+ WebContentsImpl* focused_web_contents = GetFocusedWebContents();
+
+ if (focused_web_contents->ShowingInterstitialPage()) {
+ return static_cast<RenderFrameHostImpl*>(
+ focused_web_contents->GetRenderManager()
+ ->interstitial_page()
+ ->GetMainFrame())
+ ->GetRenderWidgetHost();
+ }
+
return GetFocusedWebContents()->GetMainFrame()->GetRenderWidgetHost();
}
@@ -2757,6 +2779,19 @@ void WebContentsImpl::AttachInterstitialPage(
// Stop the throbber if needed while the interstitial page is shown.
if (frame_tree_.IsLoading())
LoadingStateChanged(true, true, nullptr);
+
+ // Connect to outer WebContents if necessary.
+ if (node_.OuterContentsFrameTreeNode()) {
+ if (GetRenderManager()->GetProxyToOuterDelegate()) {
+ DCHECK(
+ static_cast<RenderWidgetHostViewBase*>(interstitial_page->GetView())
+ ->IsRenderWidgetHostViewChildFrame());
+ RenderWidgetHostViewChildFrame* view =
+ static_cast<RenderWidgetHostViewChildFrame*>(
+ interstitial_page->GetView());
+ GetRenderManager()->SetRWHViewForInnerContents(view);
+ }
+ }
}
void WebContentsImpl::DidProceedOnInterstitial() {
@@ -2770,6 +2805,19 @@ void WebContentsImpl::DidProceedOnInterstitial() {
}
void WebContentsImpl::DetachInterstitialPage() {
+ // Disconnect from outer WebContents if necessary.
+ if (node_.OuterContentsFrameTreeNode()) {
+ if (GetRenderManager()->GetProxyToOuterDelegate()) {
+ DCHECK(static_cast<RenderWidgetHostViewBase*>(
+ GetRenderManager()->current_frame_host()->GetView())
+ ->IsRenderWidgetHostViewChildFrame());
+ RenderWidgetHostViewChildFrame* view =
+ static_cast<RenderWidgetHostViewChildFrame*>(
+ GetRenderManager()->current_frame_host()->GetView());
+ GetRenderManager()->SetRWHViewForInnerContents(view);
+ }
+ }
+
bool interstitial_pausing_throbber =
ShowingInterstitialPage() &&
GetRenderManager()->interstitial_page()->pause_throbber();
@@ -4830,7 +4878,14 @@ void WebContentsImpl::SetAsFocusedWebContentsIfNecessary() {
if (GetRenderManager()->GetProxyToOuterDelegate())
GetRenderManager()->GetProxyToOuterDelegate()->SetFocusedFrame();
- GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true);
+ if (ShowingInterstitialPage()) {
+ static_cast<RenderFrameHostImpl*>(
+ GetRenderManager()->interstitial_page()->GetMainFrame())
+ ->GetRenderWidgetHost()
+ ->SetPageFocus(true);
+ } else {
+ GetMainFrame()->GetRenderWidgetHost()->SetPageFocus(true);
+ }
GetOutermostWebContents()->node_.SetFocusedWebContents(this);
}

Powered by Google App Engine
This is Rietveld 408576698