diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-21 15:00:34 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-21 15:00:34 +0000 |
commit | 74b8d3e4e52a6419a98ecc40b6f6710f7911726d (patch) | |
tree | e8f076d596363ea2ac0cc61831260c3d395a9436 /chrome/common | |
parent | 0b7ba8c5a0f954e8dea8709a34a5b5f0dc40c615 (diff) | |
download | chromium_src-74b8d3e4e52a6419a98ecc40b6f6710f7911726d.zip chromium_src-74b8d3e4e52a6419a98ecc40b6f6710f7911726d.tar.gz chromium_src-74b8d3e4e52a6419a98ecc40b6f6710f7911726d.tar.bz2 |
Add a unique identifier for plugin groups and use it to identify blocked plugins.
Currently we use the plugin path as identifier for per-plugin content settings, which is not stable across Chrome updates or plugin moves.
The new identifier is either hardcoded (for predefined plugin groups), or the filename without path.
BUG=39252
TEST=none
Review URL: http://codereview.chromium.org/3384014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/plugin_group.cc | 106 | ||||
-rw-r--r-- | chrome/common/plugin_group.h | 19 | ||||
-rw-r--r-- | chrome/common/plugin_group_unittest.cc | 8 |
3 files changed, 77 insertions, 56 deletions
diff --git a/chrome/common/plugin_group.cc b/chrome/common/plugin_group.cc index 6297466..a4930146 100644 --- a/chrome/common/plugin_group.cc +++ b/chrome/common/plugin_group.cc @@ -6,6 +6,7 @@ #include "base/linked_ptr.h" #include "base/string_util.h" +#include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "base/version.h" @@ -18,19 +19,19 @@ // (new versions) are published. // TODO(panayiotis): Get the Real Player version on Mac, somehow. static const PluginGroupDefinition kGroupDefinitions[] = { - { "Quicktime", "QuickTime Plug-in", "", "", "7.6.6", + { "apple-quicktime", "Quicktime", "QuickTime Plug-in", "", "", "7.6.6", "http://www.apple.com/quicktime/download/" }, - { "Java", "Java", "", "", "", + { "java-runtime-environment", "Java", "Java", "", "", "", "http://support.apple.com/kb/HT1338" }, - { "Flash", "Shockwave Flash", "", "", "10.1.82", + { "adobe-flash-player", "Flash", "Shockwave Flash", "", "", "10.1.82", "http://get.adobe.com/flashplayer/" }, - { "Silverlight 3", "Silverlight", "0", "4", "3.0.50106.0", + { "silverlight-3", "Silverlight 3", "Silverlight", "0", "4", "3.0.50106.0", "http://go.microsoft.com/fwlink/?LinkID=185927" }, - { "Silverlight 4", "Silverlight", "4", "5", "", + { "silverlight-4", "Silverlight 4", "Silverlight", "4", "5", "", "http://go.microsoft.com/fwlink/?LinkID=185927" }, - { "Flip4Mac", "Flip4Mac", "", "", "2.2.1", + { "flip4mac", "Flip4Mac", "Flip4Mac", "", "", "2.2.1", "http://www.telestream.net/flip4mac-wmv/overview.htm" }, - { "Shockwave", "Shockwave for Director", "", "", "11.5.8.612", + { "shockwave", "Shockwave", "Shockwave for Director", "", "", "11.5.8.612", "http://www.adobe.com/shockwave/download/" } }; @@ -38,31 +39,34 @@ static const PluginGroupDefinition kGroupDefinitions[] = { // TODO(panayiotis): We should group "RealJukebox NS Plugin" with the rest of // the RealPlayer files. static const PluginGroupDefinition kGroupDefinitions[] = { - { "Quicktime", "QuickTime Plug-in", "", "", "7.6.7", + { "apple-quicktime", "Quicktime", "QuickTime Plug-in", "", "", "7.6.7", "http://www.apple.com/quicktime/download/" }, - { "Java 6", "Java", "", "6", "6.0.200", + { "java-runtime-environment", "Java 6", "Java", "", "6", "6.0.200", "http://www.java.com/" }, - { "Adobe Reader 9", "Adobe Acrobat", "9", "10", "9.3.3", + { "adobe-reader", "Adobe Reader 9", "Adobe Acrobat", "9", "10", "9.3.3", "http://get.adobe.com/reader/" }, - { "Adobe Reader 8", "Adobe Acrobat", "0", "9", "8.2.3", + { "adobe-reader-8", "Adobe Reader 8", "Adobe Acrobat", "0", "9", "8.2.3", "http://get.adobe.com/reader/" }, - { "Flash", "Shockwave Flash", "", "", "10.1.82", + { "adobe-flash-player", "Flash", "Shockwave Flash", "", "", "10.1.82", "http://get.adobe.com/flashplayer/" }, - { "Silverlight 3", "Silverlight", "0", "4", "3.0.50106.0", + { "silverlight-3", "Silverlight 3", "Silverlight", "0", "4", "3.0.50106.0", "http://go.microsoft.com/fwlink/?LinkID=185927" }, - { "Silverlight 4", "Silverlight", "4", "5", "", + { "silverlight-4", "Silverlight 4", "Silverlight", "4", "5", "", "http://go.microsoft.com/fwlink/?LinkID=185927" }, - { "Shockwave", "Shockwave for Director", "", "", "11.5.8.612", + { "shockwave", "Shockwave", "Shockwave for Director", "", "", "11.5.8.612", "http://www.adobe.com/shockwave/download/" }, - { "DivX Player", "DivX Web Player", "", "", "1.4.3.4", - "http://download.divx.com/divx/autoupdate/player/DivXWebPlayerInstaller.exe" }, + { "divx-player", "DivX Player", "DivX Web Player", "", "", "1.4.3.4", + "http://download.divx.com/divx/autoupdate/player/" + "DivXWebPlayerInstaller.exe" }, // These are here for grouping, no vulnerabilies known. - { "Windows Media Player", "Windows Media Player", "", "", "", "" }, - { "Microsoft Office", "Microsoft Office", "", "", "", "" }, + { "windows-media-player", "Windows Media Player", "Windows Media Player", + "", "", "", "" }, + { "microsoft-office", "Microsoft Office", "Microsoft Office", + "", "", "", "" }, // TODO(panayiotis): The vulnerable versions are // (v >= 6.0.12.1040 && v <= 6.0.12.1663) // || v == 6.0.12.1698 || v == 6.0.12.1741 - { "RealPlayer", "RealPlayer", "", "", "", + { "realplayer", "RealPlayer", "RealPlayer", "", "", "", "http://www.adobe.com/shockwave/download/" }, }; @@ -129,26 +133,25 @@ PluginGroup::PluginGroup(const string16& group_name, const std::string& version_range_low, const std::string& version_range_high, const std::string& min_version, - const std::string& update_url) { - group_name_ = group_name; - name_matcher_ = name_matcher; - version_range_low_str_ = version_range_low; - if (!version_range_low.empty()) { - version_range_low_.reset( - Version::GetVersionFromString(version_range_low)); - } - version_range_high_str_ = version_range_high; + const std::string& update_url, + const std::string& identifier) + : identifier_(identifier), + group_name_(group_name), + name_matcher_(name_matcher), + version_range_low_str_(version_range_low), + version_range_high_str_(version_range_high), + update_url_(update_url), + enabled_(false), + min_version_str_(min_version), + version_(Version::GetVersionFromString("0")) { + if (!version_range_low.empty()) + version_range_low_.reset(Version::GetVersionFromString(version_range_low)); if (!version_range_high.empty()) { version_range_high_.reset( Version::GetVersionFromString(version_range_high)); } - min_version_str_ = min_version; - if (!min_version.empty()) { + if (!min_version.empty()) min_version_.reset(Version::GetVersionFromString(min_version)); - } - update_url_ = update_url; - enabled_ = false; - version_.reset(Version::GetVersionFromString("0")); } PluginGroup* PluginGroup::FromPluginGroupDefinition( @@ -158,27 +161,35 @@ PluginGroup* PluginGroup::FromPluginGroupDefinition( definition.version_matcher_low, definition.version_matcher_high, definition.min_version, - definition.update_url); + definition.update_url, + definition.identifier); } PluginGroup::~PluginGroup() { } PluginGroup* PluginGroup::FromWebPluginInfo(const WebPluginInfo& wpi) { // Create a matcher from the name of this plugin. - return new PluginGroup(wpi.name, wpi.name, - "", "", "", ""); +#if defined(OS_POSIX) + std::string identifier = wpi.path.BaseName().value(); +#elif defined(OS_WIN) + std::string identifier = base::SysWideToUTF8(wpi.path.BaseName().value()); +#endif + return new PluginGroup(wpi.name, wpi.name, std::string(), std::string(), + std::string(), std::string(), identifier); } -PluginGroup* PluginGroup::FindHardcodedPluginGroup(const WebPluginInfo& info) { - static std::vector<linked_ptr<PluginGroup> >* hardcoded_plugin_groups = NULL; +PluginGroup* PluginGroup::CopyOrCreatePluginGroup( + const WebPluginInfo& info) { + static PluginMap* hardcoded_plugin_groups = NULL; if (!hardcoded_plugin_groups) { - std::vector<linked_ptr<PluginGroup> >* groups = - new std::vector<linked_ptr<PluginGroup> >(); + PluginMap* groups = new PluginMap(); const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( definitions[i]); - groups->push_back(linked_ptr<PluginGroup>(definition_group)); + std::string identifier = definition_group->identifier(); + DCHECK(groups->find(identifier) == groups->end()); + (*groups)[identifier] = linked_ptr<PluginGroup>(definition_group); } hardcoded_plugin_groups = groups; } @@ -196,15 +207,14 @@ PluginGroup* PluginGroup::FindHardcodedPluginGroup(const WebPluginInfo& info) { } PluginGroup* PluginGroup::FindGroupMatchingPlugin( - std::vector<linked_ptr<PluginGroup> >& plugin_groups, + const PluginMap& plugin_groups, const WebPluginInfo& plugin) { - for (std::vector<linked_ptr<PluginGroup> >::iterator it = + for (std::map<std::string, linked_ptr<PluginGroup> >::const_iterator it = plugin_groups.begin(); it != plugin_groups.end(); ++it) { - if ((*it)->Match(plugin)) { - return it->get(); - } + if (it->second->Match(plugin)) + return it->second.get(); } return NULL; } diff --git a/chrome/common/plugin_group.h b/chrome/common/plugin_group.h index 62f5b6f..9691dd7 100644 --- a/chrome/common/plugin_group.h +++ b/chrome/common/plugin_group.h @@ -6,6 +6,7 @@ #define CHROME_COMMON_PLUGIN_GROUP_H_ #pragma once +#include <map> #include <set> #include <vector> @@ -23,6 +24,7 @@ class linked_ptr; // Hard-coded definitions of plugin groups. struct PluginGroupDefinition { + const char* identifier; // Unique identifier for this group. const char* name; // Name of this group. const char* name_matcher; // Substring matcher for the plugin name. const char* version_matcher_low; // Matchers for the plugin version. @@ -40,6 +42,8 @@ struct PluginGroupDefinition { class PluginGroup { public: + typedef std::map<std::string, linked_ptr<PluginGroup> > PluginMap; + // Creates a PluginGroup from a PluginGroupDefinition. static PluginGroup* FromPluginGroupDefinition( const PluginGroupDefinition& definition); @@ -53,7 +57,8 @@ class PluginGroup { // Find a plugin group matching |info| in the list of hardcoded plugins and // returns a copy of it if found, or a new group matching exactly this plugin // otherwise. - static PluginGroup* FindHardcodedPluginGroup(const WebPluginInfo& info); + // The caller should take ownership of the return PluginGroup. + static PluginGroup* CopyOrCreatePluginGroup(const WebPluginInfo& info); // Configures the set of plugin name patterns for disabling plugins via // enterprise configuration management. @@ -70,14 +75,14 @@ class PluginGroup { // Find the PluginGroup matching a Plugin in a list of plugin groups. Returns // NULL if no matching PluginGroup is found. static PluginGroup* FindGroupMatchingPlugin( - std::vector<linked_ptr<PluginGroup> >& plugin_groups, + const std::map<std::string, linked_ptr<PluginGroup> >& plugin_groups, const WebPluginInfo& plugin); // Creates a copy of this plugin group. PluginGroup* Copy() { return new PluginGroup(group_name_, name_matcher_, version_range_low_str_, version_range_high_str_, min_version_str_, - update_url_); + update_url_, identifier_); } // Returns true if the given plugin matches this group. @@ -94,6 +99,10 @@ class PluginGroup { // Returns whether the plugin group is enabled or not. bool Enabled() const { return enabled_; } + // Returns a unique identifier for this group, if one is defined, or the empty + // string otherwise. + const std::string& identifier() const { return identifier_; } + // Returns this group's name, or the filename without extension if the name // is empty. string16 GetGroupName() const; @@ -129,7 +138,8 @@ class PluginGroup { const std::string& version_range_low, const std::string& version_range_high, const std::string& min_version, - const std::string& update_url); + const std::string& update_url, + const std::string& identifier); Version* CreateVersionFromString(const string16& version_string); @@ -143,6 +153,7 @@ class PluginGroup { static std::set<string16>* policy_disabled_plugin_patterns_; + std::string identifier_; string16 group_name_; string16 name_matcher_; std::string version_range_low_str_; diff --git a/chrome/common/plugin_group_unittest.cc b/chrome/common/plugin_group_unittest.cc index 7bef7d2..a42cbaf 100644 --- a/chrome/common/plugin_group_unittest.cc +++ b/chrome/common/plugin_group_unittest.cc @@ -16,13 +16,13 @@ #include "webkit/glue/plugins/webplugininfo.h" static const PluginGroupDefinition kPluginDef = { - "MyPlugin", "MyPlugin", "", "", "3.0.44", "http://latest/" }; + "myplugin", "MyPlugin", "MyPlugin", "", "", "3.0.44", "http://latest/" }; static const PluginGroupDefinition kPluginDef3 = { - "MyPlugin 3", "MyPlugin", "0", "4", "3.0.44", "http://latest" }; + "myplugin-3", "MyPlugin 3", "MyPlugin", "0", "4", "3.0.44", "http://latest" }; static const PluginGroupDefinition kPluginDef4 = { - "MyPlugin 4", "MyPlugin", "4", "5", "4.0.44", "http://latest" }; + "myplugin-4", "MyPlugin 4", "MyPlugin", "4", "5", "4.0.44", "http://latest" }; static const PluginGroupDefinition kPluginDefNotVulnerable = { - "MyPlugin", "MyPlugin", "", "", "", "http://latest" }; + "myplugin-latest", "MyPlugin", "MyPlugin", "", "", "", "http://latest" }; // name, path, version, desc, mime_types, enabled. static WebPluginInfo kPlugin2043 = { |