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/plugin_updater.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/plugin_updater.cc')
-rw-r--r-- | chrome/browser/plugin_updater.cc | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/chrome/browser/plugin_updater.cc b/chrome/browser/plugin_updater.cc index 288de87..4c884d7 100644 --- a/chrome/browser/plugin_updater.cc +++ b/chrome/browser/plugin_updater.cc @@ -80,11 +80,12 @@ void EnablePluginGroup(bool enable, const string16& group_name) { } } -void EnablePluginFile(bool enable, const FilePath::StringType& file_path) { - if (enable) - NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(file_path)); +void EnablePluginFile(bool enable, const FilePath::StringType& path) { + FilePath file_path(path); + if (enable && !PluginGroup::IsPluginPathDisabledByPolicy(file_path)) + NPAPI::PluginList::Singleton()->EnablePlugin(file_path); else - NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(file_path)); + NPAPI::PluginList::Singleton()->DisablePlugin(file_path); } #if defined(OS_CHROMEOS) @@ -166,6 +167,42 @@ void DisablePluginGroupsFromPrefs(Profile* profile) { } } + // Build the set of policy-disabled plugins once and cache it. + // Don't do this in the constructor, there's no profile available there. + std::set<string16> policy_disabled_plugins; + const ListValue* plugin_blacklist = + profile->GetPrefs()->GetList(prefs::kPluginsPluginsBlacklist); + if (plugin_blacklist) { + ListValue::const_iterator end(plugin_blacklist->end()); + for (ListValue::const_iterator current(plugin_blacklist->begin()); + current != end; ++current) { + string16 plugin_name; + if ((*current)->GetAsUTF16(&plugin_name)) { + policy_disabled_plugins.insert(plugin_name); + } + } + } + PluginGroup::SetPolicyDisabledPluginSet(policy_disabled_plugins); + + // Disable all of the plugins and plugin groups that are disabled by policy. + std::vector<WebPluginInfo> plugins; + NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); + for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); + it != plugins.end(); + ++it) { + if (PluginGroup::IsPluginNameDisabledByPolicy(it->name)) + NPAPI::PluginList::Singleton()->DisablePlugin(it->path); + } + + std::vector<linked_ptr<PluginGroup> > plugin_groups; + GetPluginGroups(&plugin_groups); + std::vector<linked_ptr<PluginGroup> >::const_iterator it; + for (it = plugin_groups.begin(); it != plugin_groups.end(); ++it) { + string16 current_group_name = (*it)->GetGroupName(); + if (PluginGroup::IsPluginNameDisabledByPolicy(current_group_name)) + EnablePluginGroup(false, current_group_name); + } + if (!enable_internal_pdf_ && !found_internal_pdf) { // The internal PDF plugin is disabled by default, and the user hasn't // overridden the default. |