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

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

Issue 1960703003: Take session history SiteInstance into account for unique origin navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed ordering. Created 4 years, 7 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
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 1103
1104 scoped_refptr<SiteInstance> 1104 scoped_refptr<SiteInstance>
1105 RenderFrameHostManager::GetSiteInstanceForNavigation( 1105 RenderFrameHostManager::GetSiteInstanceForNavigation(
1106 const GURL& dest_url, 1106 const GURL& dest_url,
1107 SiteInstance* source_instance, 1107 SiteInstance* source_instance,
1108 SiteInstance* dest_instance, 1108 SiteInstance* dest_instance,
1109 SiteInstance* candidate_instance, 1109 SiteInstance* candidate_instance,
1110 ui::PageTransition transition, 1110 ui::PageTransition transition,
1111 bool dest_is_restore, 1111 bool dest_is_restore,
1112 bool dest_is_view_source_mode) { 1112 bool dest_is_view_source_mode) {
1113 // On renderer-initiated navigations, when the frame initiating the navigation
1114 // and the frame being navigated differ, |source_instance| is set to the
1115 // SiteInstance of the initiating frame. |dest_instance| is present on session
1116 // history navigations. The two cannot be set simultaneously.
1117 DCHECK(!source_instance || !dest_instance);
1118
1113 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 1119 SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
1114 1120
1115 // We do not currently swap processes for navigations in webview tag guests. 1121 // We do not currently swap processes for navigations in webview tag guests.
1116 if (current_instance->GetSiteURL().SchemeIs(kGuestScheme)) 1122 if (current_instance->GetSiteURL().SchemeIs(kGuestScheme))
1117 return current_instance; 1123 return current_instance;
1118 1124
1119 // Determine if we need a new BrowsingInstance for this entry. If true, this 1125 // Determine if we need a new BrowsingInstance for this entry. If true, this
1120 // implies that it will get a new SiteInstance (and likely process), and that 1126 // implies that it will get a new SiteInstance (and likely process), and that
1121 // other tabs in the current BrowsingInstance will be unable to script it. 1127 // other tabs in the current BrowsingInstance will be unable to script it.
1122 // This is used for cases that require a process swap even in the 1128 // This is used for cases that require a process swap even in the
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 } 2521 }
2516 2522
2517 msg->set_routing_id(render_frame_host_->GetRoutingID()); 2523 msg->set_routing_id(render_frame_host_->GetRoutingID());
2518 render_frame_host_->Send(msg); 2524 render_frame_host_->Send(msg);
2519 } 2525 }
2520 2526
2521 bool RenderFrameHostManager::CanSubframeSwapProcess( 2527 bool RenderFrameHostManager::CanSubframeSwapProcess(
2522 const GURL& dest_url, 2528 const GURL& dest_url,
2523 SiteInstance* source_instance, 2529 SiteInstance* source_instance,
2524 SiteInstance* dest_instance) { 2530 SiteInstance* dest_instance) {
2531 // On renderer-initiated navigations, when the frame initiating the navigation
2532 // and the frame being navigated differ, |source_instance| is set to the
2533 // SiteInstance of the initiating frame. |dest_instance| is present on session
2534 // history navigations. The two cannot be set simultaneously.
2535 DCHECK(!source_instance || !dest_instance);
2536
2525 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can 2537 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can
2526 // get here in tests for subframes (e.g., NavigateFrameToURL). 2538 // get here in tests for subframes (e.g., NavigateFrameToURL).
2527 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) 2539 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible())
2528 return false; 2540 return false;
2529 2541
2530 // If dest_url is a unique origin like about:blank, then the need for a swap 2542 // If dest_url is a unique origin like about:blank, then the need for a swap
2531 // is determined by the source_instance. 2543 // is determined by the source_instance or dest_instance.
2532 GURL resolved_url = dest_url; 2544 GURL resolved_url = dest_url;
2533 if (url::Origin(resolved_url).unique()) { 2545 if (url::Origin(resolved_url).unique()) {
2534 // If there is no source_instance for a unique origin, then we should avoid 2546 if (source_instance) {
2535 // a process swap. 2547 resolved_url = source_instance->GetSiteURL();
2536 if (!source_instance) 2548 } else if (dest_instance) {
2549 resolved_url = dest_instance->GetSiteURL();
2550 } else {
2551 // If there is no SiteInstance this unique origin can be associated with,
2552 // then we should avoid a process swap.
2537 return false; 2553 return false;
2538 2554 }
2539 // Use source_instance to determine if a swap is needed.
2540 resolved_url = source_instance->GetSiteURL();
2541 } 2555 }
2542 2556
2543 // If we are in an OOPIF mode that only applies to some sites, only swap if 2557 // If we are in an OOPIF mode that only applies to some sites, only swap if
2544 // the policy determines that a transfer would have been needed. We can get 2558 // the policy determines that a transfer would have been needed. We can get
2545 // here for session restore. 2559 // here for session restore.
2546 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(), 2560 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(),
2547 resolved_url)) { 2561 resolved_url)) {
2548 DCHECK(!dest_instance || 2562 DCHECK(!dest_instance ||
2549 dest_instance == render_frame_host_->GetSiteInstance()); 2563 dest_instance == render_frame_host_->GetSiteInstance());
2550 return false; 2564 return false;
2551 } 2565 }
2552 2566
2553 return true; 2567 return true;
2554 } 2568 }
2555 2569
2556 } // namespace content 2570 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698