Commit e90a0c4a authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Fix the timing of activation of Site Isolation field trials.

Bug: 825325
Change-Id: I17d46070a5fc5a060b0881a2ba58f52ffce07f1d
Reviewed-on: https://chromium-review.googlesource.com/978674
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545640}
parent de6d8810
...@@ -33,15 +33,27 @@ void CreateCompositeClientIfNeeded(content::WebContents* web_contents) { ...@@ -33,15 +33,27 @@ void CreateCompositeClientIfNeeded(content::WebContents* web_contents) {
// where OOPIF is used such as isolate-extensions, but should be good for // where OOPIF is used such as isolate-extensions, but should be good for
// feature testing purpose. Eventually, we will remove this check and use pdf // feature testing purpose. Eventually, we will remove this check and use pdf
// compositor service by default for printing. // compositor service by default for printing.
bool is_site_isolation_enabled;
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSitePerProcess) || switches::kSitePerProcess) ||
base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kIsolateOrigins) || switches::kIsolateOrigins)) {
((base::FeatureList::IsEnabled(::features::kSitePerProcess) || is_site_isolation_enabled = true;
base::FeatureList::IsEnabled(::features::kIsolateOrigins)) && } else if (base::CommandLine::ForCurrentProcess()->HasSwitch(
!base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableSiteIsolationTrials)) {
switches::kDisableSiteIsolationTrials)) || is_site_isolation_enabled = false;
base::FeatureList::IsEnabled(::features::kTopDocumentIsolation) || } else {
// The features need to be checked last, because checking a feature
// activates the field trial and assigns the client either to a control or
// an experiment group.
is_site_isolation_enabled =
base::FeatureList::IsEnabled(::features::kSitePerProcess) ||
base::FeatureList::IsEnabled(::features::kIsolateOrigins) ||
base::FeatureList::IsEnabled(::features::kTopDocumentIsolation);
}
if (is_site_isolation_enabled ||
base::FeatureList::IsEnabled( base::FeatureList::IsEnabled(
printing::features::kUsePdfCompositorServiceForPrint)) { printing::features::kUsePdfCompositorServiceForPrint)) {
PrintCompositeClient::CreateForWebContents(web_contents); PrintCompositeClient::CreateForWebContents(web_contents);
......
...@@ -26,19 +26,29 @@ namespace content { ...@@ -26,19 +26,29 @@ namespace content {
// static // static
bool SiteIsolationPolicy::UseDedicatedProcessesForAllSites() { bool SiteIsolationPolicy::UseDedicatedProcessesForAllSites() {
return base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSitePerProcess) || switches::kSitePerProcess)) {
(base::FeatureList::IsEnabled(features::kSitePerProcess) && return true;
!base::CommandLine::ForCurrentProcess()->HasSwitch( }
switches::kDisableSiteIsolationTrials));
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableSiteIsolationTrials)) {
return false;
}
// The feature needs to be checked last, because checking the feature
// activates the field trial and assigns the client either to a control or an
// experiment group.
return base::FeatureList::IsEnabled(features::kSitePerProcess);
} }
// static // static
SiteIsolationPolicy::CrossSiteDocumentBlockingEnabledState SiteIsolationPolicy::CrossSiteDocumentBlockingEnabledState
SiteIsolationPolicy::IsCrossSiteDocumentBlockingEnabled() { SiteIsolationPolicy::IsCrossSiteDocumentBlockingEnabled() {
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
::features::kCrossSiteDocumentBlockingAlways)) ::features::kCrossSiteDocumentBlockingAlways)) {
return XSDB_ENABLED_UNCONDITIONALLY; return XSDB_ENABLED_UNCONDITIONALLY;
}
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
::features::kCrossSiteDocumentBlockingIfIsolating)) { ::features::kCrossSiteDocumentBlockingIfIsolating)) {
...@@ -54,16 +64,33 @@ bool SiteIsolationPolicy::IsTopDocumentIsolationEnabled() { ...@@ -54,16 +64,33 @@ bool SiteIsolationPolicy::IsTopDocumentIsolationEnabled() {
if (UseDedicatedProcessesForAllSites()) if (UseDedicatedProcessesForAllSites())
return false; return false;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableSiteIsolationTrials)) {
return false;
}
// The feature needs to be checked last, because checking the feature
// activates the field trial and assigns the client either to a control or an
// experiment group.
return base::FeatureList::IsEnabled(::features::kTopDocumentIsolation); return base::FeatureList::IsEnabled(::features::kTopDocumentIsolation);
} }
// static // static
bool SiteIsolationPolicy::AreIsolatedOriginsEnabled() { bool SiteIsolationPolicy::AreIsolatedOriginsEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kIsolateOrigins) || switches::kIsolateOrigins)) {
(base::FeatureList::IsEnabled(features::kIsolateOrigins) && return true;
!base::CommandLine::ForCurrentProcess()->HasSwitch( }
switches::kDisableSiteIsolationTrials));
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableSiteIsolationTrials)) {
return false;
}
// The feature needs to be checked last, because checking the feature
// activates the field trial and assigns the client either to a control or an
// experiment group.
return base::FeatureList::IsEnabled(features::kIsolateOrigins);
} }
// static // static
...@@ -80,15 +107,20 @@ SiteIsolationPolicy::GetIsolatedOriginsFromEnvironment() { ...@@ -80,15 +107,20 @@ SiteIsolationPolicy::GetIsolatedOriginsFromEnvironment() {
return cmdline_origins; return cmdline_origins;
} }
if (base::FeatureList::IsEnabled(features::kIsolateOrigins) && if (base::CommandLine::ForCurrentProcess()->HasSwitch(
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableSiteIsolationTrials)) { switches::kDisableSiteIsolationTrials)) {
return std::vector<url::Origin>();
}
// The feature needs to be checked last, because checking the feature
// activates the field trial and assigns the client either to a control or an
// experiment group.
if (base::FeatureList::IsEnabled(features::kIsolateOrigins)) {
std::string field_trial_arg = base::GetFieldTrialParamValueByFeature( std::string field_trial_arg = base::GetFieldTrialParamValueByFeature(
features::kIsolateOrigins, features::kIsolateOrigins,
features::kIsolateOriginsFieldTrialParamName); features::kIsolateOriginsFieldTrialParamName);
return ParseIsolatedOrigins(field_trial_arg); return ParseIsolatedOrigins(field_trial_arg);
} }
return std::vector<url::Origin>(); return std::vector<url::Origin>();
} }
......
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