| 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 <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/glue/plugins/plugin_group.h" | 19 #include "webkit/glue/plugins/plugin_group.h" |
| 18 #include "webkit/glue/plugins/webplugininfo.h" | 20 #include "webkit/glue/plugins/webplugininfo.h" |
| 19 | 21 |
| 20 class GURL; | 22 class GURL; |
| 21 | 23 |
| 22 namespace base { | 24 namespace base { |
| 23 | 25 |
| 24 template <typename T> | 26 template <typename T> |
| 25 struct DefaultLazyInstanceTraits; | 27 struct DefaultLazyInstanceTraits; |
| 26 | 28 |
| 27 } // namespace base | 29 } // namespace base |
| 28 | 30 |
| 31 namespace plugin_test_internal { |
| 32 class TestablePluginList; |
| 33 } |
| 34 |
| 29 namespace NPAPI { | 35 namespace NPAPI { |
| 30 | 36 |
| 31 #define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin") | 37 #define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin") |
| 32 #define kGearsPluginLibraryName FILE_PATH_LITERAL("gears") | 38 #define kGearsPluginLibraryName FILE_PATH_LITERAL("gears") |
| 33 | 39 |
| 34 class PluginInstance; | 40 class PluginInstance; |
| 35 | 41 |
| 36 // 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 |
| 37 // slightly different between Win/Mac and Unixes. | 43 // slightly different between Win/Mac and Unixes. |
| 38 struct PluginEntryPoints { | 44 struct PluginEntryPoints { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Gets the one instance of the PluginList. | 86 // Gets the one instance of the PluginList. |
| 81 static PluginList* Singleton(); | 87 static PluginList* Singleton(); |
| 82 | 88 |
| 83 // Returns true if we're in debug-plugin-loading mode. This is controlled | 89 // Returns true if we're in debug-plugin-loading mode. This is controlled |
| 84 // by a command line switch. | 90 // by a command line switch. |
| 85 static bool DebugPluginLoading(); | 91 static bool DebugPluginLoading(); |
| 86 | 92 |
| 87 static const PluginGroupDefinition* GetPluginGroupDefinitions(); | 93 static const PluginGroupDefinition* GetPluginGroupDefinitions(); |
| 88 static size_t GetPluginGroupDefinitionsSize(); | 94 static size_t GetPluginGroupDefinitionsSize(); |
| 89 | 95 |
| 96 virtual ~PluginList() { } |
| 97 |
| 90 // Returns true iff the plugin list has been loaded already. | 98 // Returns true iff the plugin list has been loaded already. |
| 91 bool PluginsLoaded(); | 99 bool PluginsLoaded(); |
| 92 | 100 |
| 93 // Cause the plugin list to refresh next time they are accessed, regardless | 101 // Cause the plugin list to refresh next time they are accessed, regardless |
| 94 // of whether they are already loaded. | 102 // of whether they are already loaded. |
| 95 void RefreshPlugins(); | 103 void RefreshPlugins(); |
| 96 | 104 |
| 97 // Add/Remove an extra plugin to load when we actually do the loading. Must | 105 // Add/Remove an extra plugin to load when we actually do the loading. Must |
| 98 // be called before the plugins have been loaded. | 106 // be called before the plugins have been loaded. |
| 99 void AddExtraPluginPath(const FilePath& plugin_path); | 107 void AddExtraPluginPath(const FilePath& plugin_path); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // version. | 225 // version. |
| 218 void DisableOutdatedPluginGroups(); | 226 void DisableOutdatedPluginGroups(); |
| 219 | 227 |
| 220 const DisabledPlugins& GetDisabledPlugins() const; | 228 const DisabledPlugins& GetDisabledPlugins() const; |
| 221 | 229 |
| 222 const DisabledGroups& GetDisabledGroups() const; | 230 const DisabledGroups& GetDisabledGroups() const; |
| 223 | 231 |
| 224 ~PluginList(); | 232 ~PluginList(); |
| 225 | 233 |
| 226 private: | 234 private: |
| 227 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); | 235 friend class plugin_test_internal::TestablePluginList; |
| 228 | 236 |
| 229 // Constructors are private for singletons | 237 // Constructors are private for singletons |
| 230 PluginList(); | 238 PluginList(); |
| 231 | 239 |
| 232 // Creates PluginGroups for the static group definitions, and adds them to | 240 // Creates PluginGroups for the static group definitions, and adds them to |
| 233 // the PluginGroup cache of this PluginList. | 241 // the PluginGroup cache of this PluginList. |
| 234 void AddHardcodedPluginGroups(); | 242 void AddHardcodedPluginGroups(); |
| 235 | 243 |
| 236 // Adds the given WebPluginInfo to its corresponding group, creating it if | 244 // Adds the given WebPluginInfo to its corresponding group, creating it if |
| 237 // necessary, and returns the group. | 245 // necessary, and returns the group. |
| 238 // Callers need to protect calls to this method by a lock themselves. | 246 // Callers need to protect calls to this method by a lock themselves. |
| 239 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); | 247 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); |
| 240 | 248 |
| 241 // Load all plugins from the default plugins directory | 249 // Load all plugins from the default plugins directory. |
| 242 void LoadPlugins(bool refresh); | 250 // Declared virtual so that it can be overridden for tests. |
| 251 virtual void LoadPlugins(bool refresh); |
| 252 |
| 253 // Allows tests to perform custom post-initialization tasks on newly created |
| 254 // PluginGroups. |
| 255 virtual void PostInitPluginGroup(PluginGroup* group) { } |
| 243 | 256 |
| 244 // Load all plugins from a specific directory. | 257 // Load all plugins from a specific directory. |
| 245 // |plugins| is updated with loaded plugin information. | 258 // |plugins| is updated with loaded plugin information. |
| 246 // |visited_plugins| is updated with paths to all plugins that were considered | 259 // |visited_plugins| is updated with paths to all plugins that were considered |
| 247 // (including those we didn't load) | 260 // (including those we didn't load) |
| 248 void LoadPluginsFromDir(const FilePath& path, | 261 void LoadPluginsFromDir(const FilePath& path, |
| 249 std::set<FilePath>* visited_plugins); | 262 std::set<FilePath>* visited_plugins); |
| 250 | 263 |
| 251 // Returns true if we should load the given plugin, or false otherwise. | 264 // Returns true if we should load the given plugin, or false otherwise. |
| 252 // plugins is the list of plugins we have crawled in the current plugin | 265 // plugins is the list of plugins we have crawled in the current plugin |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 mutable Lock lock_; | 354 mutable Lock lock_; |
| 342 | 355 |
| 343 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 356 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
| 344 | 357 |
| 345 DISALLOW_COPY_AND_ASSIGN(PluginList); | 358 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 346 }; | 359 }; |
| 347 | 360 |
| 348 } // namespace NPAPI | 361 } // namespace NPAPI |
| 349 | 362 |
| 350 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 363 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
| OLD | NEW |