| 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, frame_entry.source_site_instance(), frame_entry.site_instance(), | 208 dest_url, frame_entry.source_site_instance(), frame_entry.site_instance(), |
| 208 entry.GetTransitionType(), | 209 entry.GetTransitionType(), |
| 209 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, | 210 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
| 210 entry.IsViewSourceMode(), entry.transferred_global_request_id(), | 211 entry.IsViewSourceMode(), entry.transferred_global_request_id(), |
| 211 entry.bindings()); | 212 entry.bindings(), is_reload); |
| 212 if (!dest_render_frame_host) | 213 if (!dest_render_frame_host) |
| 213 return nullptr; // We weren't able to create a pending render frame host. | 214 return nullptr; // We weren't able to create a pending render frame host. |
| 214 | 215 |
| 215 // If the current render_frame_host_ isn't live, we should create it so | 216 // If the current render_frame_host_ isn't live, we should create it so |
| 216 // that we don't show a sad tab while the dest_render_frame_host fetches | 217 // that we don't show a sad tab while the dest_render_frame_host fetches |
| 217 // its first page. (Bug 1145340) | 218 // its first page. (Bug 1145340) |
| 218 if (dest_render_frame_host != render_frame_host_.get() && | 219 if (dest_render_frame_host != render_frame_host_.get() && |
| 219 !render_frame_host_->IsRenderFrameLive()) { | 220 !render_frame_host_->IsRenderFrameLive()) { |
| 220 // Note: we don't call InitRenderView here because we are navigating away | 221 // Note: we don't call InitRenderView here because we are navigating away |
| 221 // soon anyway, and we don't have the NavigationEntry for this host. | 222 // soon anyway, and we don't have the NavigationEntry for this host. |
| (...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 } | 2163 } |
| 2163 | 2164 |
| 2164 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 2165 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
| 2165 const GURL& dest_url, | 2166 const GURL& dest_url, |
| 2166 SiteInstance* source_instance, | 2167 SiteInstance* source_instance, |
| 2167 SiteInstance* dest_instance, | 2168 SiteInstance* dest_instance, |
| 2168 ui::PageTransition transition, | 2169 ui::PageTransition transition, |
| 2169 bool dest_is_restore, | 2170 bool dest_is_restore, |
| 2170 bool dest_is_view_source_mode, | 2171 bool dest_is_view_source_mode, |
| 2171 const GlobalRequestID& transferred_request_id, | 2172 const GlobalRequestID& transferred_request_id, |
| 2172 int bindings) { | 2173 int bindings, |
| 2174 bool is_reload) { |
| 2173 if (!frame_tree_node_->IsMainFrame() && | 2175 if (!frame_tree_node_->IsMainFrame() && |
| 2174 !CanSubframeSwapProcess(dest_url, source_instance, dest_instance)) { | 2176 !CanSubframeSwapProcess(dest_url, source_instance, dest_instance)) { |
| 2175 // Note: Do not add code here to determine whether the subframe should swap | 2177 // Note: Do not add code here to determine whether the subframe should swap |
| 2176 // or not. Add it to CanSubframeSwapProcess instead. | 2178 // or not. Add it to CanSubframeSwapProcess instead. |
| 2177 return render_frame_host_.get(); | 2179 return render_frame_host_.get(); |
| 2178 } | 2180 } |
| 2179 | 2181 |
| 2180 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2182 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 2181 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2183 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
| 2182 dest_url, source_instance, dest_instance, nullptr, transition, | 2184 dest_url, source_instance, dest_instance, nullptr, transition, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 // a timeout). If the handler returns false, we'll have to cancel the | 2247 // a timeout). If the handler returns false, we'll have to cancel the |
| 2246 // request. | 2248 // request. |
| 2247 // | 2249 // |
| 2248 // Also make sure the old RenderFrame stops, in case a load is in | 2250 // Also make sure the old RenderFrame stops, in case a load is in |
| 2249 // progress. (We don't want to do this for transfers, since it will | 2251 // progress. (We don't want to do this for transfers, since it will |
| 2250 // interrupt the transfer with an unexpected DidStopLoading.) | 2252 // interrupt the transfer with an unexpected DidStopLoading.) |
| 2251 render_frame_host_->Send(new FrameMsg_Stop( | 2253 render_frame_host_->Send(new FrameMsg_Stop( |
| 2252 render_frame_host_->GetRoutingID())); | 2254 render_frame_host_->GetRoutingID())); |
| 2253 pending_render_frame_host_->SetNavigationsSuspended(true, | 2255 pending_render_frame_host_->SetNavigationsSuspended(true, |
| 2254 base::TimeTicks()); | 2256 base::TimeTicks()); |
| 2255 render_frame_host_->DispatchBeforeUnload(true); | 2257 render_frame_host_->DispatchBeforeUnload(true, is_reload); |
| 2256 } | 2258 } |
| 2257 | 2259 |
| 2258 return pending_render_frame_host_.get(); | 2260 return pending_render_frame_host_.get(); |
| 2259 } | 2261 } |
| 2260 | 2262 |
| 2261 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 2263 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
| 2262 | 2264 |
| 2263 // It's possible to swap out the current RFH and then decide to navigate in it | 2265 // It's possible to swap out the current RFH and then decide to navigate in it |
| 2264 // anyway (e.g., a cross-process navigation that redirects back to the | 2266 // anyway (e.g., a cross-process navigation that redirects back to the |
| 2265 // original site). In that case, we have a proxy for the current RFH but | 2267 // original site). In that case, we have a proxy for the current RFH but |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 resolved_url)) { | 2599 resolved_url)) { |
| 2598 DCHECK(!dest_instance || | 2600 DCHECK(!dest_instance || |
| 2599 dest_instance == render_frame_host_->GetSiteInstance()); | 2601 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2600 return false; | 2602 return false; |
| 2601 } | 2603 } |
| 2602 | 2604 |
| 2603 return true; | 2605 return true; |
| 2604 } | 2606 } |
| 2605 | 2607 |
| 2606 } // namespace content | 2608 } // namespace content |
| OLD | NEW |