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 <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 | 18 |
19 class DictionaryValue; | 19 class DictionaryValue; |
20 class FilePath; | 20 class FilePath; |
21 class Version; | 21 class Version; |
22 struct WebPluginInfo; | 22 struct WebPluginInfo; |
23 | 23 |
24 namespace NPAPI { | 24 namespace NPAPI { |
25 class PluginList; | 25 class PluginList; |
26 }; | 26 }; |
| 27 namespace plugin_test_internal { |
| 28 class PluginListWithoutFileIO; |
| 29 } |
27 | 30 |
28 // Hard-coded version ranges for plugin groups. | 31 // Hard-coded version ranges for plugin groups. |
29 struct VersionRangeDefinition { | 32 struct VersionRangeDefinition { |
30 // Matcher for lowest version matched by this range (inclusive). May be empty | 33 // Matcher for lowest version matched by this range (inclusive). May be empty |
31 // to match everything iff |version_matcher_high| is also empty. | 34 // to match everything iff |version_matcher_high| is also empty. |
32 const char* version_matcher_low; | 35 const char* version_matcher_low; |
33 // Matcher for highest version matched by this range (exclusive). May be empty | 36 // Matcher for highest version matched by this range (exclusive). May be empty |
34 // to match anything higher than |version_matcher_low|. | 37 // to match anything higher than |version_matcher_low|. |
35 const char* version_matcher_high; | 38 const char* version_matcher_high; |
36 const char* min_version; // Minimum secure version. | 39 const char* min_version; // Minimum secure version. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 int position, | 108 int position, |
106 WebPluginInfo** group_plugin_copy); | 109 WebPluginInfo** group_plugin_copy); |
107 | 110 |
108 // Returns a poitner to the plugin at the end of the |web_plugin_infos_| | 111 // Returns a poitner to the plugin at the end of the |web_plugin_infos_| |
109 // array. | 112 // array. |
110 std::list<WebPluginInfo>& GetPlugins(); | 113 std::list<WebPluginInfo>& GetPlugins(); |
111 | 114 |
112 // Returns the positions of the plugins in the group. | 115 // Returns the positions of the plugins in the group. |
113 std::vector<int>& GetPluginPositions(); | 116 std::vector<int>& GetPluginPositions(); |
114 | 117 |
| 118 bool IsEmpty() const; |
| 119 |
115 // Enables/disables this group. This enables/disables all plugins in the | 120 // Enables/disables this group. This enables/disables all plugins in the |
116 // group. | 121 // group. |
117 void Enable(bool enable); | 122 void Enable(bool enable); |
118 | 123 |
119 // Refreshes the enabled flag based on the state of its plugins. | 124 // Refreshes the enabled flag based on the state of its plugins. |
120 void RefreshEnabledState(); | 125 void RefreshEnabledState(); |
121 | 126 |
122 // Returns whether the plugin group is enabled or not. | 127 // Returns whether the plugin group is enabled or not. |
123 bool Enabled() const { return enabled_; } | 128 bool Enabled() const { return enabled_; } |
124 | 129 |
(...skipping 22 matching lines...) Expand all Loading... |
147 bool IsVulnerable() const; | 152 bool IsVulnerable() const; |
148 | 153 |
149 // Disables all plugins in this group that are older than the | 154 // Disables all plugins in this group that are older than the |
150 // minimum version. | 155 // minimum version. |
151 void DisableOutdatedPlugins(); | 156 void DisableOutdatedPlugins(); |
152 | 157 |
153 private: | 158 private: |
154 typedef std::map<std::string, PluginGroup*> PluginMap; | 159 typedef std::map<std::string, PluginGroup*> PluginMap; |
155 | 160 |
156 friend class NPAPI::PluginList; | 161 friend class NPAPI::PluginList; |
| 162 friend class plugin_test_internal::PluginListWithoutFileIO; |
157 friend class PluginGroupTest; | 163 friend class PluginGroupTest; |
158 friend class TableModelArrayControllerTest; | 164 friend class TableModelArrayControllerTest; |
159 friend class PluginExceptionsTableModelTest; | 165 friend class PluginExceptionsTableModelTest; |
160 | 166 |
161 // Generates the (short) identifier string for the given plugin. | 167 // Generates the (short) identifier string for the given plugin. |
162 static std::string GetIdentifier(const WebPluginInfo& wpi); | 168 static std::string GetIdentifier(const WebPluginInfo& wpi); |
163 | 169 |
164 // Generates the long identifier (based on the full file path) for the given | 170 // Generates the long identifier (based on the full file path) for the given |
165 // plugin, to be called when the short identifier is not unique. | 171 // plugin, to be called when the short identifier is not unique. |
166 static std::string GetLongIdentifier(const WebPluginInfo& wpi); | 172 static std::string GetLongIdentifier(const WebPluginInfo& wpi); |
(...skipping 26 matching lines...) Expand all Loading... |
193 Version* CreateVersionFromString(const string16& version_string); | 199 Version* CreateVersionFromString(const string16& version_string); |
194 | 200 |
195 // Set the description and version for this plugin group from the | 201 // Set the description and version for this plugin group from the |
196 // given plug-in. | 202 // given plug-in. |
197 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); | 203 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); |
198 | 204 |
199 // Updates the active plugin in the group. The active plugin is the first | 205 // Updates the active plugin in the group. The active plugin is the first |
200 // enabled one, or if all plugins are disabled, simply the first one. | 206 // enabled one, or if all plugins are disabled, simply the first one. |
201 void UpdateActivePlugin(const WebPluginInfo& plugin); | 207 void UpdateActivePlugin(const WebPluginInfo& plugin); |
202 | 208 |
| 209 // Used by tests to override the default PluginList singleton. |
| 210 NPAPI::PluginList* GetPluginList() const; |
| 211 void set_plugin_list(NPAPI::PluginList* plugin_list) { |
| 212 plugin_list_ = plugin_list; |
| 213 } |
| 214 |
203 static std::set<string16>* policy_disabled_plugin_patterns_; | 215 static std::set<string16>* policy_disabled_plugin_patterns_; |
204 | 216 |
205 std::string identifier_; | 217 std::string identifier_; |
206 string16 group_name_; | 218 string16 group_name_; |
207 string16 name_matcher_; | 219 string16 name_matcher_; |
208 string16 description_; | 220 string16 description_; |
209 std::string update_url_; | 221 std::string update_url_; |
210 bool enabled_; | 222 bool enabled_; |
211 std::vector<VersionRange> version_ranges_; | 223 std::vector<VersionRange> version_ranges_; |
212 scoped_ptr<Version> version_; | 224 scoped_ptr<Version> version_; |
213 std::list<WebPluginInfo> web_plugin_infos_; | 225 std::list<WebPluginInfo> web_plugin_infos_; |
214 std::vector<int> web_plugin_positions_; | 226 std::vector<int> web_plugin_positions_; |
| 227 NPAPI::PluginList* plugin_list_; |
215 }; | 228 }; |
216 | 229 |
217 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 230 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ |
OLD | NEW |