diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/plugin_group.cc | 54 | ||||
-rw-r--r-- | chrome/common/plugin_group.h | 14 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
4 files changed, 69 insertions, 3 deletions
diff --git a/chrome/common/plugin_group.cc b/chrome/common/plugin_group.cc index 984aebc..5df39b3 100644 --- a/chrome/common/plugin_group.cc +++ b/chrome/common/plugin_group.cc @@ -68,6 +68,9 @@ static const PluginGroupDefinition kGroupDefinitions[] = {}; #endif /*static*/ +std::set<string16>* PluginGroup::policy_disabled_puglins_; + +/*static*/ const PluginGroupDefinition* PluginGroup::GetPluginGroupDefinitions() { return kGroupDefinitions; } @@ -78,6 +81,36 @@ size_t PluginGroup::GetPluginGroupDefinitionsSize() { return ARRAYSIZE_UNSAFE(kGroupDefinitions); } +/*static*/ +void PluginGroup::SetPolicyDisabledPluginSet(const std::set<string16>& set) { + if (!policy_disabled_puglins_) { + policy_disabled_puglins_ = new std::set<string16>(); + *policy_disabled_puglins_ = set; + } +} + +/*static*/ +bool PluginGroup::IsPluginNameDisabledByPolicy(const string16& plugin_name) { + return policy_disabled_puglins_ && + policy_disabled_puglins_->find(plugin_name) != + policy_disabled_puglins_->end(); +} + +/*static*/ +bool PluginGroup::IsPluginPathDisabledByPolicy(const FilePath& plugin_path) { + std::vector<WebPluginInfo> plugins; + NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); + for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); + it != plugins.end(); + ++it) { + if (FilePath::CompareEqualIgnoreCase(it->path.value(), + plugin_path.value()) && IsPluginNameDisabledByPolicy(it->name)) { + return true; + } + } + return false; +} + PluginGroup::PluginGroup(const string16& group_name, const string16& name_matcher, const std::string& version_range_low, @@ -231,7 +264,14 @@ DictionaryValue* PluginGroup::GetDataForUI() const { result->SetString(L"version", max_version_->GetString()); result->SetString(L"update_url", update_url_); result->SetBoolean(L"critical", IsVulnerable()); - result->SetBoolean(L"enabled", enabled_); + + bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(group_name_); + if (group_disabled_by_policy) { + result->SetString(L"enabledMode", L"disabledByPolicy"); + } else { + result->SetString(L"enabledMode", + enabled_ ? L"enabled" : L"disabledByUser"); + } ListValue* plugin_files = new ListValue(); for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { @@ -242,7 +282,14 @@ DictionaryValue* PluginGroup::GetDataForUI() const { plugin_file->SetStringFromUTF16(L"description", web_plugin.desc); plugin_file->SetString(L"path", web_plugin.path.value()); plugin_file->SetStringFromUTF16(L"version", web_plugin.version); - plugin_file->SetBoolean(L"enabled", web_plugin.enabled); + bool plugin_disabled_by_policy = group_disabled_by_policy || + IsPluginNameDisabledByPolicy(web_plugin.name); + if (plugin_disabled_by_policy) { + result->SetString(L"enabledMode", L"disabledByPolicy"); + } else { + result->SetString(L"enabledMode", + web_plugin.enabled ? L"enabled" : L"disabledByUser"); + } plugin_file->SetInteger(L"priority", priority); ListValue* mime_types = new ListValue(); @@ -286,10 +333,11 @@ void PluginGroup::Enable(bool enable) { for (std::vector<WebPluginInfo>::const_iterator it = web_plugin_infos_.begin(); it != web_plugin_infos_.end(); ++it) { - if (enable) { + if (enable && !IsPluginNameDisabledByPolicy(it->name)) { NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(it->path)); } else { NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(it->path)); } } } + diff --git a/chrome/common/plugin_group.h b/chrome/common/plugin_group.h index dba66ae..f9f6ce3 100644 --- a/chrome/common/plugin_group.h +++ b/chrome/common/plugin_group.h @@ -5,6 +5,7 @@ #ifndef CHROME_COMMON_PLUGIN_GROUP_H_ #define CHROME_COMMON_PLUGIN_GROUP_H_ +#include <set> #include <vector> #include "base/linked_ptr.h" @@ -41,6 +42,17 @@ class PluginGroup { // Find a plugin group matching |info| in the list of hardcoded plugins. static PluginGroup* FindHardcodedPluginGroup(const WebPluginInfo& info); + // Configures the set of plugin names that are disabled by policy. + static void SetPolicyDisabledPluginSet(const std::set<string16>& set); + + // Tests to see if a plugin is on the blacklist using its name as + // the lookup key. + static bool IsPluginNameDisabledByPolicy(const string16& plugin_name); + + // Tests to see if a plugin is on the blacklist using its path as + // the lookup key. + static bool IsPluginPathDisabledByPolicy(const FilePath& plugin_path); + // Find the PluginGroup matching a Plugin in a list of plugin groups. Returns // NULL if no matching PluginGroup is found. static PluginGroup* FindGroupMatchingPlugin( @@ -94,6 +106,8 @@ class PluginGroup { const std::string& min_version, const std::string& update_url); + static std::set<string16>* policy_disabled_puglins_; + string16 group_name_; string16 name_matcher_; std::string version_range_low_str_; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 424b011..b65a3da 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -413,6 +413,9 @@ const wchar_t kPluginsLastInternalDirectory[] = // List pref containing information (dictionaries) on plugins. const wchar_t kPluginsPluginsList[] = L"plugins.plugins_list"; +// List pref containing names of plugins that are disabled by policy. +const wchar_t kPluginsPluginsBlacklist[] = L"plugins.plugins_blacklist"; + // When first shipped, the pdf plugin will be disabled by default. When we // enable it by default, we'll want to do so only once. const wchar_t kPluginsEnabledInternalPDF[] = L"plugins.enabled_internal_pdf"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 4a00675..7dfc8ff 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -162,6 +162,7 @@ extern const wchar_t kExtensionsUIDeveloperMode[]; extern const wchar_t kExtensionToolbarSize[]; extern const wchar_t kPluginsLastInternalDirectory[]; extern const wchar_t kPluginsPluginsList[]; +extern const wchar_t kPluginsPluginsBlacklist[]; extern const wchar_t kPluginsEnabledInternalPDF[]; extern const wchar_t kCheckDefaultBrowser[]; #if defined(OS_MACOSX) |