Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: webkit/plugins/npapi/plugin_group.h

Issue 7848025: Store plug-in enabled/disabled state in PluginPrefs instead of WebPluginInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indent Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
Joao da Silva 2011/09/13 09:30:48 Not used
Bernhard Bauer 2011/09/13 12:13:01 Removed <map> and <set>.
10 #include <set> 10 #include <set>
Joao da Silva 2011/09/13 09:30:48 Not used anymore
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/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "webkit/plugins/webplugininfo.h" 17 #include "webkit/plugins/webplugininfo.h"
18 18
19 class FilePath; 19 class FilePath;
20 class PluginExceptionsTableModelTest; 20 class PluginExceptionsTableModelTest;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 static const char* kRealPlayerGroupName; 90 static const char* kRealPlayerGroupName;
91 static const char* kSilverlightGroupName; 91 static const char* kSilverlightGroupName;
92 static const char* kWindowsMediaPlayerGroupName; 92 static const char* kWindowsMediaPlayerGroupName;
93 93
94 PluginGroup(const PluginGroup& other); 94 PluginGroup(const PluginGroup& other);
95 95
96 ~PluginGroup(); 96 ~PluginGroup();
97 97
98 PluginGroup& operator=(const PluginGroup& other); 98 PluginGroup& operator=(const PluginGroup& other);
99 99
100 // Configures the set of plugin name patterns for enabling and disabling
101 // plugins via enterprise configuration management.
102 static void SetPolicyEnforcedPluginPatterns(
103 const std::set<string16>& plugins_disabled,
104 const std::set<string16>& plugins_disabled_exceptions,
105 const std::set<string16>& plugins_enabled);
106
107 // Tests whether |plugin_name| is disabled by policy.
108 static bool IsPluginNameDisabledByPolicy(const string16& plugin_name);
109
110 // Tests whether |plugin_name| within the plugin group |group_name| is
111 // disabled by policy.
112 static bool IsPluginFileNameDisabledByPolicy(const string16& plugin_name,
113 const string16& group_name);
114
115 // Tests whether |plugin_name| is enabled by policy.
116 static bool IsPluginNameEnabledByPolicy(const string16& plugin_name);
117
118 // Returns true if the given plugin matches this group. 100 // Returns true if the given plugin matches this group.
119 bool Match(const webkit::WebPluginInfo& plugin) const; 101 bool Match(const webkit::WebPluginInfo& plugin) const;
120 102
121 // Adds the given plugin to this group. 103 // Adds the given plugin to this group.
122 void AddPlugin(const webkit::WebPluginInfo& plugin); 104 void AddPlugin(const webkit::WebPluginInfo& plugin);
123 105
124 // Removes a plugin from the group by its path. 106 // Removes a plugin from the group by its path.
125 bool RemovePlugin(const FilePath& filename); 107 bool RemovePlugin(const FilePath& filename);
126 108
127 // The two following functions enable/disable a plugin given its filename. The
128 // function returns true if the plugin could be enabled/disabled. Plugins
129 // might not get enabled/disabled if they are controlled by policy or are
130 // already in the wanted state.
131 bool EnablePlugin(const FilePath& filename);
132 bool DisablePlugin(const FilePath& filename);
133
134 // Enables/disables this group. This enables/disables all plugins in the
135 // group.
136 bool EnableGroup(bool enable);
137
138 // Checks whether the group should be disabled/enabled by a policy and puts
139 // it in the needed state. Updates all contained plugins too.
140 void EnforceGroupPolicy();
141
142 // Returns whether the plugin group is enabled or not.
143 bool Enabled() const { return enabled_; }
144
145 // Returns a unique identifier for this group, if one is defined, or the empty 109 // Returns a unique identifier for this group, if one is defined, or the empty
146 // string otherwise. 110 // string otherwise.
147 const std::string& identifier() const { return identifier_; } 111 const std::string& identifier() const { return identifier_; }
148 112
149 // Sets a unique identifier for this group or if none is set an empty string. 113 // Sets a unique identifier for this group or if none is set an empty string.
150 void set_identifier(const std::string& identifier) { 114 void set_identifier(const std::string& identifier) {
151 identifier_ = identifier; 115 identifier_ = identifier;
152 } 116 }
153 117
154 // Returns this group's name, or the filename without extension if the name 118 // Returns this group's name, or the filename without extension if the name
155 // is empty. 119 // is empty.
156 string16 GetGroupName() const; 120 string16 GetGroupName() const;
157 121
158 // Returns all plugins added to the group.
159 const std::vector<webkit::WebPluginInfo>& web_plugins_info() const {
160 return web_plugin_infos_;
161 }
162
163 // Checks whether a plugin exists in the group with the given path. 122 // Checks whether a plugin exists in the group with the given path.
164 bool ContainsPlugin(const FilePath& path) const; 123 bool ContainsPlugin(const FilePath& path) const;
165 124
166 // Returns the description of the highest-priority plug-in in the group.
167 const string16& description() const { return description_; }
168
169 // Returns a DictionaryValue with data to display in the UI.
170 base::DictionaryValue* GetDataForUI() const;
171
172 // Returns a DictionaryValue with data to save in the preferences.
173 base::DictionaryValue* GetSummary() const;
174
175 // Returns the update URL. 125 // Returns the update URL.
176 std::string GetUpdateURL() const { return update_url_; } 126 std::string GetUpdateURL() const { return update_url_; }
177 127
178 // Returns true if this plugin group is whitelisted. 128 // Returns true if this plugin group is whitelisted.
179 bool IsWhitelisted() const; 129 bool IsWhitelisted() const;
180 130
181 // Returns true if the highest-priority plugin in this group has known 131 // Returns true if |plugin| in this group has known security problems.
182 // security problems. 132 bool IsVulnerable(const WebPluginInfo& plugin) const;
183 bool IsVulnerable() const;
184 133
185 // Returns true if this plug-in group always requires user authorization 134 // Returns true if |plugin| in this plug-in group always requires user
186 // to run. 135 // authorization to run.
187 bool RequiresAuthorization() const; 136 bool RequiresAuthorization(const WebPluginInfo& plugin) const;
188 137
189 // Check if the group has no plugins. Could happen after a reload if the plug- 138 // Check if the group has no plugins. Could happen after a reload if the plug-
190 // in has disappeared from the pc (or in the process of updating). 139 // in has disappeared from the pc (or in the process of updating).
191 bool IsEmpty() const; 140 bool IsEmpty() const;
192 141
193 // Parse a version string as used by a plug-in. This method is more lenient 142 // Parse a version string as used by a plug-in. This method is more lenient
194 // in accepting weird version strings than Version::GetFromString(). 143 // in accepting weird version strings than Version::GetFromString().
195 static Version* CreateVersionFromString(const string16& version_string); 144 static Version* CreateVersionFromString(const string16& version_string);
196 145
197 std::vector<webkit::WebPluginInfo> web_plugin_infos() { 146 const std::vector<webkit::WebPluginInfo>& web_plugin_infos() const {
198 return web_plugin_infos_; 147 return web_plugin_infos_;
199 } 148 }
200 149
201 private: 150 private:
202 friend class PluginList; 151 friend class PluginList;
203 friend class MockPluginList; 152 friend class MockPluginList;
204 friend class PluginGroupTest; 153 friend class PluginGroupTest;
205 friend class ::PluginExceptionsTableModelTest; 154 friend class ::PluginExceptionsTableModelTest;
206 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated); 155 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated);
207 156
(...skipping 22 matching lines...) Expand all
230 static bool IsPluginOutdated(const Version& plugin_version, 179 static bool IsPluginOutdated(const Version& plugin_version,
231 const VersionRange& version_range); 180 const VersionRange& version_range);
232 181
233 PluginGroup(const string16& group_name, 182 PluginGroup(const string16& group_name,
234 const string16& name_matcher, 183 const string16& name_matcher,
235 const std::string& update_url, 184 const std::string& update_url,
236 const std::string& identifier); 185 const std::string& identifier);
237 186
238 void InitFrom(const PluginGroup& other); 187 void InitFrom(const PluginGroup& other);
239 188
240 // Set the description and version for this plugin group from the
241 // given plug-in.
242 void UpdateDescriptionAndVersion(const webkit::WebPluginInfo& plugin);
243
244 // Updates the active plugin in the group. The active plugin is the first
245 // enabled one, or if all plugins are disabled, simply the first one.
246 void UpdateActivePlugin(const webkit::WebPluginInfo& plugin);
247
248 // Resets the group state to its default value (as if the group was empty).
249 // After calling this method, calling |UpdateActivePlugin| with all plugins
250 // in a row will correctly set the group state.
251 void ResetGroupState();
252
253 // Enables the plugin if not already enabled and if policy allows it to.
254 // Returns true on success. Does not update the group state.
255 static bool Enable(webkit::WebPluginInfo* plugin, int reason);
256
257 // Disables the plugin if not already disabled and if policy allows it to.
258 // Returns true on success. Does not update the group state.
259 static bool Disable(webkit::WebPluginInfo* plugin, int reason);
260
261 // Helper function to implement the functions above.
262 static bool SetPluginState(webkit::WebPluginInfo* plugin,
263 int new_reason,
264 bool state_changes);
265
266 // Returns a non-const vector of all plugins in the group. This is only used 189 // Returns a non-const vector of all plugins in the group. This is only used
267 // by PluginList. 190 // by PluginList.
268 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() { 191 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() {
269 return web_plugin_infos_; 192 return web_plugin_infos_;
270 } 193 }
271 194
272 // Checks if |name| matches any of the patterns in |pattern_set|.
273 static bool IsStringMatchedInSet(const string16& name,
274 const std::set<string16>* pattern_set);
275
276 static std::set<string16>* policy_disabled_plugin_patterns_;
277 static std::set<string16>* policy_disabled_plugin_exception_patterns_;
278 static std::set<string16>* policy_enabled_plugin_patterns_;
279
280 std::string identifier_; 195 std::string identifier_;
281 string16 group_name_; 196 string16 group_name_;
282 string16 name_matcher_; 197 string16 name_matcher_;
283 string16 description_;
284 std::string update_url_; 198 std::string update_url_;
285 bool enabled_;
286 std::vector<VersionRange> version_ranges_; 199 std::vector<VersionRange> version_ranges_;
287 scoped_ptr<Version> version_;
288 std::vector<webkit::WebPluginInfo> web_plugin_infos_; 200 std::vector<webkit::WebPluginInfo> web_plugin_infos_;
289 }; 201 };
290 202
291 } // namespace npapi 203 } // namespace npapi
292 } // namespace webkit 204 } // namespace webkit
293 205
294 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ 206 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698