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 31294a791d71f488f79923d29194aa5d97081f4c..1539e1703bc9b2c8409d229bd56076d2872116fc 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -221,6 +221,13 @@ void MakeNavigateParams(const NavigationEntryImpl& entry, |
params->base_url_for_data_url = entry.GetBaseURLForDataURL(); |
params->history_url_for_data_url = entry.GetVirtualURL(); |
} |
+ |
+ // TODO(creis): Store the renderer-specific frame ID on params. We'll |
+ // eventually use the RenderFrameHost routing ID, but for now we may need to |
+ // search the RenderViewHost's frame_id_map. |
+ //int64 frame_id = -1; |
+ //params->frame_id = frame_id; |
+ |
params->referrer = entry.GetReferrer(); |
params->transition = entry.GetTransitionType(); |
params->page_state = entry.GetPageState(); |
@@ -1611,8 +1618,16 @@ bool WebContentsImpl::NavigateToEntry( |
return false; |
} |
+ // TODO(creis): We need to store the frame ID on entry and use that to find |
+ // the correct RenderManager. |
+ int64 frame_tree_node_id = frame_tree_.root()->frame_tree_node_id(); |
+ if (entry.frame_tree_node_id() != -1) |
+ frame_tree_node_id = entry.frame_tree_node_id(); |
+ |
+ RenderViewHostManager* manager = |
+ frame_tree_.FindByID(frame_tree_node_id)->render_manager(); |
RenderViewHostImpl* dest_render_view_host = |
- static_cast<RenderViewHostImpl*>(GetRenderManager()->Navigate(entry)); |
+ static_cast<RenderViewHostImpl*>(manager->Navigate(entry)); |
if (!dest_render_view_host) |
return false; // Unable to create the desired render view host. |
@@ -1639,6 +1654,10 @@ bool WebContentsImpl::NavigateToEntry( |
current_load_start_ = base::TimeTicks::Now(); |
// Navigate in the desired RenderViewHost. |
+ // TODO(creis): Put frame ID in ViewMsg_Navigate_Params so that we can tell |
+ // the renderer which frame to navigate. Problem: it has to be the frame ID |
+ // in the destination renderer process, not the frame ID in the open params. |
+ // Or... just handle named frames for now. |
ViewMsg_Navigate_Params navigate_params; |
MakeNavigateParams(entry, controller_, delegate_, reload_type, |
&navigate_params); |
@@ -1976,6 +1995,13 @@ void WebContentsImpl::DidStartProvisionalLoadForFrame( |
render_view_host->GetProcess(); |
RenderViewHost::FilterURL(render_process_host, false, &validated_url); |
+ // TODO(creis): This is a hack for now, until we mirror the frame tree and do |
+ // cross-process subframe navigations in actual subframes. |
+ NavigationEntryImpl* pending_entry = |
+ NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); |
+ if (pending_entry && pending_entry->frame_tree_node_id() != -1) |
+ is_main_frame = false; |
+ |
if (is_main_frame) { |
DidChangeLoadProgress(0); |
@@ -1984,8 +2010,6 @@ void WebContentsImpl::DidStartProvisionalLoadForFrame( |
// SiteInstance, and ensure the address bar updates accordingly. We don't |
// know the referrer or extra headers at this point, but the referrer will |
// be set properly upon commit. |
- NavigationEntryImpl* pending_entry = |
- NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); |
bool has_browser_initiated_pending_entry = pending_entry && |
!pending_entry->is_renderer_initiated(); |
if (!has_browser_initiated_pending_entry && !is_error_page) { |
@@ -2689,9 +2713,8 @@ RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { |
return render_view_host_delegate_view_; |
} |
-RenderViewHostDelegate::RendererManagement* |
-WebContentsImpl::GetRendererManagementDelegate() { |
- return GetRenderManager(); |
+RenderViewHostManager* WebContentsImpl::GetRenderManager() const { |
+ return frame_tree_.root()->render_manager(); |
} |
RendererPreferences WebContentsImpl::GetRendererPrefs( |
@@ -2829,11 +2852,33 @@ void WebContentsImpl::DidGetRedirectForResourceRequest( |
void WebContentsImpl::DidNavigate( |
RenderViewHost* rvh, |
- const ViewHostMsg_FrameNavigate_Params& params) { |
- if (frame_tree_.IsFirstNavigationAfterSwap()) { |
+ const ViewHostMsg_FrameNavigate_Params& orig_params) { |
+ ViewHostMsg_FrameNavigate_Params params(orig_params); |
+ RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
+ if (!rvhi->HasFrameID(params.frame_id)) { |
// First navigation should be a main frame navigation. |
- DCHECK(PageTransitionIsMainFrame(params.transition)); |
- frame_tree_.OnFirstNavigationAfterSwap(params.frame_id); |
+ // TODO(creis): This DCHECK is disabled for now because cross-process |
+ // subframe navigations currently have a main frame PageTransition. |
+ //DCHECK(PageTransitionIsMainFrame(params.transition)); |
+ rvhi->RegisterFrameID(params.frame_id, |
+ frame_tree_.root()->frame_tree_node_id()); |
+ } |
+ |
+ // Look up the FrameTreeNode ID that the renderer-specific frame ID |
+ // corresponds to. |
+ int frame_tree_node_id = rvhi->GetFrameTreeNodeID(params.frame_id); |
+ |
+ // TODO(creis): In the short term, cross-process subframe navigations are |
+ // happening in the pending RenderViewHost's top-level frame. (We need to |
+ // both mirror the frame tree and get the navigation to occur in the correct |
+ // subframe to fix this.) Until then, we should check whether we have a |
+ // pending NavigationEntry with a frame ID and if so, treat the cross-process |
+ // "main frame" navigation as a subframe navigation. |
+ NavigationEntryImpl* pending_entry = NavigationEntryImpl::FromNavigationEntry( |
+ controller_.GetPendingEntry()); |
+ if (pending_entry && pending_entry->frame_tree_node_id() != -1) { |
+ params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
+ frame_tree_node_id = pending_entry->frame_tree_node_id(); |
} |
if (PageTransitionIsMainFrame(params.transition)) { |
@@ -2845,9 +2890,16 @@ void WebContentsImpl::DidNavigate( |
// that may have just been swapped out. |
if (delegate_ && delegate_->CanOverscrollContent()) |
controller_.TakeScreenshot(); |
+ } |
- GetRenderManager()->DidNavigateMainFrame(rvh); |
+ FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id); |
+ if (!frame) { |
+ // Just for debugging. We can't trust the renderer to lie about the ID. |
+ NOTREACHED(); |
+ return; |
} |
+ // TODO(creis): Rename to DidNavigateFrame. |
+ frame->render_manager()->DidNavigateMainFrame(rvh); |
// Update the site of the SiteInstance if it doesn't have one yet, unless |
// assigning a site is not necessary for this URL. In that case, the |
@@ -2875,7 +2927,7 @@ void WebContentsImpl::DidNavigate( |
// For now, keep track of each frame's URL in its FrameTreeNode. This lets |
// us estimate our process count for implementing OOP iframes. |
// TODO(creis): Remove this when we track which pages commit in each frame. |
- frame_tree_.SetFrameUrl(params.frame_id, params.url); |
+ frame_tree_.SetFrameUrl(frame_tree_node_id, params.url); |
// Send notification about committed provisional loads. This notification is |
// different from the NAV_ENTRY_COMMITTED notification which doesn't include |
@@ -2931,8 +2983,10 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
const PageState& page_state) { |
// Ensure that this state update comes from either the active RVH or one of |
// the swapped out RVHs. We don't expect to hear from any other RVHs. |
+ // TODO(creis): This should go through RenderFrameHost. |
DCHECK(rvh == GetRenderViewHost() || |
- GetRenderManager()->IsOnSwappedOutList(rvh)); |
+ GetRenderManager()->IsRVHOnSwappedOutList( |
+ static_cast<RenderViewHostImpl*>(rvh))); |
// We must be prepared to handle state updates for any page, these occur |
// when the user is scrolling and entering form data, as well as when we're |
@@ -3140,7 +3194,13 @@ void WebContentsImpl::RequestTransferURL( |
GetSiteInstance(), url)) |
dest_url = GURL(kAboutBlankURL); |
- OpenURLParams params(dest_url, referrer, source_frame_id, disposition, |
+ int64 frame_tree_node_id = -1; |
+ if (source_frame_id != -1) { |
+ frame_tree_node_id = static_cast<RenderViewHostImpl*>( |
+ GetRenderViewHost())->GetFrameTreeNodeID(source_frame_id); |
+ } |
+ OpenURLParams params(dest_url, referrer, source_frame_id, |
+ frame_tree_node_id, disposition, |
page_transition, true /* is_renderer_initiated */); |
if (redirect_chain.size() > 0) |
params.redirect_chain = redirect_chain; |
@@ -3363,8 +3423,8 @@ WebPreferences WebContentsImpl::GetWebkitPrefs() { |
int WebContentsImpl::CreateSwappedOutRenderView( |
SiteInstance* instance) { |
- return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE, |
- true, true); |
+ return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, |
+ true, true); |
} |
void WebContentsImpl::OnUserGesture() { |
@@ -3533,8 +3593,8 @@ int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { |
// Create a swapped out RenderView in the given SiteInstance if none exists, |
// setting its opener to the given route_id. Return the new view's route_id. |
- return GetRenderManager()->CreateRenderView(instance, opener_route_id, |
- true, true); |
+ return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, |
+ true, true); |
} |
NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
@@ -3625,10 +3685,6 @@ bool WebContentsImpl::IsHidden() { |
return capturer_count_ == 0 && !should_normally_be_visible_; |
} |
-RenderViewHostManager* WebContentsImpl::GetRenderManager() const { |
- return frame_tree_.root()->render_manager(); |
-} |
- |
RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
} |