Commit 76bfd958 authored by Aaron Colwell's avatar Aaron Colwell Committed by Commit Bot

Allow default SiteInstance to be completely disabled.

Refactors the code so that default SiteInstances won't be used anywhere
when the kProcessSharingWithDefaultSiteInstances feature is not enabled.
The old code would still allow default SiteInstances in some scenarios
even if the feature was off. This is surprising and more an artifact
of how the feature was incrementally developed instead of intended
behavior.

Bug: 1015882
Change-Id: I5c46487428d33d77f5706e0f7f3b7795251a1212
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877909
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Auto-Submit: Aaron Colwell <acolwell@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709098}
parent dd69e27d
...@@ -33,17 +33,6 @@ ...@@ -33,17 +33,6 @@
namespace content { namespace content {
namespace {
// Returns true if CreateForURL() and related functions should be allowed to
// return a default SiteInstance.
bool ShouldAllowDefaultSiteInstance() {
return base::FeatureList::IsEnabled(
features::kProcessSharingWithDefaultSiteInstances);
}
} // namespace
int32_t SiteInstanceImpl::next_site_instance_id_ = 1; int32_t SiteInstanceImpl::next_site_instance_id_ = 1;
// static // static
...@@ -103,7 +92,11 @@ scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForURL( ...@@ -103,7 +92,11 @@ scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForURL(
// This will create a new SiteInstance and BrowsingInstance. // This will create a new SiteInstance and BrowsingInstance.
scoped_refptr<BrowsingInstance> instance( scoped_refptr<BrowsingInstance> instance(
new BrowsingInstance(browser_context)); new BrowsingInstance(browser_context));
return instance->GetSiteInstanceForURL(url, ShouldAllowDefaultSiteInstance());
// Note: The |allow_default_instance| value used here MUST match the value
// used in DoesSiteForURLMatch().
return instance->GetSiteInstanceForURL(url,
true /* allow_default_instance */);
} }
// static // static
...@@ -349,10 +342,8 @@ void SiteInstanceImpl::SetSite(const GURL& url) { ...@@ -349,10 +342,8 @@ void SiteInstanceImpl::SetSite(const GURL& url) {
void SiteInstanceImpl::ConvertToDefaultOrSetSite(const GURL& url) { void SiteInstanceImpl::ConvertToDefaultOrSetSite(const GURL& url) {
DCHECK(!has_site_); DCHECK(!has_site_);
if (ShouldAllowDefaultSiteInstance() && if (browsing_instance_->TrySettingDefaultSiteInstance(this, url))
browsing_instance_->TrySettingDefaultSiteInstance(this, url)) {
return; return;
}
SetSite(url); SetSite(url);
} }
...@@ -645,7 +636,7 @@ bool SiteInstanceImpl::DoesSiteForURLMatch(const GURL& url) { ...@@ -645,7 +636,7 @@ bool SiteInstanceImpl::DoesSiteForURLMatch(const GURL& url) {
// used in CreateForURL(). // used in CreateForURL().
return site_ == GetSiteForURLInternal(GetIsolationContext(), url, return site_ == GetSiteForURLInternal(GetIsolationContext(), url,
true /* should_use_effective_urls */, true /* should_use_effective_urls */,
ShouldAllowDefaultSiteInstance()); true /* allow_default_site_url */);
} }
// static // static
...@@ -813,6 +804,12 @@ bool SiteInstanceImpl::CanBePlacedInDefaultSiteInstance( ...@@ -813,6 +804,12 @@ bool SiteInstanceImpl::CanBePlacedInDefaultSiteInstance(
const GURL& url, const GURL& url,
const GURL& site_url) { const GURL& site_url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!base::FeatureList::IsEnabled(
features::kProcessSharingWithDefaultSiteInstances)) {
return false;
}
// Exclude "chrome-guest:" URLs from the default SiteInstance to ensure that // Exclude "chrome-guest:" URLs from the default SiteInstance to ensure that
// guest specific process selection, process swapping, and storage partition // guest specific process selection, process swapping, and storage partition
// behavior is preserved. // behavior is preserved.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment