OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_PLUGIN_GROUP_H_ |
| 6 #define CHROME_COMMON_PLUGIN_GROUP_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/linked_ptr.h" |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "base/string16.h" |
| 13 #include "base/version.h" |
| 14 #include "webkit/glue/plugins/webplugininfo.h" |
| 15 |
| 16 class DictionaryValue; |
| 17 |
| 18 // Hard-coded definitions of plugin groups. |
| 19 struct PluginGroupDefinition { |
| 20 const char* name; // Name of this group. |
| 21 const char* name_matcher; // Substring matcher for the plugin name. |
| 22 const char* version_matcher_low; // Matchers for the plugin version. |
| 23 const char* version_matcher_high; |
| 24 const char* min_version; // Minimum secure version. |
| 25 const char* update_url; // Location of latest secure version. |
| 26 }; |
| 27 |
| 28 |
| 29 // A PluginGroup contains at least one WebPluginInfo. |
| 30 // In addition, it knows if the plugin is critically vulnerable. |
| 31 class PluginGroup { |
| 32 public: |
| 33 // Creates a PluginGroup from a PluginGroupDefinition. |
| 34 static PluginGroup* FromPluginGroupDefinition( |
| 35 const PluginGroupDefinition& definition); |
| 36 |
| 37 // Creates a PluginGroup from a WebPluginInfo -- when no hard-coded |
| 38 // definition is found. |
| 39 static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); |
| 40 |
| 41 // Find a plugin group matching |info| in the list of hardcoded plugins. |
| 42 static PluginGroup* FindHardcodedPluginGroup(const WebPluginInfo& info); |
| 43 |
| 44 // Find the PluginGroup matching a Plugin in a list of plugin groups. Returns |
| 45 // NULL if no matching PluginGroup is found. |
| 46 static PluginGroup* FindGroupMatchingPlugin( |
| 47 std::vector<linked_ptr<PluginGroup> >& plugin_groups, |
| 48 const WebPluginInfo& plugin); |
| 49 |
| 50 // Creates a copy of this plugin group. |
| 51 PluginGroup* Copy() { |
| 52 return new PluginGroup(group_name_, name_matcher_, version_range_low_str_, |
| 53 version_range_high_str_, min_version_str_, |
| 54 update_url_); |
| 55 } |
| 56 |
| 57 // Returns true if the given plugin matches this group. |
| 58 bool Match(const WebPluginInfo& plugin) const; |
| 59 |
| 60 // Adds the given plugin to this group. Provide the position of the |
| 61 // plugin as given by PluginList so we can display its priority. |
| 62 void AddPlugin(const WebPluginInfo& plugin, int position); |
| 63 |
| 64 // Enables/disables this group. This enables/disables all plugins in the |
| 65 // group. |
| 66 void Enable(bool enable); |
| 67 |
| 68 // Returns this group's name |
| 69 const string16 GetGroupName() const { return group_name_; } |
| 70 |
| 71 // Returns a DictionaryValue with data to display in the UI. |
| 72 DictionaryValue* GetDataForUI() const; |
| 73 |
| 74 // Returns a DictionaryValue with data to save in the preferences. |
| 75 DictionaryValue* GetSummary() const; |
| 76 |
| 77 // Returns the update URL. |
| 78 std::string GetUpdateURL() const { return update_url_; } |
| 79 |
| 80 // Returns true if the latest plugin in this group has known |
| 81 // security problems. |
| 82 bool IsVulnerable() const; |
| 83 |
| 84 private: |
| 85 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); |
| 86 |
| 87 static const PluginGroupDefinition* GetPluginGroupDefinitions(); |
| 88 static size_t GetPluginGroupDefinitionsSize(); |
| 89 |
| 90 PluginGroup(const string16& group_name, |
| 91 const string16& name_matcher, |
| 92 const std::string& version_range_low, |
| 93 const std::string& version_range_high, |
| 94 const std::string& min_version, |
| 95 const std::string& update_url); |
| 96 |
| 97 string16 group_name_; |
| 98 string16 name_matcher_; |
| 99 std::string version_range_low_str_; |
| 100 std::string version_range_high_str_; |
| 101 scoped_ptr<Version> version_range_low_; |
| 102 scoped_ptr<Version> version_range_high_; |
| 103 string16 description_; |
| 104 std::string update_url_; |
| 105 bool enabled_; |
| 106 std::string min_version_str_; |
| 107 scoped_ptr<Version> min_version_; |
| 108 scoped_ptr<Version> max_version_; |
| 109 std::vector<WebPluginInfo> web_plugin_infos_; |
| 110 std::vector<int> web_plugin_positions_; |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(PluginGroup); |
| 113 }; |
| 114 |
| 115 #endif // CHROME_COMMON_PLUGIN_GROUP_H_ |
OLD | NEW |