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 e0d64d07eab267edf2e559e905078c3dfda9145c..ab36e7174d8e3e4b9f4ef97aad006d8d714954fa 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -1447,10 +1447,13 @@ void WebContentsImpl::AttachToOuterWebContentsFrame( |
if (!render_manager->GetRenderWidgetHostView()) |
CreateRenderWidgetHostViewForRenderManager(GetRenderViewHost()); |
+ auto* outer_web_contents_impl = |
+ static_cast<WebContentsImpl*>(outer_web_contents); |
+ auto* outer_contents_frame_impl = |
+ static_cast<RenderFrameHostImpl*>(outer_contents_frame); |
// Create a link to our outer WebContents. |
- node_.ConnectToOuterWebContents( |
- static_cast<WebContentsImpl*>(outer_web_contents), |
- static_cast<RenderFrameHostImpl*>(outer_contents_frame)); |
+ node_.ConnectToOuterWebContents(outer_web_contents_impl, |
+ outer_contents_frame_impl); |
DCHECK(outer_contents_frame); |
@@ -1458,8 +1461,7 @@ void WebContentsImpl::AttachToOuterWebContentsFrame( |
// SiteInstance of the outer WebContents. The proxy will be used to send |
// postMessage to the inner WebContents. |
render_manager->CreateOuterDelegateProxy( |
- outer_contents_frame->GetSiteInstance(), |
- static_cast<RenderFrameHostImpl*>(outer_contents_frame)); |
+ outer_contents_frame->GetSiteInstance(), outer_contents_frame_impl); |
render_manager->SetRWHViewForInnerContents( |
render_manager->GetRenderWidgetHostView()); |
@@ -1468,6 +1470,11 @@ void WebContentsImpl::AttachToOuterWebContentsFrame( |
render_manager->GetRenderWidgetHostView()) |
->RegisterFrameSinkId(); |
+ if (outer_web_contents_impl->frame_tree_.GetFocusedFrame() == |
+ outer_contents_frame_impl->frame_tree_node()) { |
+ SetFocusedFrame(frame_tree_.root(), nullptr); |
+ } |
+ |
// At this point, we should destroy the TextInputManager which will notify all |
// the RWHV in this WebContents. The RWHV in this WebContents should use the |
// TextInputManager owned by the outer WebContents. |