OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PLUGINS_NPAPI_PLUGIN_GROUP_H_ | 5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ |
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ | 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
(...skipping 15 matching lines...) Expand all Loading... |
27 | 27 |
28 // Hard-coded version ranges for plugin groups. | 28 // Hard-coded version ranges for plugin groups. |
29 struct VersionRangeDefinition { | 29 struct VersionRangeDefinition { |
30 // Matcher for lowest version matched by this range (inclusive). May be empty | 30 // Matcher for lowest version matched by this range (inclusive). May be empty |
31 // to match everything iff |version_matcher_high| is also empty. | 31 // to match everything iff |version_matcher_high| is also empty. |
32 const char* version_matcher_low; | 32 const char* version_matcher_low; |
33 // Matcher for highest version matched by this range (exclusive). May be empty | 33 // Matcher for highest version matched by this range (exclusive). May be empty |
34 // to match anything higher than |version_matcher_low|. | 34 // to match anything higher than |version_matcher_low|. |
35 const char* version_matcher_high; | 35 const char* version_matcher_high; |
36 const char* min_version; // Minimum secure version. | 36 const char* min_version; // Minimum secure version. |
37 bool requires_authorization; // If this range needs user permission to run. | |
38 }; | 37 }; |
39 | 38 |
40 // Hard-coded definitions of plugin groups. | 39 // Hard-coded definitions of plugin groups. |
41 struct PluginGroupDefinition { | 40 struct PluginGroupDefinition { |
42 const char* identifier; // Unique identifier for this group. | 41 // Unique identifier for this group. |
43 const char* name; // Name of this group. | 42 const char* identifier; |
44 const char* name_matcher; // Substring matcher for the plugin name. | 43 // Name of this group. |
45 const VersionRangeDefinition* versions; // List of version ranges. | 44 const char* name; |
46 size_t num_versions; // Size of the array |versions| points to. | 45 // Substring matcher for the plugin name. |
47 const char* update_url; // Location of latest secure version. | 46 const char* name_matcher; |
| 47 // List of version ranges. |
| 48 const VersionRangeDefinition* versions; |
| 49 // Size of the array |versions| points to. |
| 50 size_t num_versions; |
48 }; | 51 }; |
49 | 52 |
50 // Run-time structure to hold version range information. | 53 // Run-time structure to hold version range information. |
51 struct VersionRange { | 54 struct VersionRange { |
52 public: | 55 public: |
53 explicit VersionRange(const VersionRangeDefinition& definition); | 56 explicit VersionRange(const VersionRangeDefinition& definition); |
54 VersionRange(const VersionRange& other); | 57 VersionRange(const VersionRange& other); |
55 VersionRange& operator=(const VersionRange& other); | 58 VersionRange& operator=(const VersionRange& other); |
56 ~VersionRange(); | 59 ~VersionRange(); |
57 | 60 |
58 std::string low_str; | 61 std::string low_str; |
59 std::string high_str; | 62 std::string high_str; |
60 std::string min_str; | 63 std::string min_str; |
61 scoped_ptr<Version> low; | 64 scoped_ptr<Version> low; |
62 scoped_ptr<Version> high; | 65 scoped_ptr<Version> high; |
63 scoped_ptr<Version> min; | 66 scoped_ptr<Version> min; |
64 bool requires_authorization; | |
65 private: | 67 private: |
66 void InitFrom(const VersionRange& other); | 68 void InitFrom(const VersionRange& other); |
67 }; | 69 }; |
68 | 70 |
69 // A PluginGroup can match a range of versions of a specific plugin (as defined | 71 // A PluginGroup can match a range of versions of a specific plugin (as defined |
70 // by matching a substring of its name). | 72 // by matching a substring of its name). |
71 // It contains all WebPluginInfo structs (at least one) matching its definition. | 73 // It contains all WebPluginInfo structs (at least one) matching its definition. |
72 // In addition, it knows about a security "baseline", i.e. the minimum version | 74 // In addition, it knows about a security "baseline", i.e. the minimum version |
73 // of a plugin that is needed in order not to exhibit known security | 75 // of a plugin that is needed in order not to exhibit known security |
74 // vulnerabilities. | 76 // vulnerabilities. |
75 | 77 |
76 class WEBKIT_PLUGINS_EXPORT PluginGroup { | 78 class WEBKIT_PLUGINS_EXPORT PluginGroup { |
77 public: | 79 public: |
78 // Used by about:plugins to disable Reader plugin when internal PDF viewer is | 80 // Used by about:plugins to disable Reader plugin when internal PDF viewer is |
79 // enabled. | 81 // enabled. |
80 static const char kAdobeReaderGroupName[]; | 82 static const char kAdobeReaderGroupName[]; |
81 static const char kAdobeReaderUpdateURL[]; | |
82 static const char kJavaGroupName[]; | 83 static const char kJavaGroupName[]; |
83 static const char kQuickTimeGroupName[]; | 84 static const char kQuickTimeGroupName[]; |
84 static const char kShockwaveGroupName[]; | 85 static const char kShockwaveGroupName[]; |
85 static const char kRealPlayerGroupName[]; | 86 static const char kRealPlayerGroupName[]; |
86 static const char kSilverlightGroupName[]; | 87 static const char kSilverlightGroupName[]; |
87 static const char kWindowsMediaPlayerGroupName[]; | 88 static const char kWindowsMediaPlayerGroupName[]; |
88 | 89 |
89 PluginGroup(const PluginGroup& other); | 90 PluginGroup(const PluginGroup& other); |
90 | 91 |
91 ~PluginGroup(); | 92 ~PluginGroup(); |
(...skipping 18 matching lines...) Expand all Loading... |
110 identifier_ = identifier; | 111 identifier_ = identifier; |
111 } | 112 } |
112 | 113 |
113 // Returns this group's name, or the filename without extension if the name | 114 // Returns this group's name, or the filename without extension if the name |
114 // is empty. | 115 // is empty. |
115 string16 GetGroupName() const; | 116 string16 GetGroupName() const; |
116 | 117 |
117 // Checks whether a plugin exists in the group with the given path. | 118 // Checks whether a plugin exists in the group with the given path. |
118 bool ContainsPlugin(const FilePath& path) const; | 119 bool ContainsPlugin(const FilePath& path) const; |
119 | 120 |
120 // Returns the update URL. | |
121 std::string GetUpdateURL() const { return update_url_; } | |
122 | |
123 // Returns true if this plugin group is whitelisted. | |
124 bool IsWhitelisted() const; | |
125 | |
126 // Returns true if |plugin| in this group has known security problems. | 121 // Returns true if |plugin| in this group has known security problems. |
127 bool IsVulnerable(const WebPluginInfo& plugin) const; | 122 bool IsVulnerable(const WebPluginInfo& plugin) const; |
128 | 123 |
129 // Returns true if |plugin| in this plug-in group always requires user | |
130 // authorization to run. | |
131 bool RequiresAuthorization(const WebPluginInfo& plugin) const; | |
132 | |
133 // Check if the group has no plugins. Could happen after a reload if the plug- | 124 // Check if the group has no plugins. Could happen after a reload if the plug- |
134 // in has disappeared from the pc (or in the process of updating). | 125 // in has disappeared from the pc (or in the process of updating). |
135 bool IsEmpty() const; | 126 bool IsEmpty() const; |
136 | 127 |
137 // Parse a version string as used by a plug-in. This method is more lenient | 128 // Parse a version string as used by a plug-in. This method is more lenient |
138 // in accepting weird version strings than Version::GetFromString(). | 129 // in accepting weird version strings than Version::GetFromString(). |
139 static Version* CreateVersionFromString(const string16& version_string); | 130 static Version* CreateVersionFromString(const string16& version_string); |
140 | 131 |
141 const std::vector<webkit::WebPluginInfo>& web_plugin_infos() const { | 132 const std::vector<webkit::WebPluginInfo>& web_plugin_infos() const { |
142 return web_plugin_infos_; | 133 return web_plugin_infos_; |
143 } | 134 } |
144 | 135 |
145 private: | 136 private: |
146 friend class PluginList; | |
147 friend class MockPluginList; | 137 friend class MockPluginList; |
148 friend class PluginGroupTest; | 138 friend class PluginGroupTest; |
| 139 friend class PluginList; |
149 friend class ::PluginExceptionsTableModelTest; | 140 friend class ::PluginExceptionsTableModelTest; |
150 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated); | 141 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated); |
151 | 142 |
152 // Generates the (short) identifier string for the given plugin. | 143 // Generates the (short) identifier string for the given plugin. |
153 static std::string GetIdentifier(const webkit::WebPluginInfo& wpi); | 144 static std::string GetIdentifier(const webkit::WebPluginInfo& wpi); |
154 | 145 |
155 // Generates the long identifier (based on the full file path) for the given | 146 // Generates the long identifier (based on the full file path) for the given |
156 // plugin, to be called when the short identifier is not unique. | 147 // plugin, to be called when the short identifier is not unique. |
157 static std::string GetLongIdentifier(const webkit::WebPluginInfo& wpi); | 148 static std::string GetLongIdentifier(const webkit::WebPluginInfo& wpi); |
158 | 149 |
(...skipping 10 matching lines...) Expand all Loading... |
169 static bool IsVersionInRange(const Version& version, | 160 static bool IsVersionInRange(const Version& version, |
170 const VersionRange& range); | 161 const VersionRange& range); |
171 | 162 |
172 // Returns |true| iff |plugin_version| is both contained in |version_range| | 163 // Returns |true| iff |plugin_version| is both contained in |version_range| |
173 // and declared outdated (== vulnerable) by it. | 164 // and declared outdated (== vulnerable) by it. |
174 static bool IsPluginOutdated(const Version& plugin_version, | 165 static bool IsPluginOutdated(const Version& plugin_version, |
175 const VersionRange& version_range); | 166 const VersionRange& version_range); |
176 | 167 |
177 PluginGroup(const string16& group_name, | 168 PluginGroup(const string16& group_name, |
178 const string16& name_matcher, | 169 const string16& name_matcher, |
179 const std::string& update_url, | |
180 const std::string& identifier); | 170 const std::string& identifier); |
181 | 171 |
182 void InitFrom(const PluginGroup& other); | 172 void InitFrom(const PluginGroup& other); |
183 | 173 |
184 // Returns a non-const vector of all plugins in the group. This is only used | 174 // Returns a non-const vector of all plugins in the group. This is only used |
185 // by PluginList. | 175 // by PluginList. |
186 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() { | 176 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() { |
187 return web_plugin_infos_; | 177 return web_plugin_infos_; |
188 } | 178 } |
189 | 179 |
190 std::string identifier_; | 180 std::string identifier_; |
191 string16 group_name_; | 181 string16 group_name_; |
192 string16 name_matcher_; | 182 string16 name_matcher_; |
193 std::string update_url_; | |
194 std::vector<VersionRange> version_ranges_; | 183 std::vector<VersionRange> version_ranges_; |
195 std::vector<webkit::WebPluginInfo> web_plugin_infos_; | 184 std::vector<webkit::WebPluginInfo> web_plugin_infos_; |
196 }; | 185 }; |
197 | 186 |
198 } // namespace npapi | 187 } // namespace npapi |
199 } // namespace webkit | 188 } // namespace webkit |
200 | 189 |
201 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ | 190 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ |
OLD | NEW |