diff options
author | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 16:04:49 +0000 |
---|---|---|
committer | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 16:04:49 +0000 |
commit | e541d9fb2e77ff788bf2353331b34ba841b99ff5 (patch) | |
tree | 3aeb2e2a599c4a73c9b068c4f98c9258a1a68c5f /chrome/browser/configuration_policy_pref_store.cc | |
parent | facc6ada0300c8e9a67b0cf283257a2c70fa15c2 (diff) | |
download | chromium_src-e541d9fb2e77ff788bf2353331b34ba841b99ff5.zip chromium_src-e541d9fb2e77ff788bf2353331b34ba841b99ff5.tar.gz chromium_src-e541d9fb2e77ff788bf2353331b34ba841b99ff5.tar.bz2 |
Implement disabling of plugins through policy
TEST=manual testing of plugins page, ConfigurationPolicyPrefStoreTest*
BUG=45856
Review URL: http://codereview.chromium.org/2833034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/configuration_policy_pref_store.cc')
-rw-r--r-- | chrome/browser/configuration_policy_pref_store.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/configuration_policy_pref_store.cc b/chrome/browser/configuration_policy_pref_store.cc index 43c9caa..2479a67 100644 --- a/chrome/browser/configuration_policy_pref_store.cc +++ b/chrome/browser/configuration_policy_pref_store.cc @@ -6,6 +6,8 @@ #include "base/command_line.h" #include "base/logging.h" +#include "base/string16.h" +#include "base/string_util.h" #include "base/values.h" #include "chrome/browser/configuration_policy_provider.h" #include "chrome/common/chrome_switches.h" @@ -224,6 +226,41 @@ bool ConfigurationPolicyPrefStore::ApplyProxyPolicy(PolicyType policy, return result; } +bool ConfigurationPolicyPrefStore::ApplyPluginPolicy(PolicyType policy, + Value* value) { + if (policy == kPolicyDisabledPlugins) { + string16 plugin_list; + if (value->GetAsUTF16(&plugin_list)) { + std::vector<string16> plugin_names; + // Change commas into tabs so that we can change escaped + // tabs back into commas, leaving non-escaped commas as tabs + // that can be used for splitting the string. Note that plugin + // names must not contain backslashes, since a trailing backslash + // in a plugin name before a comma would get swallowed during the + // splitting. + std::replace(plugin_list.begin(), plugin_list.end(), L',', L'\t'); + ReplaceSubstringsAfterOffset(&plugin_list, 0, + ASCIIToUTF16("\\\t"), ASCIIToUTF16(",")); + SplitString(plugin_list, L'\t', &plugin_names); + bool added_plugin = false; + scoped_ptr<ListValue> list(new ListValue()); + for (std::vector<string16>::const_iterator i(plugin_names.begin()); + i != plugin_names.end(); ++i) { + if (!i->empty()) { + list->Append(Value::CreateStringValueFromUTF16(*i)); + added_plugin = true; + } + } + if (added_plugin) { + prefs_->Set(prefs::kPluginsPluginsBlacklist, list.release()); + delete value; + return true; + } + } + } + return false; +} + bool ConfigurationPolicyPrefStore::ApplySyncPolicy(PolicyType policy, Value* value) { if (policy == ConfigurationPolicyStore::kPolicySyncDisabled) { @@ -255,6 +292,9 @@ void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) { if (ApplyProxyPolicy(policy, value)) return; + if (ApplyPluginPolicy(policy, value)) + return; + if (ApplySyncPolicy(policy, value)) return; @@ -264,4 +304,5 @@ void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) { // Other policy implementations go here. NOTIMPLEMENTED(); + delete value; } |