summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 18:51:55 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 18:51:55 +0000
commit1733b78d997caca8d8553719d832b8bc949e78cf (patch)
tree4307cecc2999921e5152522013ba1289b5c43e37
parentedaeb3f929e59e72ca3cdeb81baa9dd4d5affcb0 (diff)
downloadchromium_src-1733b78d997caca8d8553719d832b8bc949e78cf.zip
chromium_src-1733b78d997caca8d8553719d832b8bc949e78cf.tar.gz
chromium_src-1733b78d997caca8d8553719d832b8bc949e78cf.tar.bz2
Add a policy to re-enable deprecated web platform features.
This will give admins the ability to re-enable deprecated features for a limited amount of time. This is a re-upload of codereview.chromium.org/263423003 because I've taken over that CL for mnissler. R=joaodasilva@chromium.org, jochen@chromium.org TBR=jar BUG=345831 Review URL: https://codereview.chromium.org/344693004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278436 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_content_browser_client.cc17
-rw-r--r--chrome/browser/policy/configuration_policy_handler_list_factory.cc32
-rw-r--r--chrome/browser/policy/policy_browsertest.cc25
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--chrome/test/data/policy/policy_test_cases.json12
-rw-r--r--components/policy/resources/policy_templates.json26
-rw-r--r--tools/metrics/histograms/histograms.xml1
8 files changed, 107 insertions, 10 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index a500608..e0226ae 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -251,8 +251,8 @@
#include "chrome/browser/media/webrtc_logging_handler_host.h"
#endif
-using blink::WebWindowFeatures;
using base::FileDescriptor;
+using blink::WebWindowFeatures;
using content::AccessTokenStore;
using content::BrowserChildProcessHostIterator;
using content::BrowserThread;
@@ -666,6 +666,9 @@ void ChromeContentBrowserClient::RegisterProfilePrefs(
prefs::kEnableHyperlinkAuditing,
true,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ registry->RegisterListPref(
+ prefs::kEnableDeprecatedWebPlatformFeatures,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// static
@@ -1611,6 +1614,18 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
command_line->AppendSwitch(switches::kDisable3DAPIs);
}
+ const base::ListValue* switches =
+ prefs->GetList(prefs::kEnableDeprecatedWebPlatformFeatures);
+ if (switches) {
+ // Enable any deprecated features that have been re-enabled by policy.
+ for (base::ListValue::const_iterator it = switches->begin();
+ it != switches->end(); ++it) {
+ std::string switch_to_enable;
+ if ((*it)->GetAsString(&switch_to_enable))
+ command_line->AppendSwitch(switch_to_enable);
+ }
+ }
+
// Disable client-side phishing detection in the renderer if it is
// disabled in the Profile preferences or the browser process.
if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index 0741e6e..2a47ba1 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/policy/managed_bookmarks_policy_handler.h"
#include "chrome/browser/profiles/incognito_mode_policy_handler.h"
#include "chrome/browser/search_engines/default_search_policy_handler.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/policy/core/browser/autofill_policy_handler.h"
@@ -491,25 +492,35 @@ void GetExtensionAllowedTypesMap(
ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
// Mapping from extension type names to Manifest::Type.
result->push_back(new StringMappingListPolicyHandler::MappingEntry(
- "extension", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ "extension", scoped_ptr<base::Value>(new base::FundamentalValue(
extensions::Manifest::TYPE_EXTENSION))));
result->push_back(new StringMappingListPolicyHandler::MappingEntry(
- "theme", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ "theme", scoped_ptr<base::Value>(new base::FundamentalValue(
extensions::Manifest::TYPE_THEME))));
result->push_back(new StringMappingListPolicyHandler::MappingEntry(
- "user_script", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ "user_script", scoped_ptr<base::Value>(new base::FundamentalValue(
extensions::Manifest::TYPE_USER_SCRIPT))));
result->push_back(new StringMappingListPolicyHandler::MappingEntry(
- "hosted_app", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ "hosted_app", scoped_ptr<base::Value>(new base::FundamentalValue(
extensions::Manifest::TYPE_HOSTED_APP))));
result->push_back(new StringMappingListPolicyHandler::MappingEntry(
- "legacy_packaged_app", scoped_ptr<base::Value>(
- base::Value::CreateIntegerValue(
- extensions::Manifest::TYPE_LEGACY_PACKAGED_APP))));
+ "legacy_packaged_app", scoped_ptr<base::Value>(new base::FundamentalValue(
+ extensions::Manifest::TYPE_LEGACY_PACKAGED_APP))));
result->push_back(new StringMappingListPolicyHandler::MappingEntry(
- "platform_app", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(
+ "platform_app", scoped_ptr<base::Value>(new base::FundamentalValue(
extensions::Manifest::TYPE_PLATFORM_APP))));
}
+
+void GetDeprecatedFeaturesMap(
+ ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
+ // Maps feature tags as specified in policy to the corresponding switch to
+ // re-enable them.
+ // TODO: Remove after 2015-04-30 per http://crbug.com/374782.
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "ShowModalDialog_EffectiveUntil20150430",
+ scoped_ptr<base::Value>(new base::StringValue(
+ switches::kEnableShowModalDialog))));
+}
#endif // !defined(OS_IOS)
} // namespace
@@ -581,6 +592,11 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
key::kExtensionAllowedTypes,
extensions::pref_names::kAllowedTypes,
base::Bind(GetExtensionAllowedTypesMap))));
+ handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
+ new StringMappingListPolicyHandler(
+ key::kEnableDeprecatedWebPlatformFeatures,
+ prefs::kEnableDeprecatedWebPlatformFeatures,
+ base::Bind(GetDeprecatedFeaturesMap))));
#endif // !defined(OS_IOS)
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 7b832a1..04be3f5 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -3015,6 +3015,31 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) {
prefs, "other.host.name"));
}
+IN_PROC_BROWSER_TEST_F(PolicyTest,
+ EnableDeprecatedWebPlatformFeatures_ShowModalDialog) {
+ base::ListValue enabled_features;
+ enabled_features.Append(new base::StringValue(
+ "ShowModalDialog_EffectiveUntil20150430"));
+ PolicyMap policies;
+ policies.Set(key::kEnableDeprecatedWebPlatformFeatures,
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ enabled_features.DeepCopy(),
+ NULL);
+ UpdateProviderPolicy(policies);
+
+ // Policy only takes effect on new browsers, not existing browsers, so create
+ // a new browser.
+ Browser* browser2 = CreateBrowser(browser()->profile());
+ ui_test_utils::NavigateToURL(browser2, GURL(url::kAboutBlankURL));
+ bool result = false;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
+ browser2->tab_strip_model()->GetActiveWebContents(),
+ "domAutomationController.send(window.showModalDialog !== undefined);",
+ &result));
+ EXPECT_TRUE(result);
+}
+
#endif // !defined(CHROME_OS)
} // namespace policy
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index c7e351c..8b187e3 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1139,6 +1139,9 @@ const char kMediaDeviceIdSalt[] = "media.device_id_salt";
// Preference to disable 3D APIs (WebGL, Pepper 3D).
const char kDisable3DAPIs[] = "disable_3d_apis";
+const char kEnableDeprecatedWebPlatformFeatures[] =
+ "enable_deprecated_web_platform_features";
+
// Whether to enable hyperlink auditing ("<a ping>").
const char kEnableHyperlinkAuditing[] = "enable_a_ping";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index b2ee4f8..e0f2b86 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -355,6 +355,7 @@ extern const char kAutofillDialogDefaults[];
extern const char kPinnedTabs[];
extern const char kDisable3DAPIs[];
+extern const char kEnableDeprecatedWebPlatformFeatures[];
extern const char kEnableHyperlinkAuditing[];
extern const char kEnableReferrers[];
extern const char kEnableDoNotTrack[];
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json
index eee9bff..16b09d9 100644
--- a/chrome/test/data/policy/policy_test_cases.json
+++ b/chrome/test/data/policy/policy_test_cases.json
@@ -2114,6 +2114,18 @@
]
},
+ "EnableDeprecatedWebPlatformFeatures": {
+ "os": ["win", "linux", "mac", "chromeos"],
+ "test_policy": {
+ "EnableDeprecatedWebPlatformFeatures": [
+ "ShowModalDialog_EffectiveUntil20150430"
+ ]
+ },
+ "pref_mappings": [
+ { "pref": "enable_deprecated_web_platform_features" }
+ ]
+ },
+
"TouchVirtualKeyboardEnabled": {
"os": ["chromeos"],
"test_policy": { "TouchVirtualKeyboardEnabled": false },
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json
index 28ab324..0b8bc0f 100644
--- a/components/policy/resources/policy_templates.json
+++ b/components/policy/resources/policy_templates.json
@@ -118,7 +118,7 @@
# persistent IDs for all fields (but not for groups!) are needed. These are
# specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs,
# because doing so would break the deployed wire format!
-# For your editing convenience: highest ID currently used: 269
+# For your editing convenience: highest ID currently used: 270
#
# Placeholders:
# The following placeholder strings are automatically substituted:
@@ -6490,6 +6490,30 @@
If the policy is left not set, the user can choose an image to be shown on the desktop and on the login screen background.''',
},
+ {
+ 'name': 'EnableDeprecatedWebPlatformFeatures',
+ 'type': 'list',
+ 'schema': {
+ 'type': 'array',
+ 'items': { 'type': 'string' },
+ },
+ 'supported_on': ['chrome.*:37-', 'chrome_os:37-', 'android:37-'],
+ 'features': {
+ 'dynamic_refresh': True,
+ 'per_profile': True,
+ },
+ 'example_value': [],
+ 'id': 270,
+ 'caption': '''Enable deprecated web platform features''',
+ 'desc': '''Specify a list of deprecated web platform features to re-enable.
+
+ This policy gives administrators the ability to re-enable deprecated web platform features for a limited time. Features are identified by a string tag and the features corresponding to the tags included in the list specified by this policy will get re-enabled.
+
+ The following tags are currently defined:
+ - ShowModalDialog_EffectiveUntil20150430
+
+ If this policy is left not set or the list is empty, all deprecated web platform features will remain disabled.''',
+ },
],
'messages': {
# Messages that are not associated to any policies.
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index ea7fcc5..3cf3bc8 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -35531,6 +35531,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="267" label="Show the apps shortcut in the bookmark bar"/>
<int value="268" label="Register protocol handlers"/>
<int value="269" label="Enable virtual keyboard"/>
+ <int value="270" label="Enable deprecated web platform features"/>
</enum>
<enum name="EnterprisePolicyInvalidations" type="int">