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_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 <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 #include "webkit/plugins/npapi/webplugininfo.h" | |
17 | 18 |
18 class DictionaryValue; | 19 class DictionaryValue; |
19 class FilePath; | 20 class FilePath; |
20 class TableModelArrayControllerTest; | 21 class TableModelArrayControllerTest; |
21 class PluginExceptionsTableModelTest; | 22 class PluginExceptionsTableModelTest; |
22 class Version; | 23 class Version; |
23 | 24 |
24 namespace webkit { | 25 namespace webkit { |
25 namespace npapi { | 26 namespace npapi { |
26 | 27 |
27 class PluginList; | 28 class PluginList; |
28 struct WebPluginInfo; | 29 namespace plugin_test_internal { |
29 | 30 class PluginListWithoutFileIO; |
31 } | |
30 // Hard-coded version ranges for plugin groups. | 32 // Hard-coded version ranges for plugin groups. |
31 struct VersionRangeDefinition { | 33 struct VersionRangeDefinition { |
32 // Matcher for lowest version matched by this range (inclusive). May be empty | 34 // Matcher for lowest version matched by this range (inclusive). May be empty |
33 // to match everything iff |version_matcher_high| is also empty. | 35 // to match everything iff |version_matcher_high| is also empty. |
34 const char* version_matcher_low; | 36 const char* version_matcher_low; |
35 // Matcher for highest version matched by this range (exclusive). May be empty | 37 // Matcher for highest version matched by this range (exclusive). May be empty |
36 // to match anything higher than |version_matcher_low|. | 38 // to match anything higher than |version_matcher_low|. |
37 const char* version_matcher_high; | 39 const char* version_matcher_high; |
38 const char* min_version; // Minimum secure version. | 40 const char* min_version; // Minimum secure version. |
39 }; | 41 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 PluginGroup& operator=(const PluginGroup& other); | 88 PluginGroup& operator=(const PluginGroup& other); |
87 | 89 |
88 // Configures the set of plugin name patterns for disabling plugins via | 90 // Configures the set of plugin name patterns for disabling plugins via |
89 // enterprise configuration management. | 91 // enterprise configuration management. |
90 static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set); | 92 static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set); |
91 | 93 |
92 // Tests to see if a plugin is on the blacklist using its name as | 94 // Tests to see if a plugin is on the blacklist using its name as |
93 // the lookup key. | 95 // the lookup key. |
94 static bool IsPluginNameDisabledByPolicy(const string16& plugin_name); | 96 static bool IsPluginNameDisabledByPolicy(const string16& plugin_name); |
95 | 97 |
96 // Tests to see if a plugin is on the blacklist using its path as | |
97 // the lookup key. | |
98 static bool IsPluginPathDisabledByPolicy(const FilePath& plugin_path); | |
99 | |
100 // Returns true if the given plugin matches this group. | 98 // Returns true if the given plugin matches this group. |
101 bool Match(const WebPluginInfo& plugin) const; | 99 bool Match(const WebPluginInfo& plugin) const; |
102 | 100 |
103 // Adds the given plugin to this group. Provide the position of the | 101 // Adds the given plugin to this group. |
104 // plugin as given by PluginList so we can display its priority. | 102 // Retuns true if plugin has been added and false if it was already contained |
105 void AddPlugin(const WebPluginInfo& plugin, int position); | 103 // in the group before. |
104 bool AddPlugin(const WebPluginInfo& plugin, int priority); | |
106 | 105 |
107 bool IsEmpty() const; | 106 // Removes a plugin from the group by its path. |
107 bool RemovePlugin(const FilePath& filename); | |
108 | |
109 // The two following functions enable/disable a plugin given its filename. The | |
110 // function returns true if the plugin could be enabled/disabled. Plugins | |
111 // might not get enabled/disabled if they are controlled by policy or are | |
112 // already in the wanted state. | |
113 bool EnablePlugin(const FilePath& filename); | |
114 bool DisablePlugin(const FilePath& filename); | |
108 | 115 |
109 // Enables/disables this group. This enables/disables all plugins in the | 116 // Enables/disables this group. This enables/disables all plugins in the |
110 // group. | 117 // group. |
111 void Enable(bool enable); | 118 bool EnableGroup(bool enable); |
119 | |
120 // Enables/disables this group. This enables/disables all plugins in the | |
jam
2011/01/19 20:22:09
nit: comment is copy and pasted from above
pastarmovj
2011/01/19 23:39:17
Fixed. Sorry about that.
| |
121 // group. | |
122 void EnforceGroupPolicy(); | |
112 | 123 |
113 // Returns whether the plugin group is enabled or not. | 124 // Returns whether the plugin group is enabled or not. |
114 bool Enabled() const { return enabled_; } | 125 bool Enabled() const { return enabled_; } |
115 | 126 |
116 // Returns a unique identifier for this group, if one is defined, or the empty | 127 // Returns a unique identifier for this group, if one is defined, or the empty |
117 // string otherwise. | 128 // string otherwise. |
118 const std::string& identifier() const { return identifier_; } | 129 const std::string& identifier() const { return identifier_; } |
119 | 130 |
120 // Returns this group's name, or the filename without extension if the name | 131 // Returns this group's name, or the filename without extension if the name |
121 // is empty. | 132 // is empty. |
122 string16 GetGroupName() const; | 133 string16 GetGroupName() const; |
123 | 134 |
135 const std::vector<WebPluginInfo>& GetPlugins() const; | |
jam
2011/01/19 20:22:09
simple getters should just be named in unix_hacker
pastarmovj
2011/01/19 23:39:17
Done.
| |
136 | |
137 bool ContainsPlugin(const FilePath& path) const; | |
jam
2011/01/19 20:22:09
nit: small comment to match the rest of the header
pastarmovj
2011/01/19 23:39:17
Done.
| |
138 | |
124 // Returns the description of the highest-priority plug-in in the group. | 139 // Returns the description of the highest-priority plug-in in the group. |
125 const string16& description() const { return description_; } | 140 const string16& description() const { return description_; } |
126 | 141 |
127 // Returns a DictionaryValue with data to display in the UI. | 142 // Returns a DictionaryValue with data to display in the UI. |
128 DictionaryValue* GetDataForUI() const; | 143 DictionaryValue* GetDataForUI() const; |
129 | 144 |
130 // Returns a DictionaryValue with data to save in the preferences. | 145 // Returns a DictionaryValue with data to save in the preferences. |
131 DictionaryValue* GetSummary() const; | 146 DictionaryValue* GetSummary() const; |
132 | 147 |
133 // Returns the update URL. | 148 // Returns the update URL. |
134 std::string GetUpdateURL() const { return update_url_; } | 149 std::string GetUpdateURL() const { return update_url_; } |
135 | 150 |
136 // Returns true if the highest-priority plugin in this group has known | 151 // Returns true if the highest-priority plugin in this group has known |
137 // security problems. | 152 // security problems. |
138 bool IsVulnerable() const; | 153 bool IsVulnerable() const; |
139 | 154 |
155 // Check if the group has no plugins. Could happen after a reload if the plug- | |
156 // in has disappeared from the pc (or in the process of updating). | |
157 bool IsEmpty() const; | |
jam
2011/01/19 20:22:09
this isn't needed anymore right?
pastarmovj
2011/01/19 23:39:17
It is needed only for actually checking which grou
| |
158 | |
140 // Disables all plugins in this group that are older than the | 159 // Disables all plugins in this group that are older than the |
141 // minimum version. | 160 // minimum version. |
142 void DisableOutdatedPlugins(); | 161 void DisableOutdatedPlugins(); |
143 | 162 |
144 // Parse a version string as used by a plug-in. This method is more lenient | 163 // Parse a version string as used by a plug-in. This method is more lenient |
145 // in accepting weird version strings than Version::GetFromString(). | 164 // in accepting weird version strings than Version::GetFromString(). |
146 static Version* CreateVersionFromString(const string16& version_string); | 165 static Version* CreateVersionFromString(const string16& version_string); |
147 | 166 |
148 private: | 167 private: |
149 typedef std::map<std::string, PluginGroup*> PluginMap; | 168 typedef std::map<std::string, PluginGroup*> PluginMap; |
jam
2011/01/19 20:22:09
this typedef isn't used by PluginGroup, so it shou
pastarmovj
2011/01/19 23:39:17
The problem is that we want to differentiate diffe
jam
2011/01/20 00:24:25
I don't understand what you mean. AddToPluginGrou
| |
150 | 169 |
151 friend class PluginList; | 170 friend class PluginList; |
171 friend class plugin_test_internal::PluginListWithoutFileIO; | |
152 friend class PluginGroupTest; | 172 friend class PluginGroupTest; |
153 friend class ::TableModelArrayControllerTest; | 173 friend class ::TableModelArrayControllerTest; |
154 friend class ::PluginExceptionsTableModelTest; | 174 friend class ::PluginExceptionsTableModelTest; |
155 | 175 |
156 // Generates the (short) identifier string for the given plugin. | 176 // Generates the (short) identifier string for the given plugin. |
157 static std::string GetIdentifier(const WebPluginInfo& wpi); | 177 static std::string GetIdentifier(const WebPluginInfo& wpi); |
158 | 178 |
159 // Generates the long identifier (based on the full file path) for the given | 179 // Generates the long identifier (based on the full file path) for the given |
160 // plugin, to be called when the short identifier is not unique. | 180 // plugin, to be called when the short identifier is not unique. |
161 static std::string GetLongIdentifier(const WebPluginInfo& wpi); | 181 static std::string GetLongIdentifier(const WebPluginInfo& wpi); |
(...skipping 24 matching lines...) Expand all Loading... | |
186 void InitFrom(const PluginGroup& other); | 206 void InitFrom(const PluginGroup& other); |
187 | 207 |
188 // Set the description and version for this plugin group from the | 208 // Set the description and version for this plugin group from the |
189 // given plug-in. | 209 // given plug-in. |
190 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); | 210 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); |
191 | 211 |
192 // Updates the active plugin in the group. The active plugin is the first | 212 // Updates the active plugin in the group. The active plugin is the first |
193 // enabled one, or if all plugins are disabled, simply the first one. | 213 // enabled one, or if all plugins are disabled, simply the first one. |
194 void UpdateActivePlugin(const WebPluginInfo& plugin); | 214 void UpdateActivePlugin(const WebPluginInfo& plugin); |
195 | 215 |
216 // Refreshes the enabled flag based on the state of its plugins. | |
217 void RefreshEnabledState(); | |
218 | |
219 // Enables the plugin if not already enabled and if policy allows it to. | |
220 // Returns true on success. | |
221 static bool Enable(WebPluginInfo* plugin, int reason); | |
222 | |
223 // Disables the plugin if not already disabled and if policy allows it to. | |
224 // Returns true on success. | |
225 static bool Disable(WebPluginInfo* plugin, int reason); | |
226 | |
196 static std::set<string16>* policy_disabled_plugin_patterns_; | 227 static std::set<string16>* policy_disabled_plugin_patterns_; |
197 | 228 |
198 std::string identifier_; | 229 std::string identifier_; |
199 string16 group_name_; | 230 string16 group_name_; |
200 string16 name_matcher_; | 231 string16 name_matcher_; |
201 string16 description_; | 232 string16 description_; |
202 std::string update_url_; | 233 std::string update_url_; |
203 bool enabled_; | 234 bool enabled_; |
204 std::vector<VersionRange> version_ranges_; | 235 std::vector<VersionRange> version_ranges_; |
205 scoped_ptr<Version> version_; | 236 scoped_ptr<Version> version_; |
206 std::vector<WebPluginInfo> web_plugin_infos_; | 237 std::vector<WebPluginInfo> web_plugin_infos_; |
207 std::vector<int> web_plugin_positions_; | |
208 }; | 238 }; |
209 | 239 |
210 } // namespace npapi | 240 } // namespace npapi |
211 } // namespace webkit | 241 } // namespace webkit |
212 | 242 |
213 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ | 243 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ |
OLD | NEW |