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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 1303773002: Give the main frame a RenderWidget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix all the tests. Probably. Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ResetProxyHosts(); 246 ResetProxyHosts();
247 247
248 // Release the WebUI prior to resetting the current RenderFrameHost, as the 248 // Release the WebUI prior to resetting the current RenderFrameHost, as the
249 // WebUI accesses the RenderFrameHost during cleanup. 249 // WebUI accesses the RenderFrameHost during cleanup.
250 web_ui_.reset(); 250 web_ui_.reset();
251 251
252 // We should always have a current RenderFrameHost except in some tests. 252 // We should always have a current RenderFrameHost except in some tests.
253 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); 253 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>());
254 } 254 }
255 255
256 void RenderFrameHostManager::Init(BrowserContext* browser_context, 256 void RenderFrameHostManager::Init(SiteInstance* site_instance,
257 SiteInstance* site_instance,
258 int32 view_routing_id, 257 int32 view_routing_id,
259 int32 frame_routing_id, 258 int32 frame_routing_id,
260 int32 widget_routing_id) { 259 int32 widget_routing_id) {
261 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It 260 DCHECK(site_instance);
262 // is important to immediately give this SiteInstance to a RenderViewHost so 261 // TODO(avi): While RenderViewHostImpl is-a RenderWidgetHostImpl, this must
263 // that the SiteInstance is ref counted. 262 // hold true to avoid having two RenderWidgetHosts for the top-level frame.
264 if (!site_instance) 263 // https://crbug.com/545684
265 site_instance = SiteInstance::Create(browser_context); 264 DCHECK_IMPLIES(frame_tree_node_->IsMainFrame(),
266 265 view_routing_id == widget_routing_id);
267 int flags = delegate_->IsHidden() ? CREATE_RF_HIDDEN : 0; 266 int flags = delegate_->IsHidden() ? CREATE_RF_HIDDEN : 0;
268 SetRenderFrameHost(CreateRenderFrameHost(site_instance, view_routing_id, 267 SetRenderFrameHost(CreateRenderFrameHost(site_instance, view_routing_id,
269 frame_routing_id, widget_routing_id, 268 frame_routing_id, widget_routing_id,
270 flags)); 269 flags));
271 270
272 // Notify the delegate of the creation of the current RenderFrameHost. 271 // Notify the delegate of the creation of the current RenderFrameHost.
273 // Do this only for subframes, as the main frame case is taken care of by 272 // Do this only for subframes, as the main frame case is taken care of by
274 // WebContentsImpl::Init. 273 // WebContentsImpl::Init.
275 if (!frame_tree_node_->IsMainFrame()) { 274 if (!frame_tree_node_->IsMainFrame()) {
276 delegate_->NotifySwappedFromRenderManager( 275 delegate_->NotifySwappedFromRenderManager(
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 // If we are reusing the RenderViewHost and it doesn't already have a 1794 // If we are reusing the RenderViewHost and it doesn't already have a
1796 // RenderWidgetHostView, we need to create one if this is the main frame. 1795 // RenderWidgetHostView, we need to create one if this is the main frame.
1797 if (!render_view_host->GetWidget()->GetView() && 1796 if (!render_view_host->GetWidget()->GetView() &&
1798 frame_tree_node_->IsMainFrame()) { 1797 frame_tree_node_->IsMainFrame()) {
1799 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host); 1798 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host);
1800 } 1799 }
1801 } 1800 }
1802 } else { 1801 } else {
1803 // Create a new RenderFrameHost if we don't find an existing one. 1802 // Create a new RenderFrameHost if we don't find an existing one.
1804 1803
1804 int32 view_routing_id = MSG_ROUTING_NONE;
1805 int32 widget_routing_id = MSG_ROUTING_NONE; 1805 int32 widget_routing_id = MSG_ROUTING_NONE;
1806 // A RenderFrame in a different process from its parent RenderFrame 1806 // A RenderFrame in a different process from its parent RenderFrame
1807 // requires a RenderWidget for input/layout/painting. 1807 // requires a RenderWidget for input/layout/painting.
1808 if (frame_tree_node_->parent() && 1808 if (frame_tree_node_->parent() &&
1809 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance() != 1809 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance() !=
1810 instance) { 1810 instance) {
1811 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 1811 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
1812 widget_routing_id = instance->GetProcess()->GetNextRoutingID(); 1812 widget_routing_id = instance->GetProcess()->GetNextRoutingID();
1813 } else if (!frame_tree_node_->parent()) {
1814 // TODO(avi): This branch can be merged with the above branch once
1815 // RenderViewHostImpl has-a RenderWidgetHostImpl. https://crbug.com/545684
1816 view_routing_id = widget_routing_id =
1817 instance->GetProcess()->GetNextRoutingID();
1813 } 1818 }
1814 1819
1815 new_render_frame_host = CreateRenderFrameHost( 1820 new_render_frame_host = CreateRenderFrameHost(
1816 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, widget_routing_id, flags); 1821 instance, view_routing_id, MSG_ROUTING_NONE, widget_routing_id, flags);
1817 RenderViewHostImpl* render_view_host = 1822 RenderViewHostImpl* render_view_host =
1818 new_render_frame_host->render_view_host(); 1823 new_render_frame_host->render_view_host();
1819 int proxy_routing_id = MSG_ROUTING_NONE; 1824 int proxy_routing_id = MSG_ROUTING_NONE;
1820 1825
1821 // Prevent the process from exiting while we're trying to navigate in it. 1826 // Prevent the process from exiting while we're trying to navigate in it.
1822 // Otherwise, if the new RFH is swapped out already, store it. 1827 // Otherwise, if the new RFH is swapped out already, store it.
1823 if (!swapped_out) { 1828 if (!swapped_out) {
1824 new_render_frame_host->GetProcess()->AddPendingView(); 1829 new_render_frame_host->GetProcess()->AddPendingView();
1825 } else { 1830 } else {
1826 proxy = new RenderFrameProxyHost( 1831 proxy = new RenderFrameProxyHost(
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2655 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2651 if (!frame_tree_node_->opener()) 2656 if (!frame_tree_node_->opener())
2652 return MSG_ROUTING_NONE; 2657 return MSG_ROUTING_NONE;
2653 2658
2654 return frame_tree_node_->opener() 2659 return frame_tree_node_->opener()
2655 ->render_manager() 2660 ->render_manager()
2656 ->GetRoutingIdForSiteInstance(instance); 2661 ->GetRoutingIdForSiteInstance(instance);
2657 } 2662 }
2658 2663
2659 } // namespace content 2664 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698