| 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 <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 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 | 2312 |
| 2313 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 2313 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
| 2314 const GURL& dest_url, | 2314 const GURL& dest_url, |
| 2315 SiteInstance* source_instance, | 2315 SiteInstance* source_instance, |
| 2316 SiteInstance* dest_instance, | 2316 SiteInstance* dest_instance, |
| 2317 ui::PageTransition transition, | 2317 ui::PageTransition transition, |
| 2318 bool dest_is_restore, | 2318 bool dest_is_restore, |
| 2319 bool dest_is_view_source_mode, | 2319 bool dest_is_view_source_mode, |
| 2320 const GlobalRequestID& transferred_request_id, | 2320 const GlobalRequestID& transferred_request_id, |
| 2321 int bindings) { | 2321 int bindings) { |
| 2322 // Don't swap for subframes unless we are in --site-per-process. We can get | 2322 if (!frame_tree_node_->IsMainFrame()) { |
| 2323 // here in tests for subframes (e.g., NavigateFrameToURL). | 2323 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can |
| 2324 if (!frame_tree_node_->IsMainFrame() && | 2324 // get here in tests for subframes (e.g., NavigateFrameToURL). |
| 2325 !SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | 2325 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 2326 return render_frame_host_.get(); | 2326 return render_frame_host_.get(); |
| 2327 |
| 2328 // If dest_url is a unique origin like about:blank, then the need for a swap |
| 2329 // is determined by the source_instance. |
| 2330 GURL resolved_url = dest_url; |
| 2331 if (url::Origin(resolved_url).unique()) { |
| 2332 // If there is no source_instance for a unique origin, then we should |
| 2333 // avoid a process swap. |
| 2334 if (!source_instance) |
| 2335 return render_frame_host_.get(); |
| 2336 |
| 2337 // Use source_instance to determine if a swap is needed. |
| 2338 resolved_url = source_instance->GetSiteURL(); |
| 2339 } |
| 2340 |
| 2341 // If we are in an OOPIF mode that only applies to some sites, only swap if |
| 2342 // the policy determines that a transfer would have been needed. We can get |
| 2343 // here for session restore. |
| 2344 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(), |
| 2345 resolved_url)) { |
| 2346 DCHECK(!dest_instance || |
| 2347 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2348 return render_frame_host_.get(); |
| 2349 } |
| 2327 } | 2350 } |
| 2328 | 2351 |
| 2329 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2352 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 2330 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2353 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
| 2331 dest_url, source_instance, dest_instance, nullptr, transition, | 2354 dest_url, source_instance, dest_instance, nullptr, transition, |
| 2332 dest_is_restore, dest_is_view_source_mode); | 2355 dest_is_restore, dest_is_view_source_mode); |
| 2333 | 2356 |
| 2334 // If we are currently navigating cross-process to a pending RFH for a | 2357 // If we are currently navigating cross-process to a pending RFH for a |
| 2335 // different SiteInstance, we want to get back to normal and then navigate as | 2358 // different SiteInstance, we want to get back to normal and then navigate as |
| 2336 // usual. We will reuse the pending RFH below if it matches the destination | 2359 // usual. We will reuse the pending RFH below if it matches the destination |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2660 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2683 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2661 if (!frame_tree_node_->opener()) | 2684 if (!frame_tree_node_->opener()) |
| 2662 return MSG_ROUTING_NONE; | 2685 return MSG_ROUTING_NONE; |
| 2663 | 2686 |
| 2664 return frame_tree_node_->opener() | 2687 return frame_tree_node_->opener() |
| 2665 ->render_manager() | 2688 ->render_manager() |
| 2666 ->GetRoutingIdForSiteInstance(instance); | 2689 ->GetRoutingIdForSiteInstance(instance); |
| 2667 } | 2690 } |
| 2668 | 2691 |
| 2669 } // namespace content | 2692 } // namespace content |
| OLD | NEW |