| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 
| 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include <map> | 9 #include <map> | 
| 10 #include <set> | 10 #include <set> | 
| 11 #include <string> | 11 #include <string> | 
| 12 #include <vector> | 12 #include <vector> | 
| 13 | 13 | 
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" | 
| 15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" | 
| 16 #include "base/string16.h" | 16 #include "base/string16.h" | 
| 17 | 17 | 
| 18 class DictionaryValue; | 18 class DictionaryValue; | 
| 19 class FilePath; | 19 class FilePath; | 
| 20 class Version; | 20 class Version; | 
| 21 struct WebPluginInfo; | 21 struct WebPluginInfo; | 
| 22 | 22 | 
| 23 namespace NPAPI { | 23 namespace NPAPI { | 
| 24   class PluginList; | 24 class PluginList; | 
| 25 }; | 25 }; | 
| 26 namespace plugin_test_internal { | 26 | 
| 27 class PluginExceptionsTableModelTest; | 27 // Hard-coded version ranges for plugin groups. | 
| 28 } | 28 struct VersionRangeDefinition { | 
|  | 29   // Matcher for lowest version matched by this range (inclusive). May be empty | 
|  | 30   // to match everything iff |version_matcher_high| is also empty. | 
|  | 31   const char* version_matcher_low; | 
|  | 32   // Matcher for highest version matched by this range (exclusive). May be empty | 
|  | 33   // to match anything higher than |version_matcher_low|. | 
|  | 34   const char* version_matcher_high; | 
|  | 35   const char* min_version;  // Minimum secure version. | 
|  | 36 }; | 
| 29 | 37 | 
| 30 // Hard-coded definitions of plugin groups. | 38 // Hard-coded definitions of plugin groups. | 
| 31 struct PluginGroupDefinition { | 39 struct PluginGroupDefinition { | 
| 32   const char* identifier;  // Unique identifier for this group. | 40   const char* identifier;  // Unique identifier for this group. | 
| 33   const char* name;  // Name of this group. | 41   const char* name;  // Name of this group. | 
| 34   const char* name_matcher;  // Substring matcher for the plugin name. | 42   const char* name_matcher;  // Substring matcher for the plugin name. | 
| 35   const char* version_matcher_low;  // Matchers for the plugin version. | 43   const VersionRangeDefinition* versions;  // List of version ranges. | 
| 36   const char* version_matcher_high; | 44   const size_t num_versions;  // Size of the array |versions| points to. | 
| 37   const char* min_version;  // Minimum secure version. |  | 
| 38   const char* update_url;  // Location of latest secure version. | 45   const char* update_url;  // Location of latest secure version. | 
| 39 }; | 46 }; | 
| 40 | 47 | 
|  | 48 // Run-time structure to hold version range information. | 
|  | 49 struct VersionRange { | 
|  | 50  public: | 
|  | 51   explicit VersionRange(VersionRangeDefinition definition); | 
|  | 52   VersionRange(const VersionRange& other); | 
|  | 53   VersionRange& operator=(const VersionRange& other); | 
|  | 54 | 
|  | 55   std::string low_str; | 
|  | 56   std::string high_str; | 
|  | 57   std::string min_str; | 
|  | 58   scoped_ptr<Version> low; | 
|  | 59   scoped_ptr<Version> high; | 
|  | 60   scoped_ptr<Version> min; | 
|  | 61  private: | 
|  | 62   void InitFrom(const VersionRange& other); | 
|  | 63 }; | 
|  | 64 | 
| 41 // A PluginGroup can match a range of versions of a specific plugin (as defined | 65 // A PluginGroup can match a range of versions of a specific plugin (as defined | 
| 42 // by matching a substring of its name). | 66 // by matching a substring of its name). | 
| 43 // It contains all WebPluginInfo structs (at least one) matching its definition. | 67 // It contains all WebPluginInfo structs (at least one) matching its definition. | 
| 44 // In addition, it knows about a security "baseline", i.e. the minimum version | 68 // In addition, it knows about a security "baseline", i.e. the minimum version | 
| 45 // of a plugin that is needed in order not to exhibit known security | 69 // of a plugin that is needed in order not to exhibit known security | 
| 46 // vulnerabilities. | 70 // vulnerabilities. | 
| 47 | 71 | 
| 48 class PluginGroup { | 72 class PluginGroup { | 
| 49  public: | 73  public: | 
| 50   // Used by about:plugins to disable Reader plugin when internal PDF viewer is | 74   // Used by about:plugins to disable Reader plugin when internal PDF viewer is | 
| 51   // enabled. | 75   // enabled. | 
| 52   static const char* kAdobeReader8GroupName; | 76   static const char* kAdobeReaderGroupName; | 
| 53   static const char* kAdobeReader9GroupName; |  | 
| 54 | 77 | 
| 55   PluginGroup(const PluginGroup& other); | 78   PluginGroup(const PluginGroup& other); | 
| 56 | 79 | 
| 57   ~PluginGroup(); | 80   ~PluginGroup(); | 
| 58 | 81 | 
| 59   PluginGroup& operator=(const PluginGroup& other); | 82   PluginGroup& operator=(const PluginGroup& other); | 
| 60 | 83 | 
| 61   // Configures the set of plugin name patterns for disabling plugins via | 84   // Configures the set of plugin name patterns for disabling plugins via | 
| 62   // enterprise configuration management. | 85   // enterprise configuration management. | 
| 63   static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set); | 86   static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111   // Disables all plugins in this group that are older than the | 134   // Disables all plugins in this group that are older than the | 
| 112   // minimum version. | 135   // minimum version. | 
| 113   void DisableOutdatedPlugins(); | 136   void DisableOutdatedPlugins(); | 
| 114 | 137 | 
| 115  private: | 138  private: | 
| 116   typedef std::map<std::string, PluginGroup*> PluginMap; | 139   typedef std::map<std::string, PluginGroup*> PluginMap; | 
| 117 | 140 | 
| 118   friend class NPAPI::PluginList; | 141   friend class NPAPI::PluginList; | 
| 119   friend class PluginGroupTest; | 142   friend class PluginGroupTest; | 
| 120   friend class TableModelArrayControllerTest; | 143   friend class TableModelArrayControllerTest; | 
| 121   friend class plugin_test_internal::PluginExceptionsTableModelTest; | 144   friend class PluginExceptionsTableModelTest; | 
| 122 | 145 | 
| 123   // Generates the (short) identifier string for the given plugin. | 146   // Generates the (short) identifier string for the given plugin. | 
| 124   static std::string GetIdentifier(const WebPluginInfo& wpi); | 147   static std::string GetIdentifier(const WebPluginInfo& wpi); | 
| 125 | 148 | 
| 126   // Generates the long identifier (based on the full file path) for the given | 149   // Generates the long identifier (based on the full file path) for the given | 
| 127   // plugin, to be called when the short identifier is not unique. | 150   // plugin, to be called when the short identifier is not unique. | 
| 128   static std::string GetLongIdentifier(const WebPluginInfo& wpi); | 151   static std::string GetLongIdentifier(const WebPluginInfo& wpi); | 
| 129 | 152 | 
| 130   // Creates a PluginGroup from a PluginGroupDefinition. The caller takes | 153   // Creates a PluginGroup from a PluginGroupDefinition. The caller takes | 
| 131   // ownership of the created PluginGroup. | 154   // ownership of the created PluginGroup. | 
| 132   static PluginGroup* FromPluginGroupDefinition( | 155   static PluginGroup* FromPluginGroupDefinition( | 
| 133       const PluginGroupDefinition& definition); | 156       const PluginGroupDefinition& definition); | 
| 134 | 157 | 
| 135   // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of | 158   // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of | 
| 136   // the created PluginGroup. | 159   // the created PluginGroup. | 
| 137   static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); | 160   static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); | 
| 138 | 161 | 
|  | 162   // Returns |true| if |version| is contained in [low, high) of |range|. | 
|  | 163   static bool IsVersionInRange(const Version& version, | 
|  | 164                                const VersionRange& range); | 
|  | 165 | 
|  | 166   // Returns |true| iff |plugin_version| is both contained in |version_range| | 
|  | 167   // and declared outdated (== vulnerable) by it. | 
|  | 168   static bool IsPluginOutdated(const Version& plugin_version, | 
|  | 169                                const VersionRange& version_range); | 
|  | 170 | 
| 139   PluginGroup(const string16& group_name, | 171   PluginGroup(const string16& group_name, | 
| 140               const string16& name_matcher, | 172               const string16& name_matcher, | 
| 141               const std::string& version_range_low, |  | 
| 142               const std::string& version_range_high, |  | 
| 143               const std::string& min_version, |  | 
| 144               const std::string& update_url, | 173               const std::string& update_url, | 
| 145               const std::string& identifier); | 174               const std::string& identifier); | 
| 146 | 175 | 
| 147   void InitFrom(const PluginGroup& other); | 176   void InitFrom(const PluginGroup& other); | 
| 148 | 177 | 
| 149   Version* CreateVersionFromString(const string16& version_string); | 178   Version* CreateVersionFromString(const string16& version_string); | 
| 150 | 179 | 
| 151   // Set the description and version for this plugin group from the | 180   // Set the description and version for this plugin group from the | 
| 152   // given plug-in. | 181   // given plug-in. | 
| 153   void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); | 182   void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); | 
| 154 | 183 | 
| 155   // Updates the active plugin in the group. The active plugin is the first | 184   // Updates the active plugin in the group. The active plugin is the first | 
| 156   // enabled one, or if all plugins are disabled, simply the first one. | 185   // enabled one, or if all plugins are disabled, simply the first one. | 
| 157   void UpdateActivePlugin(const WebPluginInfo& plugin); | 186   void UpdateActivePlugin(const WebPluginInfo& plugin); | 
| 158 | 187 | 
| 159   static std::set<string16>* policy_disabled_plugin_patterns_; | 188   static std::set<string16>* policy_disabled_plugin_patterns_; | 
| 160 | 189 | 
| 161   std::string identifier_; | 190   std::string identifier_; | 
| 162   string16 group_name_; | 191   string16 group_name_; | 
| 163   string16 name_matcher_; | 192   string16 name_matcher_; | 
| 164   std::string version_range_low_str_; |  | 
| 165   std::string version_range_high_str_; |  | 
| 166   scoped_ptr<Version> version_range_low_; |  | 
| 167   scoped_ptr<Version> version_range_high_; |  | 
| 168   string16 description_; | 193   string16 description_; | 
| 169   std::string update_url_; | 194   std::string update_url_; | 
| 170   bool enabled_; | 195   bool enabled_; | 
| 171   std::string min_version_str_; | 196   std::vector<VersionRange> version_ranges_; | 
| 172   scoped_ptr<Version> min_version_; |  | 
| 173   scoped_ptr<Version> version_; | 197   scoped_ptr<Version> version_; | 
| 174   std::vector<WebPluginInfo> web_plugin_infos_; | 198   std::vector<WebPluginInfo> web_plugin_infos_; | 
| 175   std::vector<int> web_plugin_positions_; | 199   std::vector<int> web_plugin_positions_; | 
| 176 }; | 200 }; | 
| 177 | 201 | 
| 178 #endif  // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 202 #endif  // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 
| OLD | NEW | 
|---|