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

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

Issue 2797473005: Fix interstitials on OOPIF-based guests. (Closed)
Patch Set: rebase 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/test/browser_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40f1d41bf1a00133e5800dffefa5a0f652ebbbec..dc437897ed35eb4f2c627c919a212ff6562e260f 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1849,8 +1849,21 @@ RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost(
if (receiving_widget != GetMainFrame()->GetRenderWidgetHost())
return receiving_widget;
+ 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();
+ }
+
FrameTreeNode* focused_frame =
- GetFocusedWebContents()->frame_tree_.GetFocusedFrame();
+ focused_contents->frame_tree_.GetFocusedFrame();
+
if (!focused_frame)
return receiving_widget;
@@ -1866,7 +1879,17 @@ RenderWidgetHostImpl* WebContentsImpl::GetFocusedRenderWidgetHost(
}
RenderWidgetHostImpl* WebContentsImpl::GetRenderWidgetHostWithPageFocus() {
- return GetFocusedWebContents()->GetMainFrame()->GetRenderWidgetHost();
+ WebContentsImpl* focused_web_contents = GetFocusedWebContents();
+
+ if (focused_web_contents->ShowingInterstitialPage()) {
+ return static_cast<RenderFrameHostImpl*>(
+ focused_web_contents->GetRenderManager()
+ ->interstitial_page()
+ ->GetMainFrame())
+ ->GetRenderWidgetHost();
+ }
+
+ return focused_web_contents->GetMainFrame()->GetRenderWidgetHost();
}
void WebContentsImpl::EnterFullscreenMode(const GURL& origin) {
@@ -2673,6 +2696,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() {
@@ -2686,6 +2722,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();
@@ -4764,7 +4813,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);
}
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/test/browser_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698