Index: content/browser/frame_host/render_frame_host_manager.cc |
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc |
index b40cc2b39218a103adb484a3a35fc33e66e78b57..1d03513ab46bb0f40495a34ad20524e1d56080b2 100644 |
--- a/content/browser/frame_host/render_frame_host_manager.cc |
+++ b/content/browser/frame_host/render_frame_host_manager.cc |
@@ -646,13 +646,13 @@ bool RenderFrameHostManager::ShouldTransitionCrossSite() { |
bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
const NavigationEntry* current_entry, |
- const NavigationEntryImpl* new_entry) const { |
- DCHECK(new_entry); |
- |
+ SiteInstance* new_site_instance, |
+ const GURL& new_url, |
+ bool new_is_view_source_mode) const { |
// If new_entry already has a SiteInstance, assume it is correct. We only |
// need to force a swap if it is in a different BrowsingInstance. |
- if (new_entry->site_instance()) { |
- return !new_entry->site_instance()->IsRelatedSiteInstance( |
+ if (new_site_instance) { |
+ return !new_site_instance->IsRelatedSiteInstance( |
render_frame_host_->GetSiteInstance()); |
} |
@@ -670,8 +670,6 @@ bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
SiteInstanceImpl::GetEffectiveURL(browser_context, |
current_entry->GetURL()) : |
render_frame_host_->GetSiteInstance()->GetSiteURL(); |
- const GURL& new_url = SiteInstanceImpl::GetEffectiveURL(browser_context, |
- new_entry->GetURL()); |
// Don't force a new BrowsingInstance for debug URLs that are handled in the |
// renderer process, like javascript: or chrome://crash. |
@@ -709,7 +707,7 @@ bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
// "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat |
// it as a new navigation). So require a BrowsingInstance switch. |
if (current_entry && |
- current_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) |
+ current_entry->IsViewSourceMode() != new_is_view_source_mode) |
return true; |
return false; |
@@ -727,24 +725,26 @@ bool RenderFrameHostManager::ShouldReuseWebUI( |
controller.GetBrowserContext(), new_entry->GetURL())); |
} |
-SiteInstance* RenderFrameHostManager::GetSiteInstanceForEntry( |
- const NavigationEntryImpl& entry, |
+SiteInstance* RenderFrameHostManager::GetSiteInstanceForURL( |
+ const GURL& dest_url, |
+ SiteInstance* navigation_instance, |
SiteInstance* current_instance, |
- bool force_browsing_instance_swap) { |
- // Determine which SiteInstance to use for navigating to |entry|. |
- const GURL& dest_url = entry.GetURL(); |
+ PageTransition page_transition, |
+ NavigationEntryImpl::RestoreType restore_type, |
+ bool force_browsing_instance_swap, |
+ bool is_view_source_mode) { |
NavigationControllerImpl& controller = |
delegate_->GetControllerForRenderManager(); |
BrowserContext* browser_context = controller.GetBrowserContext(); |
// If the entry has an instance already we should use it. |
- if (entry.site_instance()) { |
+ if (navigation_instance) { |
// If we are forcing a swap, this should be in a different BrowsingInstance. |
if (force_browsing_instance_swap) { |
- CHECK(!entry.site_instance()->IsRelatedSiteInstance( |
+ CHECK(!navigation_instance->IsRelatedSiteInstance( |
render_frame_host_->GetSiteInstance())); |
} |
- return entry.site_instance(); |
+ return navigation_instance; |
} |
// If a swap is required, we need to force the SiteInstance AND |
@@ -763,8 +763,7 @@ SiteInstance* RenderFrameHostManager::GetSiteInstanceForEntry( |
// RenderViews in response to a link click. |
// |
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && |
- PageTransitionCoreTypeIs(entry.GetTransitionType(), |
- PAGE_TRANSITION_GENERATED)) { |
+ PageTransitionCoreTypeIs(page_transition, PAGE_TRANSITION_GENERATED)) { |
return current_instance; |
} |
@@ -806,7 +805,7 @@ SiteInstance* RenderFrameHostManager::GetSiteInstanceForEntry( |
// TODO(nasko): This is the same condition as later in the function. This |
// should be taken into account when refactoring this method as part of |
// http://crbug.com/123007. |
- if (entry.IsViewSourceMode()) |
+ if (is_view_source_mode) |
return SiteInstance::CreateForURL(browser_context, dest_url); |
// If we are navigating from a blank SiteInstance to a WebUI, make sure we |
@@ -830,7 +829,7 @@ SiteInstance* RenderFrameHostManager::GetSiteInstanceForEntry( |
// renderers created for particular chrome urls (e.g. the chrome-native:// |
// scheme) can be reused for subsequent navigations in the same WebContents. |
// See http://crbug.com/386542. |
- if (entry.restore_type() != NavigationEntryImpl::RESTORE_NONE && |
+ if (restore_type != NavigationEntryImpl::RESTORE_NONE && |
GetContentClient()->browser()->ShouldAssignSiteForURL(dest_url)) { |
current_site_instance->SetSite(dest_url); |
} |
@@ -873,7 +872,7 @@ SiteInstance* RenderFrameHostManager::GetSiteInstanceForEntry( |
// TODO(creis): Refactor this method so this duplicated code isn't needed. |
// See http://crbug.com/123007. |
if (current_entry && |
- current_entry->IsViewSourceMode() != entry.IsViewSourceMode() && |
+ current_entry->IsViewSourceMode() != is_view_source_mode && |
!IsRendererDebugURL(dest_url)) { |
return SiteInstance::CreateForURL(browser_context, dest_url); |
} |
@@ -1332,10 +1331,23 @@ RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
// process-per-tab model, such as WebUI pages. |
const NavigationEntry* current_entry = |
delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
+ BrowserContext* browser_context = |
+ delegate_->GetControllerForRenderManager().GetBrowserContext(); |
bool force_swap = !is_guest_scheme && |
- ShouldSwapBrowsingInstancesForNavigation(current_entry, &entry); |
+ ShouldSwapBrowsingInstancesForNavigation( |
+ current_entry, |
+ entry.site_instance(), |
+ SiteInstanceImpl::GetEffectiveURL(browser_context, entry.GetURL()), |
+ entry.IsViewSourceMode()); |
if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) |
Charlie Reis
2014/08/14 06:28:08
This needs braces if the body is more than one lin
clamy
2014/08/14 10:02:59
Done.
|
- new_instance = GetSiteInstanceForEntry(entry, current_instance, force_swap); |
+ new_instance = GetSiteInstanceForURL( |
+ entry.GetURL(), |
+ entry.site_instance(), |
+ current_instance, |
+ entry.GetTransitionType(), |
+ entry.restore_type(), |
+ force_swap, |
+ entry.IsViewSourceMode()); |
// If force_swap is true, we must use a different SiteInstance. If we didn't, |
// we would have two RenderFrameHosts in the same SiteInstance and the same |