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 namespace plugin_test_internal { |
27 class PluginExceptionsTableModelTest; | 27 class PluginExceptionsTableModelTest; |
28 class PluginGroupTest; | |
29 class TableModelArrayControllerTest; | |
28 } | 30 } |
29 | 31 |
32 // Hard-coded version ranges for plugin groups. | |
33 struct VersionRangeDefinition { | |
34 // Matcher for lowest version matched by this range (inclusive). May be empty | |
35 // to match everything iff |version_matcher_high| is also empty. | |
36 const char* version_matcher_low; | |
37 // Matcher for highest version matched by this range (exclusive). May be empty | |
38 // to match anything higher than |version_matcher_low|. | |
39 const char* version_matcher_high; | |
40 const char* min_version; // Minimum secure version. | |
41 }; | |
42 | |
30 // Hard-coded definitions of plugin groups. | 43 // Hard-coded definitions of plugin groups. |
31 struct PluginGroupDefinition { | 44 struct PluginGroupDefinition { |
32 const char* identifier; // Unique identifier for this group. | 45 const char* identifier; // Unique identifier for this group. |
33 const char* name; // Name of this group. | 46 const char* name; // Name of this group. |
34 const char* name_matcher; // Substring matcher for the plugin name. | 47 const char* name_matcher; // Substring matcher for the plugin name. |
35 const char* version_matcher_low; // Matchers for the plugin version. | 48 const VersionRangeDefinition* versions; // List of version ranges. |
36 const char* version_matcher_high; | 49 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. | 50 const char* update_url; // Location of latest secure version. |
39 }; | 51 }; |
40 | 52 |
53 // Run-time structure to hold version range information. | |
54 struct VersionRange { | |
55 public: | |
56 explicit VersionRange(VersionRangeDefinition definition); | |
57 VersionRange(const VersionRange& other); | |
58 VersionRange& operator=(const VersionRange& other); | |
59 | |
60 std::string low_str; | |
61 std::string high_str; | |
62 std::string min_str; | |
63 scoped_ptr<Version> low; | |
64 scoped_ptr<Version> high; | |
65 scoped_ptr<Version> min; | |
66 private: | |
67 void InitFrom(const VersionRange& other); | |
68 }; | |
69 | |
41 // A PluginGroup can match a range of versions of a specific plugin (as defined | 70 // A PluginGroup can match a range of versions of a specific plugin (as defined |
42 // by matching a substring of its name). | 71 // by matching a substring of its name). |
43 // It contains all WebPluginInfo structs (at least one) matching its definition. | 72 // 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 | 73 // 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 | 74 // of a plugin that is needed in order not to exhibit known security |
46 // vulnerabilities. | 75 // vulnerabilities. |
47 | 76 |
48 class PluginGroup { | 77 class PluginGroup { |
49 public: | 78 public: |
50 // Used by about:plugins to disable Reader plugin when internal PDF viewer is | 79 // Used by about:plugins to disable Reader plugin when internal PDF viewer is |
51 // enabled. | 80 // enabled. |
52 static const char* kAdobeReader8GroupName; | 81 static const char* kAdobeReaderGroupName; |
53 static const char* kAdobeReader9GroupName; | |
54 | 82 |
55 PluginGroup(const PluginGroup& other); | 83 PluginGroup(const PluginGroup& other); |
56 | 84 |
57 ~PluginGroup(); | 85 ~PluginGroup(); |
58 | 86 |
59 PluginGroup& operator=(const PluginGroup& other); | 87 PluginGroup& operator=(const PluginGroup& other); |
60 | 88 |
61 // Configures the set of plugin name patterns for disabling plugins via | 89 // Configures the set of plugin name patterns for disabling plugins via |
62 // enterprise configuration management. | 90 // enterprise configuration management. |
63 static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set); | 91 static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 bool IsVulnerable() const; | 137 bool IsVulnerable() const; |
110 | 138 |
111 // Disables all plugins in this group that are older than the | 139 // Disables all plugins in this group that are older than the |
112 // minimum version. | 140 // minimum version. |
113 void DisableOutdatedPlugins(); | 141 void DisableOutdatedPlugins(); |
114 | 142 |
115 private: | 143 private: |
116 typedef std::map<std::string, PluginGroup*> PluginMap; | 144 typedef std::map<std::string, PluginGroup*> PluginMap; |
117 | 145 |
118 friend class NPAPI::PluginList; | 146 friend class NPAPI::PluginList; |
119 friend class PluginGroupTest; | 147 friend class plugin_test_internal::PluginGroupTest; |
120 friend class TableModelArrayControllerTest; | 148 friend class plugin_test_internal::TableModelArrayControllerTest; |
121 friend class plugin_test_internal::PluginExceptionsTableModelTest; | 149 friend class plugin_test_internal::PluginExceptionsTableModelTest; |
122 | 150 |
123 // Generates the (short) identifier string for the given plugin. | 151 // Generates the (short) identifier string for the given plugin. |
124 static std::string GetIdentifier(const WebPluginInfo& wpi); | 152 static std::string GetIdentifier(const WebPluginInfo& wpi); |
125 | 153 |
126 // Generates the long identifier (based on the full file path) for the given | 154 // 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. | 155 // plugin, to be called when the short identifier is not unique. |
128 static std::string GetLongIdentifier(const WebPluginInfo& wpi); | 156 static std::string GetLongIdentifier(const WebPluginInfo& wpi); |
129 | 157 |
130 // Creates a PluginGroup from a PluginGroupDefinition. The caller takes | 158 // Creates a PluginGroup from a PluginGroupDefinition. The caller takes |
131 // ownership of the created PluginGroup. | 159 // ownership of the created PluginGroup. |
132 static PluginGroup* FromPluginGroupDefinition( | 160 static PluginGroup* FromPluginGroupDefinition( |
133 const PluginGroupDefinition& definition); | 161 const PluginGroupDefinition& definition); |
134 | 162 |
135 // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of | 163 // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of |
136 // the created PluginGroup. | 164 // the created PluginGroup. |
137 static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); | 165 static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); |
138 | 166 |
167 static bool IsPluginOutdated(const Version& plugin_version, | |
Bernhard Bauer
2010/12/08 13:36:30
Can you add a comment explaining the semantics of
Jakob Kummerow
2010/12/09 08:58:17
Done.
| |
168 const VersionRange& version_range); | |
169 | |
139 PluginGroup(const string16& group_name, | 170 PluginGroup(const string16& group_name, |
140 const string16& name_matcher, | 171 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, | 172 const std::string& update_url, |
145 const std::string& identifier); | 173 const std::string& identifier); |
146 | 174 |
147 void InitFrom(const PluginGroup& other); | 175 void InitFrom(const PluginGroup& other); |
148 | 176 |
149 Version* CreateVersionFromString(const string16& version_string); | 177 Version* CreateVersionFromString(const string16& version_string); |
150 | 178 |
151 // Set the description and version for this plugin group from the | 179 // Set the description and version for this plugin group from the |
152 // given plug-in. | 180 // given plug-in. |
153 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); | 181 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); |
154 | 182 |
155 // Updates the active plugin in the group. The active plugin is the first | 183 // 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. | 184 // enabled one, or if all plugins are disabled, simply the first one. |
157 void UpdateActivePlugin(const WebPluginInfo& plugin); | 185 void UpdateActivePlugin(const WebPluginInfo& plugin); |
158 | 186 |
159 static std::set<string16>* policy_disabled_plugin_patterns_; | 187 static std::set<string16>* policy_disabled_plugin_patterns_; |
160 | 188 |
161 std::string identifier_; | 189 std::string identifier_; |
162 string16 group_name_; | 190 string16 group_name_; |
163 string16 name_matcher_; | 191 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_; | 192 string16 description_; |
169 std::string update_url_; | 193 std::string update_url_; |
170 bool enabled_; | 194 bool enabled_; |
171 std::string min_version_str_; | 195 std::vector<VersionRange> version_ranges_; |
172 scoped_ptr<Version> min_version_; | |
173 scoped_ptr<Version> version_; | 196 scoped_ptr<Version> version_; |
174 std::vector<WebPluginInfo> web_plugin_infos_; | 197 std::vector<WebPluginInfo> web_plugin_infos_; |
175 std::vector<int> web_plugin_positions_; | 198 std::vector<int> web_plugin_positions_; |
176 }; | 199 }; |
177 | 200 |
178 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 201 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ |
OLD | NEW |