Replace SiteInstance::IsSameWebSite() with a new non-static method.
https://chromium-review.googlesource.com/c/chromium/src/+/1352856
This commit is contained in:
parent
e4cfc52c29
commit
61c46c6313
1 changed files with 12 additions and 15 deletions
|
@ -119,15 +119,14 @@ namespace {
|
||||||
bool g_suppress_renderer_process_restart = false;
|
bool g_suppress_renderer_process_restart = false;
|
||||||
|
|
||||||
bool IsSameWebSite(content::BrowserContext* browser_context,
|
bool IsSameWebSite(content::BrowserContext* browser_context,
|
||||||
const GURL& src_url,
|
content::SiteInstance* site_instance,
|
||||||
const GURL& dest_url) {
|
const GURL& dest_url) {
|
||||||
return content::SiteInstance::IsSameWebSite(browser_context, src_url,
|
return site_instance->IsSameSiteWithURL(dest_url) ||
|
||||||
dest_url) ||
|
// `IsSameSiteWithURL` doesn't seem to work for some URIs such as
|
||||||
// `IsSameWebSite` doesn't seem to work for some URIs such as `file:`,
|
// `file:`, handle these scenarios by comparing only the site as
|
||||||
// handle these scenarios by comparing only the site as defined by
|
// defined by `GetSiteForURL`.
|
||||||
// `GetSiteForURL`.
|
(content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
|
||||||
content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
|
site_instance->GetSiteURL());
|
||||||
src_url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserClient* g_browser_client = nullptr;
|
AtomBrowserClient* g_browser_client = nullptr;
|
||||||
|
@ -226,8 +225,7 @@ bool AtomBrowserClient::ShouldForceNewSiteInstance(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new a SiteInstance if navigating to a different site.
|
// Create new a SiteInstance if navigating to a different site.
|
||||||
auto src_url = current_instance->GetSiteURL();
|
return !IsSameWebSite(browser_context, current_instance, url);
|
||||||
return !IsSameWebSite(browser_context, src_url, url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
||||||
|
@ -238,13 +236,12 @@ bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
|
||||||
bool has_response_started) const {
|
bool has_response_started) const {
|
||||||
bool navigation_was_redirected = false;
|
bool navigation_was_redirected = false;
|
||||||
if (has_response_started) {
|
if (has_response_started) {
|
||||||
navigation_was_redirected = !IsSameWebSite(
|
navigation_was_redirected =
|
||||||
browser_context, current_instance->GetSiteURL(), dest_url);
|
!IsSameWebSite(browser_context, current_instance, dest_url);
|
||||||
} else {
|
} else {
|
||||||
navigation_was_redirected =
|
navigation_was_redirected =
|
||||||
speculative_instance &&
|
speculative_instance &&
|
||||||
!IsSameWebSite(browser_context, speculative_instance->GetSiteURL(),
|
!IsSameWebSite(browser_context, speculative_instance, dest_url);
|
||||||
dest_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return navigation_was_redirected;
|
return navigation_was_redirected;
|
||||||
|
@ -308,7 +305,7 @@ content::SiteInstance* AtomBrowserClient::GetSiteInstanceFromAffinity(
|
||||||
auto iter = site_per_affinities_.find(affinity);
|
auto iter = site_per_affinities_.find(affinity);
|
||||||
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
|
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
|
||||||
if (iter != site_per_affinities_.end() &&
|
if (iter != site_per_affinities_.end() &&
|
||||||
IsSameWebSite(browser_context, iter->second->GetSiteURL(), dest_site)) {
|
IsSameWebSite(browser_context, iter->second, dest_site)) {
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue