| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 FrameTreeNode::GloballyFindByID( | 192 FrameTreeNode::GloballyFindByID( |
| 193 delegate_->GetOuterDelegateFrameTreeNodeId()); | 193 delegate_->GetOuterDelegateFrameTreeNodeId()); |
| 194 DCHECK(outer_delegate_frame_tree_node->parent()); | 194 DCHECK(outer_delegate_frame_tree_node->parent()); |
| 195 outer_delegate_frame_tree_node->frame_tree()->RemoveFrame( | 195 outer_delegate_frame_tree_node->frame_tree()->RemoveFrame( |
| 196 outer_delegate_frame_tree_node); | 196 outer_delegate_frame_tree_node); |
| 197 } | 197 } |
| 198 | 198 |
| 199 RenderFrameHostImpl* RenderFrameHostManager::Navigate( | 199 RenderFrameHostImpl* RenderFrameHostManager::Navigate( |
| 200 const GURL& dest_url, | 200 const GURL& dest_url, |
| 201 const FrameNavigationEntry& frame_entry, | 201 const FrameNavigationEntry& frame_entry, |
| 202 const NavigationEntryImpl& entry) { | 202 const NavigationEntryImpl& entry, |
| 203 bool is_reload) { |
| 203 TRACE_EVENT1("navigation", "RenderFrameHostManager:Navigate", | 204 TRACE_EVENT1("navigation", "RenderFrameHostManager:Navigate", |
| 204 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 205 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 205 // Create a pending RenderFrameHost to use for the navigation. | 206 // Create a pending RenderFrameHost to use for the navigation. |
| 206 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate( | 207 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate( |
| 207 dest_url, | 208 dest_url, |
| 208 // TODO(creis): Move source_site_instance to FNE. | 209 // TODO(creis): Move source_site_instance to FNE. |
| 209 entry.source_site_instance(), frame_entry.site_instance(), | 210 entry.source_site_instance(), frame_entry.site_instance(), |
| 210 entry.GetTransitionType(), | 211 entry.GetTransitionType(), |
| 211 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, | 212 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
| 212 entry.IsViewSourceMode(), entry.transferred_global_request_id(), | 213 entry.IsViewSourceMode(), entry.transferred_global_request_id(), |
| 213 entry.bindings()); | 214 entry.bindings(), is_reload); |
| 214 if (!dest_render_frame_host) | 215 if (!dest_render_frame_host) |
| 215 return nullptr; // We weren't able to create a pending render frame host. | 216 return nullptr; // We weren't able to create a pending render frame host. |
| 216 | 217 |
| 217 // If the current render_frame_host_ isn't live, we should create it so | 218 // If the current render_frame_host_ isn't live, we should create it so |
| 218 // that we don't show a sad tab while the dest_render_frame_host fetches | 219 // that we don't show a sad tab while the dest_render_frame_host fetches |
| 219 // its first page. (Bug 1145340) | 220 // its first page. (Bug 1145340) |
| 220 if (dest_render_frame_host != render_frame_host_.get() && | 221 if (dest_render_frame_host != render_frame_host_.get() && |
| 221 !render_frame_host_->IsRenderFrameLive()) { | 222 !render_frame_host_->IsRenderFrameLive()) { |
| 222 // Note: we don't call InitRenderView here because we are navigating away | 223 // Note: we don't call InitRenderView here because we are navigating away |
| 223 // soon anyway, and we don't have the NavigationEntry for this host. | 224 // soon anyway, and we don't have the NavigationEntry for this host. |
| (...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 } | 2103 } |
| 2103 | 2104 |
| 2104 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 2105 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
| 2105 const GURL& dest_url, | 2106 const GURL& dest_url, |
| 2106 SiteInstance* source_instance, | 2107 SiteInstance* source_instance, |
| 2107 SiteInstance* dest_instance, | 2108 SiteInstance* dest_instance, |
| 2108 ui::PageTransition transition, | 2109 ui::PageTransition transition, |
| 2109 bool dest_is_restore, | 2110 bool dest_is_restore, |
| 2110 bool dest_is_view_source_mode, | 2111 bool dest_is_view_source_mode, |
| 2111 const GlobalRequestID& transferred_request_id, | 2112 const GlobalRequestID& transferred_request_id, |
| 2112 int bindings) { | 2113 int bindings, |
| 2114 bool is_reload) { |
| 2113 if (!frame_tree_node_->IsMainFrame() && | 2115 if (!frame_tree_node_->IsMainFrame() && |
| 2114 !CanSubframeSwapProcess(dest_url, source_instance, dest_instance)) { | 2116 !CanSubframeSwapProcess(dest_url, source_instance, dest_instance)) { |
| 2115 // Note: Do not add code here to determine whether the subframe should swap | 2117 // Note: Do not add code here to determine whether the subframe should swap |
| 2116 // or not. Add it to CanSubframeSwapProcess instead. | 2118 // or not. Add it to CanSubframeSwapProcess instead. |
| 2117 return render_frame_host_.get(); | 2119 return render_frame_host_.get(); |
| 2118 } | 2120 } |
| 2119 | 2121 |
| 2120 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2122 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 2121 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2123 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
| 2122 dest_url, source_instance, dest_instance, nullptr, transition, | 2124 dest_url, source_instance, dest_instance, nullptr, transition, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 // a timeout). If the handler returns false, we'll have to cancel the | 2187 // a timeout). If the handler returns false, we'll have to cancel the |
| 2186 // request. | 2188 // request. |
| 2187 // | 2189 // |
| 2188 // Also make sure the old render view stops, in case a load is in | 2190 // Also make sure the old render view stops, in case a load is in |
| 2189 // progress. (We don't want to do this for transfers, since it will | 2191 // progress. (We don't want to do this for transfers, since it will |
| 2190 // interrupt the transfer with an unexpected DidStopLoading.) | 2192 // interrupt the transfer with an unexpected DidStopLoading.) |
| 2191 render_frame_host_->Send(new FrameMsg_Stop( | 2193 render_frame_host_->Send(new FrameMsg_Stop( |
| 2192 render_frame_host_->GetRoutingID())); | 2194 render_frame_host_->GetRoutingID())); |
| 2193 pending_render_frame_host_->SetNavigationsSuspended(true, | 2195 pending_render_frame_host_->SetNavigationsSuspended(true, |
| 2194 base::TimeTicks()); | 2196 base::TimeTicks()); |
| 2195 render_frame_host_->DispatchBeforeUnload(true); | 2197 render_frame_host_->DispatchBeforeUnload(true, is_reload); |
| 2196 } | 2198 } |
| 2197 | 2199 |
| 2198 return pending_render_frame_host_.get(); | 2200 return pending_render_frame_host_.get(); |
| 2199 } | 2201 } |
| 2200 | 2202 |
| 2201 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 2203 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
| 2202 | 2204 |
| 2203 // It's possible to swap out the current RFH and then decide to navigate in it | 2205 // It's possible to swap out the current RFH and then decide to navigate in it |
| 2204 // anyway (e.g., a cross-process navigation that redirects back to the | 2206 // anyway (e.g., a cross-process navigation that redirects back to the |
| 2205 // original site). In that case, we have a proxy for the current RFH but | 2207 // original site). In that case, we have a proxy for the current RFH but |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 resolved_url)) { | 2549 resolved_url)) { |
| 2548 DCHECK(!dest_instance || | 2550 DCHECK(!dest_instance || |
| 2549 dest_instance == render_frame_host_->GetSiteInstance()); | 2551 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2550 return false; | 2552 return false; |
| 2551 } | 2553 } |
| 2552 | 2554 |
| 2553 return true; | 2555 return true; |
| 2554 } | 2556 } |
| 2555 | 2557 |
| 2556 } // namespace content | 2558 } // namespace content |
| OLD | NEW |