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_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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... | |
36 // This struct holds entry points into a plugin. The entry points are | 36 // This struct holds entry points into a plugin. The entry points are |
37 // slightly different between Win/Mac and Unixes. | 37 // slightly different between Win/Mac and Unixes. |
38 struct PluginEntryPoints { | 38 struct PluginEntryPoints { |
39 #if !defined(OS_POSIX) || defined(OS_MACOSX) | 39 #if !defined(OS_POSIX) || defined(OS_MACOSX) |
40 NP_GetEntryPointsFunc np_getentrypoints; | 40 NP_GetEntryPointsFunc np_getentrypoints; |
41 #endif | 41 #endif |
42 NP_InitializeFunc np_initialize; | 42 NP_InitializeFunc np_initialize; |
43 NP_ShutdownFunc np_shutdown; | 43 NP_ShutdownFunc np_shutdown; |
44 }; | 44 }; |
45 | 45 |
46 // This struct fully describes a plugin. For external plugins, it's read in from | |
47 // the version info of the dll; For internal plugins, it's predefined and | |
48 // includes addresses of entry functions. (Yes, it's Win32 NPAPI-centric, but | |
49 // it'll do for holding descriptions of internal plugins cross-platform.) | |
50 // TODO(evan): remove when NaCl is fixed. | |
51 struct PluginVersionInfo { | |
52 FilePath path; | |
53 // Info about the plugin itself. | |
54 std::wstring product_name; | |
55 std::wstring file_description; | |
56 std::wstring file_version; | |
57 // Info about the data types that the plugin supports. | |
58 std::wstring mime_types; | |
59 std::wstring file_extensions; | |
60 std::wstring type_descriptions; | |
61 // Entry points for internal plugins. Pointers are NULL for external plugins. | |
62 PluginEntryPoints entry_points; | |
63 }; | |
64 | |
65 // The PluginList is responsible for loading our NPAPI based plugins. It does | 46 // The PluginList is responsible for loading our NPAPI based plugins. It does |
66 // so in whatever manner is appropriate for the platform. On Windows, it loads | 47 // so in whatever manner is appropriate for the platform. On Windows, it loads |
67 // plugins from a known directory by looking for DLLs which start with "NP", | 48 // plugins from a known directory by looking for DLLs which start with "NP", |
68 // and checking to see if they are valid NPAPI libraries. On the Mac, it walks | 49 // and checking to see if they are valid NPAPI libraries. On the Mac, it walks |
69 // the machine-wide and user plugin directories and loads anything that has | 50 // the machine-wide and user plugin directories and loads anything that has |
70 // the correct types. On Linux, it walks the plugin directories as well | 51 // the correct types. On Linux, it walks the plugin directories as well |
71 // (e.g. /usr/lib/browser-plugins/). | 52 // (e.g. /usr/lib/browser-plugins/). |
72 // This object is thread safe. | 53 // This object is thread safe. |
73 class PluginList { | 54 class PluginList { |
74 public: | 55 public: |
(...skipping 17 matching lines...) Expand all Loading... | |
92 // Add/Remove an extra plugin to load when we actually do the loading. Must | 73 // Add/Remove an extra plugin to load when we actually do the loading. Must |
93 // be called before the plugins have been loaded. | 74 // be called before the plugins have been loaded. |
94 void AddExtraPluginPath(const FilePath& plugin_path); | 75 void AddExtraPluginPath(const FilePath& plugin_path); |
95 void RemoveExtraPluginPath(const FilePath& plugin_path); | 76 void RemoveExtraPluginPath(const FilePath& plugin_path); |
96 | 77 |
97 // Same as above, but specifies a directory in which to search for plugins. | 78 // Same as above, but specifies a directory in which to search for plugins. |
98 void AddExtraPluginDir(const FilePath& plugin_dir); | 79 void AddExtraPluginDir(const FilePath& plugin_dir); |
99 | 80 |
100 // Register an internal plugin with the specified plugin information and | 81 // Register an internal plugin with the specified plugin information and |
101 // function pointers. An internal plugin must be registered before it can | 82 // function pointers. An internal plugin must be registered before it can |
102 // be loaded using PluginList::LoadPlugin(). | 83 // be loaded using PluginList::LoadPlugin(). |
pastarmovj
2011/01/13 13:36:08
Maybe fix this comment because it used to cover bo
| |
103 void RegisterInternalPlugin(const FilePath& path); | 84 void RegisterInternalPlugin(const WebPluginInfo& info); |
85 // This second version is for "plugins" that have been compiled | |
86 // directly into the binary -- callers must provide the metadata and | |
87 // the entry points. | |
88 // TODO(evan): we use file names here, but they're not really files, they're | |
89 // actually a string that uniquely identifies the plugin. | |
104 void RegisterInternalPlugin(const FilePath& filename, | 90 void RegisterInternalPlugin(const FilePath& filename, |
105 const std::string& name, | 91 const std::string& name, |
106 const std::string& description, | 92 const std::string& description, |
107 const std::string& mime_type, | 93 const std::string& mime_type, |
108 const PluginEntryPoints& entry_points); | 94 const PluginEntryPoints& entry_points); |
109 | 95 |
110 // Deprecated version of the above. | |
111 // TODO(evan): remove when NaCl is fixed. | |
112 void RegisterInternalPlugin(const PluginVersionInfo& info); | |
113 | |
114 // Removes a specified internal plugin from the list. The search will match | 96 // Removes a specified internal plugin from the list. The search will match |
115 // on the path from the version info previously registered. | 97 // on the path from the version info previously registered. |
116 // | 98 // |
117 // This is generally only necessary for tests. | 99 // This is generally only necessary for tests. |
118 void UnregisterInternalPlugin(const FilePath& path); | 100 void UnregisterInternalPlugin(const FilePath& path); |
119 | 101 |
120 // Creates a WebPluginInfo structure given a plugin's path. On success | 102 // Creates a WebPluginInfo structure given a plugin's path. On success |
121 // returns true, with the information being put into "info". If it's an | 103 // returns true, with the information being put into "info". If it's an |
122 // internal plugin, "entry_points" is filled in as well with a | 104 // internal plugin, "entry_points" is filled in as well with a |
123 // internally-owned PluginEntryPoints pointer. | 105 // internally-owned PluginEntryPoints pointer. |
124 // Returns false if the library couldn't be found, or if it's not a plugin. | 106 // Returns false if the library couldn't be found, or if it's not a plugin. |
125 bool ReadPluginInfo(const FilePath& filename, | 107 bool ReadPluginInfo(const FilePath& filename, |
126 WebPluginInfo* info, | 108 WebPluginInfo* info, |
127 const PluginEntryPoints** entry_points); | 109 const PluginEntryPoints** entry_points); |
128 | 110 |
129 // Populate a WebPluginInfo from a PluginVersionInfo. | 111 // In Windows and Pepper plugins, the mime types are passed as a specially |
130 static bool CreateWebPluginInfo(const PluginVersionInfo& pvi, | 112 // formatted list of strings. This function parses those strings into |
131 WebPluginInfo* info); | 113 // a WebPluginMimeType vector. |
114 // TODO(evan): make Pepper pass around formatted data and move this code | |
115 // into plugin_list_win. | |
116 static bool ParseMimeTypes(const std::string& mime_types, | |
117 const std::string& file_extensions, | |
118 const string16& mime_type_descriptions, | |
119 std::vector<WebPluginMimeType>* parsed_mime_types); | |
132 | 120 |
133 // Shutdown all plugins. Should be called at process teardown. | 121 // Shutdown all plugins. Should be called at process teardown. |
134 void Shutdown(); | 122 void Shutdown(); |
135 | 123 |
136 // Get all the plugins. | 124 // Get all the plugins. |
137 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); | 125 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); |
138 | 126 |
139 // Get all the enabled plugins. | 127 // Get all the enabled plugins. |
140 void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); | 128 void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); |
141 | 129 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 | 299 |
312 // Contains information about the available plugins. | 300 // Contains information about the available plugins. |
313 std::vector<WebPluginInfo> plugins_; | 301 std::vector<WebPluginInfo> plugins_; |
314 | 302 |
315 // Extra plugin paths that we want to search when loading. | 303 // Extra plugin paths that we want to search when loading. |
316 std::vector<FilePath> extra_plugin_paths_; | 304 std::vector<FilePath> extra_plugin_paths_; |
317 | 305 |
318 // Extra plugin directories that we want to search when loading. | 306 // Extra plugin directories that we want to search when loading. |
319 std::vector<FilePath> extra_plugin_dirs_; | 307 std::vector<FilePath> extra_plugin_dirs_; |
320 | 308 |
309 struct InternalPlugin { | |
310 WebPluginInfo info; | |
311 PluginEntryPoints entry_points; | |
312 }; | |
321 // Holds information about internal plugins. | 313 // Holds information about internal plugins. |
322 std::vector<PluginVersionInfo> internal_plugins_; | 314 std::vector<InternalPlugin> internal_plugins_; |
323 | 315 |
324 // Path names of plugins to disable (the default is to enable them all). | 316 // Path names of plugins to disable (the default is to enable them all). |
325 std::set<FilePath> disabled_plugins_; | 317 std::set<FilePath> disabled_plugins_; |
326 | 318 |
327 // Group names to disable (the default is to enable them all). | 319 // Group names to disable (the default is to enable them all). |
328 std::set<string16> disabled_groups_; | 320 std::set<string16> disabled_groups_; |
329 | 321 |
330 bool disable_outdated_plugins_; | 322 bool disable_outdated_plugins_; |
331 | 323 |
332 // Holds the currently available plugin groups. | 324 // Holds the currently available plugin groups. |
333 PluginGroup::PluginMap plugin_groups_; | 325 PluginGroup::PluginMap plugin_groups_; |
334 | 326 |
335 int next_priority_; | 327 int next_priority_; |
336 | 328 |
337 // Need synchronization for the above members since this object can be | 329 // Need synchronization for the above members since this object can be |
338 // accessed on multiple threads. | 330 // accessed on multiple threads. |
339 Lock lock_; | 331 Lock lock_; |
340 | 332 |
341 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 333 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
342 | 334 |
343 DISALLOW_COPY_AND_ASSIGN(PluginList); | 335 DISALLOW_COPY_AND_ASSIGN(PluginList); |
344 }; | 336 }; |
345 | 337 |
346 } // namespace npapi | 338 } // namespace npapi |
347 } // namespace webkit | 339 } // namespace webkit |
348 | 340 |
349 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 341 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |
OLD | NEW |