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

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

Issue 1312643002: Plumb opener information when creating RenderFrames and RenderFrameProxies for subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@opener-CreateOpenerProxiesIfNeeded
Patch Set: Add NewFrameProxy plumbing and test Created 5 years, 3 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 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 } 1966 }
1967 1967
1968 bool RenderFrameHostManager::InitRenderFrame( 1968 bool RenderFrameHostManager::InitRenderFrame(
1969 RenderFrameHostImpl* render_frame_host) { 1969 RenderFrameHostImpl* render_frame_host) {
1970 if (render_frame_host->IsRenderFrameLive()) 1970 if (render_frame_host->IsRenderFrameLive())
1971 return true; 1971 return true;
1972 1972
1973 int parent_routing_id = MSG_ROUTING_NONE; 1973 int parent_routing_id = MSG_ROUTING_NONE;
1974 int previous_sibling_routing_id = MSG_ROUTING_NONE; 1974 int previous_sibling_routing_id = MSG_ROUTING_NONE;
1975 int proxy_routing_id = MSG_ROUTING_NONE; 1975 int proxy_routing_id = MSG_ROUTING_NONE;
1976 1976 SiteInstance* site_instance = render_frame_host->GetSiteInstance();
1977 if (frame_tree_node_->parent()) { 1977 if (frame_tree_node_->parent()) {
1978 parent_routing_id = frame_tree_node_->parent()->render_manager()-> 1978 parent_routing_id = frame_tree_node_->parent()
1979 GetRoutingIdForSiteInstance(render_frame_host->GetSiteInstance()); 1979 ->render_manager()
1980 ->GetRoutingIdForSiteInstance(site_instance);
1980 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); 1981 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE);
1981 } 1982 }
1982 1983
1984 int opener_routing_id = MSG_ROUTING_NONE;
1985 if (frame_tree_node_->opener())
1986 opener_routing_id = GetOpenerRoutingID(site_instance);
1987
1983 // At this point, all RenderFrameProxies for sibling frames have already been 1988 // At this point, all RenderFrameProxies for sibling frames have already been
1984 // created, including any proxies that come after this frame. To preserve 1989 // created, including any proxies that come after this frame. To preserve
1985 // correct order for indexed window access (e.g., window.frames[1]), pass the 1990 // correct order for indexed window access (e.g., window.frames[1]), pass the
1986 // previous sibling frame so that this frame is correctly inserted into the 1991 // previous sibling frame so that this frame is correctly inserted into the
1987 // frame tree on the renderer side. 1992 // frame tree on the renderer side.
1988 FrameTreeNode* previous_sibling = frame_tree_node_->PreviousSibling(); 1993 FrameTreeNode* previous_sibling = frame_tree_node_->PreviousSibling();
1989 if (previous_sibling) { 1994 if (previous_sibling) {
1990 previous_sibling_routing_id = 1995 previous_sibling_routing_id =
1991 previous_sibling->render_manager()->GetRoutingIdForSiteInstance( 1996 previous_sibling->render_manager()->GetRoutingIdForSiteInstance(
1992 render_frame_host->GetSiteInstance()); 1997 site_instance);
1993 CHECK_NE(previous_sibling_routing_id, MSG_ROUTING_NONE); 1998 CHECK_NE(previous_sibling_routing_id, MSG_ROUTING_NONE);
1994 } 1999 }
1995 2000
1996 // Check whether there is an existing proxy for this frame in this 2001 // Check whether there is an existing proxy for this frame in this
1997 // SiteInstance. If there is, the new RenderFrame needs to be able to find 2002 // SiteInstance. If there is, the new RenderFrame needs to be able to find
1998 // the proxy it is replacing, so that it can fully initialize itself. 2003 // the proxy it is replacing, so that it can fully initialize itself.
1999 // NOTE: This is the only time that a RenderFrameProxyHost can be in the same 2004 // NOTE: This is the only time that a RenderFrameProxyHost can be in the same
2000 // SiteInstance as its RenderFrameHost. This is only the case until the 2005 // SiteInstance as its RenderFrameHost. This is only the case until the
2001 // RenderFrameHost commits, at which point it will replace and delete the 2006 // RenderFrameHost commits, at which point it will replace and delete the
2002 // RenderFrameProxyHost. 2007 // RenderFrameProxyHost.
2003 RenderFrameProxyHost* existing_proxy = 2008 RenderFrameProxyHost* existing_proxy = GetRenderFrameProxyHost(site_instance);
2004 GetRenderFrameProxyHost(render_frame_host->GetSiteInstance());
2005 if (existing_proxy) { 2009 if (existing_proxy) {
2006 proxy_routing_id = existing_proxy->GetRoutingID(); 2010 proxy_routing_id = existing_proxy->GetRoutingID();
2007 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE); 2011 CHECK_NE(proxy_routing_id, MSG_ROUTING_NONE);
2008 if (!existing_proxy->is_render_frame_proxy_live()) 2012 if (!existing_proxy->is_render_frame_proxy_live())
2009 existing_proxy->InitRenderFrameProxy(); 2013 existing_proxy->InitRenderFrameProxy();
2010 } 2014 }
2011 return delegate_->CreateRenderFrameForRenderManager( 2015 return delegate_->CreateRenderFrameForRenderManager(
2012 render_frame_host, parent_routing_id, previous_sibling_routing_id, 2016 render_frame_host, parent_routing_id, previous_sibling_routing_id,
2013 proxy_routing_id); 2017 proxy_routing_id, opener_routing_id);
2014 } 2018 }
2015 2019
2016 int RenderFrameHostManager::GetRoutingIdForSiteInstance( 2020 int RenderFrameHostManager::GetRoutingIdForSiteInstance(
2017 SiteInstance* site_instance) { 2021 SiteInstance* site_instance) {
2018 if (render_frame_host_->GetSiteInstance() == site_instance) 2022 if (render_frame_host_->GetSiteInstance() == site_instance)
2019 return render_frame_host_->GetRoutingID(); 2023 return render_frame_host_->GetRoutingID();
2020 2024
2021 // If there is a matching pending RFH, only return it if swapped out is 2025 // If there is a matching pending RFH, only return it if swapped out is
2022 // allowed, since otherwise there should be a proxy that should be used 2026 // allowed, since otherwise there should be a proxy that should be used
2023 // instead. 2027 // instead.
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2565 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2562 if (!frame_tree_node_->opener()) 2566 if (!frame_tree_node_->opener())
2563 return MSG_ROUTING_NONE; 2567 return MSG_ROUTING_NONE;
2564 2568
2565 return frame_tree_node_->opener() 2569 return frame_tree_node_->opener()
2566 ->render_manager() 2570 ->render_manager()
2567 ->GetRoutingIdForSiteInstance(instance); 2571 ->GetRoutingIdForSiteInstance(instance);
2568 } 2572 }
2569 2573
2570 } // namespace content 2574 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698