Add Enterprise policy to disable FormControlsRefresh feature
This CL adds an Enterprise Policy, UseLegacyFormControls, which
will allow enterprise customers to opt out of the new
FormControlsRefresh feature for a few milestones, in case of
problems.
Bug: 1054511
Change-Id: I9982335da17dd1323e09798c613d30d446ffd227
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076758
Reviewed-by: Roman Sorokin [CET] <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/master@{#745103}
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 5066393..55e66e21 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -2128,6 +2128,10 @@
prefs->GetBoolean(prefs::kWebComponentsV0Enabled)) {
command_line->AppendSwitch(switches::kWebComponentsV0Enabled);
}
+ if (prefs->HasPrefPath(prefs::kUseLegacyFormControls) &&
+ prefs->GetBoolean(prefs::kUseLegacyFormControls)) {
+ command_line->AppendSwitch(switches::kUseLegacyFormControls);
+ }
if (!profile->ShouldEnableOutOfBlinkCors()) {
command_line->AppendSwitch(
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index 8399d59..d5331d71 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -338,6 +338,9 @@
{ key::kWebComponentsV0Enabled,
prefs::kWebComponentsV0Enabled,
base::Value::Type::BOOLEAN },
+ { key::kUseLegacyFormControls,
+ prefs::kUseLegacyFormControls,
+ base::Value::Type::BOOLEAN },
{ key::kAmbientAuthenticationInPrivateModesEnabled,
prefs::kAmbientAuthenticationInPrivateModesEnabled,
base::Value::Type::INTEGER },
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 1965d77..d7ea042 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -84,6 +84,7 @@
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/webauthn/chrome_authenticator_request_delegate.h"
#include "chrome/common/buildflags.h"
+#include "chrome/common/chrome_ui_features_prefs.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/secure_origin_whitelist.h"
#include "chrome/common/web_components_prefs.h"
@@ -838,6 +839,7 @@
chrome_browser_net::NetErrorTabHelper::RegisterProfilePrefs(registry);
chrome_browser_net::RegisterPredictionOptionsProfilePrefs(registry);
chrome_prefs::RegisterProfilePrefs(registry);
+ chrome_ui_features_prefs::RegisterProfilePrefs(registry);
DocumentProvider::RegisterProfilePrefs(registry);
dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(registry);
dom_distiller::RegisterProfilePrefs(registry);
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
index 2ac6fe1c..0ee5857b 100644
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -107,6 +107,8 @@
"chrome_descriptors.h",
"chrome_isolated_world_ids.h",
"chrome_result_codes.h",
+ "chrome_ui_features_prefs.cc",
+ "chrome_ui_features_prefs.h",
"client_hints/client_hints.cc",
"client_hints/client_hints.h",
"common_message_generator.cc",
diff --git a/chrome/common/chrome_ui_features_prefs.cc b/chrome/common/chrome_ui_features_prefs.cc
new file mode 100644
index 0000000..7e06f82f
--- /dev/null
+++ b/chrome/common/chrome_ui_features_prefs.cc
@@ -0,0 +1,17 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/chrome_ui_features_prefs.h"
+
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_registry_simple.h"
+
+namespace chrome_ui_features_prefs {
+
+void RegisterProfilePrefs(PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(prefs::kUseLegacyFormControls,
+ /*default_value=*/false);
+}
+
+} // namespace chrome_ui_features_prefs
diff --git a/chrome/common/chrome_ui_features_prefs.h b/chrome/common/chrome_ui_features_prefs.h
new file mode 100644
index 0000000..9f18b97
--- /dev/null
+++ b/chrome/common/chrome_ui_features_prefs.h
@@ -0,0 +1,17 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_CHROME_UI_FEATURES_PREFS_H_
+#define CHROME_COMMON_CHROME_UI_FEATURES_PREFS_H_
+
+class PrefRegistrySimple;
+
+namespace chrome_ui_features_prefs {
+
+// Register preferences for Chrome UI Features.
+void RegisterProfilePrefs(PrefRegistrySimple* registry);
+
+} // namespace chrome_ui_features_prefs
+
+#endif // CHROME_COMMON_CHROME_UI_FEATURES_PREFS_H_
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index bcacb42..e8022949 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -2932,6 +2932,11 @@
// TODO(937746): Remove this after M84.
const char kWebComponentsV0Enabled[] = "web_components_v0_enabled";
+// This pref allows the FormControlsRefresh feature to be disabled temporarily
+// from M81 through M84.
+// TODO(1034611): Remove this after M84.
+const char kUseLegacyFormControls[] = "use_legacy_form_controls";
+
#if defined(OS_ANDROID)
// Last time the known interception disclosure message was dismissed. Used to
// ensure a cooldown period passes before the disclosure message is displayed
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 48a537b..2f6e3858 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -1028,6 +1028,8 @@
extern const char kWebComponentsV0Enabled[];
+extern const char kUseLegacyFormControls[];
+
#if defined(OS_ANDROID)
extern const char kKnownInterceptionDisclosureInfobarLastShown[];
#endif
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json
index 8285dd6..6f84a43 100644
--- a/chrome/test/data/policy/policy_test_cases.json
+++ b/chrome/test/data/policy/policy_test_cases.json
@@ -3414,6 +3414,12 @@
"policy_pref_mapping_tests": { "web_components_v0_enabled": {} }
},
+ "UseLegacyFormControls": {
+ "os": ["win", "linux", "mac", "chromeos", "android"],
+ "test_policy": { "UseLegacyFormControls": true },
+ "policy_pref_mapping_tests": { "use_legacy_form_controls": {} }
+ },
+
"GloballyScopeHTTPAuthCacheEnabled": {
"os": ["win", "linux", "mac", "chromeos", "android"],
"test_policy": { "GloballyScopeHTTPAuthCacheEnabled": true },
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json
index 92782f4..d2c6a865 100644
--- a/components/policy/resources/policy_templates.json
+++ b/components/policy/resources/policy_templates.json
@@ -19639,6 +19639,28 @@
This policy will be removed after Chrome 84.'''
},
{
+ 'name': 'UseLegacyFormControls',
+ 'owners': ['[email protected]', '[email protected]', '[email protected]', '[email protected]'],
+ 'type': 'main',
+ 'schema': { 'type': 'boolean' },
+ 'example_value': True,
+ 'id': 683,
+ 'supported_on': ['chrome.*:81-84', 'chrome_os:81-84', 'android:81-84', 'webview_android:81-84'],
+ 'features': {
+ 'dynamic_refresh': False,
+ 'per_profile': True,
+ },
+ 'caption': '''Use Legacy Form Controls until M84.''',
+ 'tags': [],
+ 'desc': ''' Starting in M81, the standard form control elements (e.g. <select>, <button>, <input type=date>) were given a refreshed look and feel, with improved accessibility and better platform uniformity. This policy restores the old "legacy" form control elements until M84.
+
+ If this policy is set to True, the "legacy" form control elements will be used for all sites.
+
+ If this policy is set to False or not set, the form control elements will be enabled as they are launched in M81, M82, and M83.
+
+ This policy will be removed after Chrome 84.'''
+ },
+ {
'name': 'ClickToCallEnabled',
'owners': ['[email protected]', '[email protected]'],
'type': 'main',
@@ -21008,6 +21030,6 @@
],
'placeholders': [],
'deleted_policy_ids': [412, 546, 562, 569, 578],
- 'highest_id_currently_used': 682,
+ 'highest_id_currently_used': 683,
'highest_atomic_group_id_currently_used': 38
}
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index ad6818fb..6f190eb 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -3281,6 +3281,7 @@
switches::kTraceToConsole,
switches::kUseFakeCodecForPeerConnection,
switches::kUseFakeUIForMediaStream,
+ switches::kUseLegacyFormControls,
// This flag needs to be propagated to the renderer process for
// --in-process-webgl.
switches::kUseGL,
diff --git a/content/public/common/content_switch_dependent_feature_overrides.cc b/content/public/common/content_switch_dependent_feature_overrides.cc
index 7ce31c45..25e4e0a 100644
--- a/content/public/common/content_switch_dependent_feature_overrides.cc
+++ b/content/public/common/content_switch_dependent_feature_overrides.cc
@@ -7,6 +7,7 @@
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "services/network/public/cpp/features.h"
+#include "ui/base/ui_base_features.h"
namespace content {
@@ -40,6 +41,9 @@
{switches::kEnableExperimentalWebPlatformFeatures,
std::cref(features::kOriginPolicy),
base::FeatureList::OVERRIDE_ENABLE_FEATURE},
+ {switches::kUseLegacyFormControls,
+ std::cref(features::kFormControlsRefresh),
+ base::FeatureList::OVERRIDE_DISABLE_FEATURE},
};
// TODO(chlily): There are currently a few places where, to check if some
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 3915630b..97684ce 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -938,6 +938,11 @@
// TODO(937746): Remove this after M84.
const char kWebComponentsV0Enabled[] = "web-components-v0-enabled";
+// This switch allows the FormControlsRefresh feature to be disabled temporarily
+// from M81 through M84.
+// TODO(1034611): Remove this after M84.
+const char kUseLegacyFormControls[] = "use-legacy-form-controls";
+
#if defined(OS_ANDROID)
// Disable Media Session API
const char kDisableMediaSessionAPI[] = "disable-media-session-api";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index b2f61c83..eb88e47 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -253,6 +253,7 @@
CONTENT_EXPORT extern const char kWebRtcStunProbeTrialParameter[];
CONTENT_EXPORT extern const char kWebRtcLocalEventLogging[];
CONTENT_EXPORT extern const char kWebComponentsV0Enabled[];
+CONTENT_EXPORT extern const char kUseLegacyFormControls[];
CONTENT_EXPORT extern const char kWebXrForceRuntime[];
CONTENT_EXPORT extern const char kWebXrRuntimeNone[];
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 4840c5b..7214448 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -19697,6 +19697,7 @@
<int value="680" label="RequiredClientCertificateForUser"/>
<int value="681" label="RequiredClientCertificateForDevice"/>
<int value="682" label="ReportDeviceMemoryInfo"/>
+ <int value="683" label="UseLegacyFormControls"/>
</enum>
<enum name="EnterprisePolicyDeviceIdValidity">