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

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

Issue 6162008: plugins: drop PluginVersionInfo for internal plugins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes 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
« no previous file with comments | « webkit/plugins/npapi/plugin_lib_win.cc ('k') | webkit/plugins/npapi/plugin_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 25 matching lines...) Expand all
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 15 matching lines...) Expand all
90 void RefreshPlugins(); 71 void RefreshPlugins();
91 72
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.
101 // function pointers. An internal plugin must be registered before it can 82 // An internal plugin must be registered before it can
102 // be loaded using PluginList::LoadPlugin(). 83 // be loaded using PluginList::LoadPlugin().
103 void RegisterInternalPlugin(const FilePath& path); 84 void RegisterInternalPlugin(const WebPluginInfo& info);
85
86 // This second version is for "plugins" that have been compiled
87 // directly into the binary -- callers must provide the metadata and
88 // the entry points.
89 // TODO(evan): we use file names here, but they're not really files, they're
90 // actually a string that uniquely identifies the plugin.
104 void RegisterInternalPlugin(const FilePath& filename, 91 void RegisterInternalPlugin(const FilePath& filename,
105 const std::string& name, 92 const std::string& name,
106 const std::string& description, 93 const std::string& description,
107 const std::string& mime_type, 94 const std::string& mime_type,
108 const PluginEntryPoints& entry_points); 95 const PluginEntryPoints& entry_points);
109 96
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 97 // Removes a specified internal plugin from the list. The search will match
115 // on the path from the version info previously registered. 98 // on the path from the version info previously registered.
116 // 99 //
117 // This is generally only necessary for tests. 100 // This is generally only necessary for tests.
118 void UnregisterInternalPlugin(const FilePath& path); 101 void UnregisterInternalPlugin(const FilePath& path);
119 102
120 // Creates a WebPluginInfo structure given a plugin's path. On success 103 // 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 104 // 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 105 // internal plugin, "entry_points" is filled in as well with a
123 // internally-owned PluginEntryPoints pointer. 106 // internally-owned PluginEntryPoints pointer.
124 // Returns false if the library couldn't be found, or if it's not a plugin. 107 // Returns false if the library couldn't be found, or if it's not a plugin.
125 bool ReadPluginInfo(const FilePath& filename, 108 bool ReadPluginInfo(const FilePath& filename,
126 WebPluginInfo* info, 109 WebPluginInfo* info,
127 const PluginEntryPoints** entry_points); 110 const PluginEntryPoints** entry_points);
128 111
129 // Populate a WebPluginInfo from a PluginVersionInfo. 112 // In Windows and Pepper plugins, the mime types are passed as a specially
130 static bool CreateWebPluginInfo(const PluginVersionInfo& pvi, 113 // formatted list of strings. This function parses those strings into
131 WebPluginInfo* info); 114 // a WebPluginMimeType vector.
115 // TODO(evan): make Pepper pass around formatted data and move this code
116 // into plugin_list_win.
117 static bool ParseMimeTypes(const std::string& mime_types,
118 const std::string& file_extensions,
119 const string16& mime_type_descriptions,
120 std::vector<WebPluginMimeType>* parsed_mime_types);
132 121
133 // Shutdown all plugins. Should be called at process teardown. 122 // Shutdown all plugins. Should be called at process teardown.
134 void Shutdown(); 123 void Shutdown();
135 124
136 // Get all the plugins. 125 // Get all the plugins.
137 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); 126 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
138 127
139 // Get all the enabled plugins. 128 // Get all the enabled plugins.
140 void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); 129 void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
141 130
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 300
312 // Contains information about the available plugins. 301 // Contains information about the available plugins.
313 std::vector<WebPluginInfo> plugins_; 302 std::vector<WebPluginInfo> plugins_;
314 303
315 // Extra plugin paths that we want to search when loading. 304 // Extra plugin paths that we want to search when loading.
316 std::vector<FilePath> extra_plugin_paths_; 305 std::vector<FilePath> extra_plugin_paths_;
317 306
318 // Extra plugin directories that we want to search when loading. 307 // Extra plugin directories that we want to search when loading.
319 std::vector<FilePath> extra_plugin_dirs_; 308 std::vector<FilePath> extra_plugin_dirs_;
320 309
310 struct InternalPlugin {
311 WebPluginInfo info;
312 PluginEntryPoints entry_points;
313 };
321 // Holds information about internal plugins. 314 // Holds information about internal plugins.
322 std::vector<PluginVersionInfo> internal_plugins_; 315 std::vector<InternalPlugin> internal_plugins_;
323 316
324 // Path names of plugins to disable (the default is to enable them all). 317 // Path names of plugins to disable (the default is to enable them all).
325 std::set<FilePath> disabled_plugins_; 318 std::set<FilePath> disabled_plugins_;
326 319
327 // Group names to disable (the default is to enable them all). 320 // Group names to disable (the default is to enable them all).
328 std::set<string16> disabled_groups_; 321 std::set<string16> disabled_groups_;
329 322
330 bool disable_outdated_plugins_; 323 bool disable_outdated_plugins_;
331 324
332 // Holds the currently available plugin groups. 325 // Holds the currently available plugin groups.
333 PluginGroup::PluginMap plugin_groups_; 326 PluginGroup::PluginMap plugin_groups_;
334 327
335 int next_priority_; 328 int next_priority_;
336 329
337 // Need synchronization for the above members since this object can be 330 // Need synchronization for the above members since this object can be
338 // accessed on multiple threads. 331 // accessed on multiple threads.
339 Lock lock_; 332 Lock lock_;
340 333
341 friend struct base::DefaultLazyInstanceTraits<PluginList>; 334 friend struct base::DefaultLazyInstanceTraits<PluginList>;
342 335
343 DISALLOW_COPY_AND_ASSIGN(PluginList); 336 DISALLOW_COPY_AND_ASSIGN(PluginList);
344 }; 337 };
345 338
346 } // namespace npapi 339 } // namespace npapi
347 } // namespace webkit 340 } // namespace webkit
348 341
349 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 342 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_lib_win.cc ('k') | webkit/plugins/npapi/plugin_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698