Commit 0dab7330 authored by Takashi Toyoshima's avatar Takashi Toyoshima Committed by Commit Bot

OOR-CORS: Fix renderers to check the base::Feature too

In the previous patch, renderers are changed to take a command line
flag for deciding OutOfBlinkCors mode. But since the flag is passed
by chrome/ code, content_browsertests run without the required flag
even when the OOR-CORS is enabled. This potentially affects other
chromium content embedders and may cause confusing situations.
To solve this problem, I changed to use the combination of a flag
and the base::Feature. Fortunately, there are only two call sites
in the renderer processes, and it won't be so bothering.

This fix failed content_browsertests at linux-oor-cors-rel bot.

Bug: 1015289
Change-Id: I8835b0c328e23656114b4dfcb87286f6cd1d5455
TBR: sky@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866372
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Auto-Submit: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707210}
parent f96f7903
......@@ -2083,11 +2083,10 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
command_line->AppendSwitch(switches::kAllowSyncXHRInPageDismissal);
}
if (profile->ShouldEnableOutOfBlinkCors())
command_line->AppendSwitch(network::switches::kEnableOutOfBlinkCors);
} else if (base::FeatureList::IsEnabled(
network::features::kOutOfBlinkCors)) {
command_line->AppendSwitch(network::switches::kEnableOutOfBlinkCors);
if (!profile->ShouldEnableOutOfBlinkCors()) {
command_line->AppendSwitch(
network::switches::kForceToDisableOutOfBlinkCors);
}
}
if (IsAutoReloadEnabled())
......
......@@ -439,8 +439,6 @@ void SetRuntimeFeaturesFromCommandLine(const base::CommandLine& command_line) {
switches::kEnableAccessibilityObjectModel, true},
{wrf::EnableAllowSyncXHRInPageDismissal,
switches::kAllowSyncXHRInPageDismissal, true},
{wrf::EnableOutOfBlinkCors, network::switches::kEnableOutOfBlinkCors,
true},
};
for (const auto& mapping : switchToFeatureMapping) {
if (command_line.HasSwitch(mapping.switch_name))
......@@ -570,6 +568,12 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnableOriginTrialControlledFeatures(false);
}
if (!command_line.HasSwitch(
network::switches::kForceToDisableOutOfBlinkCors) &&
base::FeatureList::IsEnabled(network::features::kOutOfBlinkCors)) {
WebRuntimeFeatures::EnableOutOfBlinkCors(true);
}
// TODO(rodneyding): add doc explaining ways to add new runtime features
// controls in the following functions.
......
......@@ -378,8 +378,9 @@ void ServiceWorkerSubresourceLoader::OnFallback(
// preflight logic is implemented in Blink. So we return a "fallback required"
// response to Blink.
// TODO(falken): Remove this mechanism after OOB-CORS ships.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
network::switches::kEnableOutOfBlinkCors) &&
if ((base::CommandLine::ForCurrentProcess()->HasSwitch(
network::switches::kForceToDisableOutOfBlinkCors) ||
!base::FeatureList::IsEnabled(network::features::kOutOfBlinkCors)) &&
((resource_request_.mode == network::mojom::RequestMode::kCors ||
resource_request_.mode ==
network::mojom::RequestMode::kCorsWithForcedPreflight) &&
......
......@@ -70,8 +70,8 @@ const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports";
const char kUnsafelyTreatInsecureOriginAsSecure[] =
"unsafely-treat-insecure-origin-as-secure";
// Enable OOR-CORS in child processes.
const char kEnableOutOfBlinkCors[] = "enable-oor-cors";
// Disable OOR-CORS in child processes regardless of the base::Feature flag.
const char kForceToDisableOutOfBlinkCors[] = "disable-oor-cors";
} // namespace switches
......
......@@ -23,7 +23,7 @@ COMPONENT_EXPORT(NETWORK_CPP) extern const char kSSLKeyLogFile[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kExplicitlyAllowedPorts[];
COMPONENT_EXPORT(NETWORK_CPP)
extern const char kUnsafelyTreatInsecureOriginAsSecure[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kEnableOutOfBlinkCors[];
COMPONENT_EXPORT(NETWORK_CPP) extern const char kForceToDisableOutOfBlinkCors[];
} // namespace switches
......
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