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

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

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests. Created 9 years, 11 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) 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_LIST_H_ 5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
7 7
8 #include <map>
8 #include <set> 9 #include <set>
9 #include <string> 10 #include <string>
11 #include <utility>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/basictypes.h" 14 #include "base/basictypes.h"
13 #include "base/file_path.h" 15 #include "base/file_path.h"
14 #include "base/linked_ptr.h" 16 #include "base/linked_ptr.h"
15 #include "base/lock.h" 17 #include "base/lock.h"
16 #include "third_party/npapi/bindings/nphostapi.h" 18 #include "third_party/npapi/bindings/nphostapi.h"
17 #include "webkit/plugins/npapi/plugin_group.h" 19 #include "webkit/plugins/npapi/plugin_group.h"
18 #include "webkit/plugins/npapi/webplugininfo.h" 20 #include "webkit/plugins/npapi/webplugininfo.h"
19 21
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // cache. 193 // cache.
192 std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info); 194 std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info);
193 195
194 // Load a specific plugin with full path. 196 // Load a specific plugin with full path.
195 void LoadPlugin(const FilePath& filename, 197 void LoadPlugin(const FilePath& filename,
196 std::vector<WebPluginInfo>* plugins); 198 std::vector<WebPluginInfo>* plugins);
197 199
198 // Enable a specific plugin, specified by path. Returns |true| iff a plugin 200 // Enable a specific plugin, specified by path. Returns |true| iff a plugin
199 // currently in the plugin list was actually enabled as a result; regardless 201 // currently in the plugin list was actually enabled as a result; regardless
200 // of return value, if a plugin is found in the future with the given name, it 202 // of return value, if a plugin is found in the future with the given name, it
201 // will be enabled. Note that plugins are enabled by default as far as 203 // will be enabled.
202 // |PluginList| is concerned.
203 bool EnablePlugin(const FilePath& filename); 204 bool EnablePlugin(const FilePath& filename);
204 205
205 // Disable a specific plugin, specified by path. Returns |true| iff a plugin 206 // Disable a specific plugin, specified by path. Returns |true| iff a plugin
206 // currently in the plugin list was actually disabled as a result; regardless 207 // currently in the plugin list was actually disabled as a result; regardless
207 // of return value, if a plugin is found in the future with the given name, it 208 // of return value, if a plugin is found in the future with the given name, it
208 // will be disabled. 209 // will be disabled.
209 bool DisablePlugin(const FilePath& filename); 210 bool DisablePlugin(const FilePath& filename);
210 211
211 // Enable/disable a plugin group, specified by group_name. Returns |true| iff 212 // Enable/disable a plugin group, specified by group_name. Returns |true| iff
212 // a plugin currently in the plugin list was actually enabled/disabled as a 213 // a plugin currently in the plugin list was actually enabled/disabled as a
213 // result; regardless of return value, if a plugin is found in the future with 214 // result; regardless of return value, if a plugin is found in the future with
214 // the given name, it will be enabled/disabled. Note that plugins are enabled 215 // the given name, it will be enabled/disabled.
215 // by default as far as |PluginList| is concerned.
216 bool EnableGroup(bool enable, const string16& name); 216 bool EnableGroup(bool enable, const string16& name);
217 217
218 // Disable all plugins groups that are known to be outdated, according to 218 // Disable all plugins groups that are known to be outdated, according to
219 // the information hardcoded in PluginGroup, to make sure that they can't 219 // the information hardcoded in PluginGroup, to make sure that they can't
220 // be loaded on a web page and instead show a UI to update to the latest 220 // be loaded on a web page and instead show a UI to update to the latest
221 // version. 221 // version.
222 void DisableOutdatedPluginGroups(); 222 void DisableOutdatedPluginGroups();
223 223
224 ~PluginList(); 224 virtual ~PluginList();
225 225
226 private: 226 protected:
227 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition);
228
229 // Constructors are private for singletons 227 // Constructors are private for singletons
230 PluginList(); 228 PluginList();
231 229
232 // Creates PluginGroups for the static group definitions, and adds them to 230 // Load all plugins from the default plugins directory
233 // the PluginGroup cache of this PluginList. 231 virtual void LoadPlugins(bool refresh);
234 void AddHardcodedPluginGroups(); 232
233 // Allows tests to perform custom post-initialization tasks on newly created
234 // PluginGroups.
235 virtual void ProcessGroupAfterInitialize(PluginGroup* group) { }
235 236
236 // Adds the given WebPluginInfo to its corresponding group, creating it if 237 // Adds the given WebPluginInfo to its corresponding group, creating it if
237 // necessary, and returns the group. 238 // necessary, and returns the group.
238 // Callers need to protect calls to this method by a lock themselves. 239 // Callers need to protect calls to this method by a lock themselves.
239 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); 240 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info);
240 241
241 // Load all plugins from the default plugins directory 242 bool plugins_loaded_;
242 void LoadPlugins(bool refresh); 243
244 // Holds the currently available plugin groups.
245 PluginGroup::PluginMap plugin_groups_;
246
247 private:
248 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition);
249
250 // Creates PluginGroups for the static group definitions, and adds them to
251 // the PluginGroup cache of this PluginList.
252 void AddHardcodedPluginGroups();
243 253
244 // Load all plugins from a specific directory. 254 // Load all plugins from a specific directory.
245 // |plugins| is updated with loaded plugin information. 255 // |plugins| is updated with loaded plugin information.
246 // |visited_plugins| is updated with paths to all plugins that were considered 256 // |visited_plugins| is updated with paths to all plugins that were considered
247 // (including those we didn't load) 257 // (including those we didn't load)
248 void LoadPluginsFromDir(const FilePath& path, 258 void LoadPluginsFromDir(const FilePath& path,
249 std::vector<WebPluginInfo>* plugins, 259 std::vector<WebPluginInfo>* plugins,
250 std::set<FilePath>* visited_plugins); 260 std::set<FilePath>* visited_plugins);
251 261
252 // Returns true if we should load the given plugin, or false otherwise. 262 // Returns true if we should load the given plugin, or false otherwise.
253 // plugins is the list of plugins we have crawled in the current plugin 263 // plugins is the list of plugins we have crawled in the current plugin
254 // loading run. 264 // loading run.
255 bool ShouldLoadPlugin(const WebPluginInfo& info, 265 bool ShouldLoadPlugin(const WebPluginInfo& info,
256 std::vector<WebPluginInfo>* plugins); 266 std::vector<WebPluginInfo>* plugins);
257 267
258 // Return whether a plug-in group with the given name should be disabled, 268 // Return whether a plug-in group with the given name should be disabled,
259 // either because it already is on the list of disabled groups, or because it 269 // either because it already is on the list of disabled groups, or because it
260 // is blacklisted by a policy. In the latter case, add the plugin group to the 270 // is blacklisted by a policy. In the latter case, add the plugin group to the
261 // list of disabled groups as well. 271 // list of disabled groups as well.
262 bool ShouldDisableGroup(const string16& group_name); 272 bool ShouldDisableGroup(const string16& group_name);
263 273
264 // Returns true if the given WebPluginInfo supports "mime-type". 274 // Returns true if the plugin supports |mime_type|. |mime_type| should be all
265 // mime_type should be all lower case. 275 // lower case.
266 static bool SupportsType(const WebPluginInfo& info, 276 bool SupportsType(const WebPluginInfo& plugin,
267 const std::string &mime_type, 277 const std::string& mime_type,
268 bool allow_wildcard); 278 bool allow_wildcard);
269 279
270 // Returns true if the given WebPluginInfo supports a given file extension. 280 // Returns true if the given plugin supports a given file extension.
271 // extension should be all lower case. 281 // |extension| should be all lower case. If |mime_type| is not NULL, it will
272 // If mime_type is not NULL, it will be set to the mime type if found. 282 // be set to the MIME type if found. The MIME type which corresponds to the
273 // The mime type which corresponds to the extension is optionally returned 283 // extension is optionally returned back.
274 // back. 284 bool SupportsExtension(const WebPluginInfo& plugin,
275 static bool SupportsExtension(const WebPluginInfo& info, 285 const std::string& extension,
276 const std::string &extension, 286 std::string* actual_mime_type);
277 std::string* actual_mime_type);
278
279 // 287 //
280 // Platform functions 288 // Platform functions
281 // 289 //
282 290
283 // Do any initialization. 291 // Do any initialization.
284 void PlatformInit(); 292 void PlatformInit();
285 293
286 // Get the ordered list of directories from which to load plugins 294 // Get the ordered list of directories from which to load plugins
287 void GetPluginDirectories(std::vector<FilePath>* plugin_dirs); 295 void GetPluginDirectories(std::vector<FilePath>* plugin_dirs);
288 296
289 // 297 //
290 // Command-line switches 298 // Command-line switches
291 // 299 //
292 300
293 #if defined(OS_WIN) 301 #if defined(OS_WIN)
294 // true if we shouldn't load the new WMP plugin. 302 // true if we shouldn't load the new WMP plugin.
295 bool dont_load_new_wmp_; 303 bool dont_load_new_wmp_;
296 304
297 // Loads plugins registered under HKCU\Software\MozillaPlugins and 305 // Loads plugins registered under HKCU\Software\MozillaPlugins and
298 // HKLM\Software\MozillaPlugins. 306 // HKLM\Software\MozillaPlugins.
299 void LoadPluginsFromRegistry(std::vector<WebPluginInfo>* plugins, 307 void LoadPluginsFromRegistry(std::vector<WebPluginInfo>* plugins,
300 std::set<FilePath>* visited_plugins); 308 std::set<FilePath>* visited_plugins);
301 #endif 309 #endif
302 310
303 // 311 //
304 // Internals 312 // Internals
305 // 313 //
306 314
307 bool plugins_loaded_;
308
309 // If true, we reload plugins even if they've been loaded already. 315 // If true, we reload plugins even if they've been loaded already.
310 bool plugins_need_refresh_; 316 bool plugins_need_refresh_;
311 317
312 // Contains information about the available plugins.
313 std::vector<WebPluginInfo> plugins_;
314
315 // Extra plugin paths that we want to search when loading. 318 // Extra plugin paths that we want to search when loading.
316 std::vector<FilePath> extra_plugin_paths_; 319 std::vector<FilePath> extra_plugin_paths_;
317 320
318 // Extra plugin directories that we want to search when loading. 321 // Extra plugin directories that we want to search when loading.
319 std::vector<FilePath> extra_plugin_dirs_; 322 std::vector<FilePath> extra_plugin_dirs_;
320 323
321 // Holds information about internal plugins. 324 // Holds information about internal plugins.
322 std::vector<PluginVersionInfo> internal_plugins_; 325 std::vector<PluginVersionInfo> internal_plugins_;
323 326
324 // Path names of plugins to disable (the default is to enable them all).
325 std::set<FilePath> disabled_plugins_;
326
327 // Group names to disable (the default is to enable them all).
328 std::set<string16> disabled_groups_;
329
330 bool disable_outdated_plugins_; 327 bool disable_outdated_plugins_;
331 328
332 // Holds the currently available plugin groups. 329 std::vector<FilePath> prematurely_disabled_plugins_;
333 PluginGroup::PluginMap plugin_groups_;
334 330
335 int next_priority_; 331 int next_priority_;
336 332
337 // Need synchronization for the above members since this object can be 333 // Need synchronization for the above members since this object can be
338 // accessed on multiple threads. 334 // accessed on multiple threads.
339 Lock lock_; 335 /*mutable*/ Lock lock_;
jam 2011/01/15 00:51:34 ?
pastarmovj 2011/01/18 18:30:39 Removed now. I forgot to do so but I tested if it
340 336
341 friend struct base::DefaultLazyInstanceTraits<PluginList>; 337 friend struct base::DefaultLazyInstanceTraits<PluginList>;
342 338
343 DISALLOW_COPY_AND_ASSIGN(PluginList); 339 DISALLOW_COPY_AND_ASSIGN(PluginList);
344 }; 340 };
345 341
346 } // namespace npapi 342 } // namespace npapi
347 } // namespace webkit 343 } // namespace webkit
348 344
349 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 345 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698