Chromium Code Reviews| 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_LIST_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 class GURL; | 22 class GURL; |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 | 25 |
| 26 template <typename T> | 26 template <typename T> |
| 27 struct DefaultLazyInstanceTraits; | 27 struct DefaultLazyInstanceTraits; |
| 28 | 28 |
| 29 } // namespace base | 29 } // namespace base |
| 30 | 30 |
| 31 namespace plugin_test_internal { | |
| 32 class TestablePluginList; | |
| 33 } | |
| 34 | |
| 31 namespace NPAPI { | 35 namespace NPAPI { |
| 32 | 36 |
| 33 #define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin") | 37 #define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin") |
| 34 #define kGearsPluginLibraryName FILE_PATH_LITERAL("gears") | 38 #define kGearsPluginLibraryName FILE_PATH_LITERAL("gears") |
| 35 | 39 |
| 36 class PluginInstance; | 40 class PluginInstance; |
| 37 | 41 |
| 38 // This struct holds entry points into a plugin. The entry points are | 42 // This struct holds entry points into a plugin. The entry points are |
| 39 // slightly different between Win/Mac and Unixes. | 43 // slightly different between Win/Mac and Unixes. |
| 40 struct PluginEntryPoints { | 44 struct PluginEntryPoints { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 // be loaded on a web page and instead show a UI to update to the latest | 223 // be loaded on a web page and instead show a UI to update to the latest |
| 220 // version. | 224 // version. |
| 221 void DisableOutdatedPluginGroups(); | 225 void DisableOutdatedPluginGroups(); |
| 222 | 226 |
| 223 const DisabledPlugins& GetDisabledPlugins() const; | 227 const DisabledPlugins& GetDisabledPlugins() const; |
| 224 | 228 |
| 225 const DisabledGroups& GetDisabledGroups() const; | 229 const DisabledGroups& GetDisabledGroups() const; |
| 226 | 230 |
| 227 virtual ~PluginList(); | 231 virtual ~PluginList(); |
| 228 | 232 |
| 229 private: | 233 protected: |
| 230 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); | 234 // Constructors are private for singletons. |
|
jam
2010/12/15 19:41:57
nit: this comment doesn't make sense now
| |
| 231 | |
| 232 // Constructors are private for singletons | |
| 233 PluginList(); | 235 PluginList(); |
| 234 | 236 |
| 235 // Creates PluginGroups for the static group definitions, and adds them to | 237 // Load all plugins from the default plugins directory. |
| 236 // the PluginGroup cache of this PluginList. | 238 // Declared virtual so that it can be overridden for tests. |
| 237 void AddHardcodedPluginGroups(); | 239 virtual void LoadPlugins(bool refresh); |
| 240 | |
| 241 // Allows tests to perform custom post-initialization tasks on newly created | |
| 242 // PluginGroups. | |
| 243 virtual void ProcessGroupAfterInitialize(PluginGroup* group) { } | |
| 238 | 244 |
| 239 // Adds the given WebPluginInfo to its corresponding group, creating it if | 245 // Adds the given WebPluginInfo to its corresponding group, creating it if |
| 240 // necessary, and returns the group. | 246 // necessary, and returns the group. |
| 241 // Callers need to protect calls to this method by a lock themselves. | 247 // Callers need to protect calls to this method by a lock themselves. |
| 242 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info, | 248 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info, |
| 243 std::vector<WebPluginInfo*>* plugins); | 249 std::vector<WebPluginInfo*>* plugins); |
| 244 | 250 |
| 245 // Load all plugins from the default plugins directory | 251 bool plugins_loaded_; |
| 246 void LoadPlugins(bool refresh); | 252 |
| 253 // Contains information about the available plugins. | |
| 254 std::vector<WebPluginInfo*> plugins_; | |
|
jam
2010/12/15 19:41:57
i actually don't like moving member variables to b
| |
| 255 | |
| 256 // Path names of plugins to disable (the default is to enable them all). | |
| 257 DisabledPlugins disabled_plugins_; | |
| 258 | |
| 259 // Holds the currently available plugin groups. | |
| 260 PluginGroup::PluginMap plugin_groups_; | |
| 261 | |
| 262 private: | |
| 263 // Creates PluginGroups for the static group definitions, and adds them to | |
| 264 // the PluginGroup cache of this PluginList. | |
| 265 void AddHardcodedPluginGroups(); | |
| 247 | 266 |
| 248 // Load all plugins from a specific directory. | 267 // Load all plugins from a specific directory. |
| 249 // |plugins| is updated with loaded plugin information. | 268 // |plugins| is updated with loaded plugin information. |
| 250 // |visited_plugins| is updated with paths to all plugins that were considered | 269 // |visited_plugins| is updated with paths to all plugins that were considered |
| 251 // (including those we didn't load) | 270 // (including those we didn't load) |
| 252 void LoadPluginsFromDir(const FilePath& path, | 271 void LoadPluginsFromDir(const FilePath& path, |
| 253 std::vector<WebPluginInfo*>* plugins, | 272 std::vector<WebPluginInfo*>* plugins, |
| 254 std::set<FilePath>* visited_plugins); | 273 std::set<FilePath>* visited_plugins); |
| 255 | 274 |
| 256 // Returns true if we should load the given plugin, or false otherwise. | 275 // Returns true if we should load the given plugin, or false otherwise. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 // Loads plugins registered under HKCU\Software\MozillaPlugins and | 320 // Loads plugins registered under HKCU\Software\MozillaPlugins and |
| 302 // HKLM\Software\MozillaPlugins. | 321 // HKLM\Software\MozillaPlugins. |
| 303 void LoadPluginsFromRegistry(std::set<FilePath>* visited_plugins, | 322 void LoadPluginsFromRegistry(std::set<FilePath>* visited_plugins, |
| 304 std::vector<WebPluginInfo*>* plugins); | 323 std::vector<WebPluginInfo*>* plugins); |
| 305 #endif | 324 #endif |
| 306 | 325 |
| 307 // | 326 // |
| 308 // Internals | 327 // Internals |
| 309 // | 328 // |
| 310 | 329 |
| 311 bool plugins_loaded_; | |
| 312 | |
| 313 // If true, we reload plugins even if they've been loaded already. | 330 // If true, we reload plugins even if they've been loaded already. |
| 314 bool plugins_need_refresh_; | 331 bool plugins_need_refresh_; |
| 315 | 332 |
| 316 // Contains information about the available plugins. | |
| 317 std::vector<WebPluginInfo*> plugins_; | |
| 318 | |
| 319 // Extra plugin paths that we want to search when loading. | 333 // Extra plugin paths that we want to search when loading. |
| 320 std::vector<FilePath> extra_plugin_paths_; | 334 std::vector<FilePath> extra_plugin_paths_; |
| 321 | 335 |
| 322 // Extra plugin directories that we want to search when loading. | 336 // Extra plugin directories that we want to search when loading. |
| 323 std::vector<FilePath> extra_plugin_dirs_; | 337 std::vector<FilePath> extra_plugin_dirs_; |
| 324 | 338 |
| 325 // Holds information about internal plugins. | 339 // Holds information about internal plugins. |
| 326 std::vector<PluginVersionInfo> internal_plugins_; | 340 std::vector<PluginVersionInfo> internal_plugins_; |
| 327 | 341 |
| 328 // An element of the disabled list saves the reason for being disabled in the | 342 // An element of the disabled list saves the reason for being disabled in the |
| 329 // second element of the pair. | 343 // second element of the pair. |
| 330 typedef std::pair<FilePath, PluginDisabledReason> DisabledPluginsListElement; | 344 typedef std::pair<FilePath, PluginDisabledReason> DisabledPluginsListElement; |
| 331 // Path names of plugins to disable (the default is to enable them all). | |
| 332 DisabledPlugins disabled_plugins_; | |
| 333 | 345 |
| 334 typedef std::pair<string16, PluginDisabledReason> DisabledGroupsListElement; | 346 typedef std::pair<string16, PluginDisabledReason> DisabledGroupsListElement; |
| 335 // Group names to disable (the default is to enable them all). | 347 // Group names to disable (the default is to enable them all). |
| 336 DisabledGroups disabled_groups_; | 348 DisabledGroups disabled_groups_; |
| 337 | 349 |
| 338 bool disable_outdated_plugins_; | 350 bool disable_outdated_plugins_; |
| 339 | 351 |
| 340 // Holds the currently available plugin groups. | |
| 341 PluginGroup::PluginMap plugin_groups_; | |
| 342 | |
| 343 int next_priority_; | 352 int next_priority_; |
| 344 | 353 |
| 345 // Need synchronization for the above members since this object can be | 354 // Need synchronization for the above members since this object can be |
| 346 // accessed on multiple threads. | 355 // accessed on multiple threads. |
| 347 mutable Lock lock_; | 356 mutable Lock lock_; |
| 348 | 357 |
| 349 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 358 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
| 350 | 359 |
| 351 DISALLOW_COPY_AND_ASSIGN(PluginList); | 360 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 352 }; | 361 }; |
| 353 | 362 |
| 354 } // namespace NPAPI | 363 } // namespace NPAPI |
| 355 | 364 |
| 356 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 365 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
| OLD | NEW |