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

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

Issue 7648017: Make WebPluginInfo more generic (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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_host.cc ('k') | webkit/plugins/npapi/plugin_lib.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_LIB_H_ 5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_ 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/native_library.h" 13 #include "base/native_library.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "webkit/plugins/npapi/plugin_list.h" 15 #include "webkit/plugins/npapi/plugin_list.h"
16 #include "webkit/plugins/npapi/webplugin.h" 16 #include "webkit/plugins/npapi/webplugin.h"
17 17
18 class FilePath; 18 class FilePath;
19 struct WebPluginInfo;
20 19
21 namespace webkit { 20 namespace webkit {
22 namespace npapi { 21 namespace npapi {
23 22
24 class PluginInstance; 23 class PluginInstance;
25 24
26 // A PluginLib is a single NPAPI Plugin Library, and is the lifecycle 25 // A PluginLib is a single NPAPI Plugin Library, and is the lifecycle
27 // manager for new PluginInstances. 26 // manager for new PluginInstances.
28 class PluginLib : public base::RefCounted<PluginLib> { 27 class PluginLib : public base::RefCounted<PluginLib> {
29 public: 28 public:
30 static PluginLib* CreatePluginLib(const FilePath& filename); 29 static PluginLib* CreatePluginLib(const FilePath& filename);
31 30
32 // Creates a WebPluginInfo structure given a plugin's path. On success 31 // Creates a WebPluginInfo structure given a plugin's path. On success
33 // returns true, with the information being put into "info". 32 // returns true, with the information being put into "info".
34 // Returns false if the library couldn't be found, or if it's not a plugin. 33 // Returns false if the library couldn't be found, or if it's not a plugin.
35 static bool ReadWebPluginInfo(const FilePath& filename, WebPluginInfo* info); 34 static bool ReadWebPluginInfo(const FilePath& filename,
35 webkit::WebPluginInfo* info);
36 36
37 #if defined(OS_POSIX) && !defined(OS_MACOSX) 37 #if defined(OS_POSIX) && !defined(OS_MACOSX)
38 // Parse the result of an NP_GetMIMEDescription() call. 38 // Parse the result of an NP_GetMIMEDescription() call.
39 // This API is only used on Unixes, and is exposed here for testing. 39 // This API is only used on Unixes, and is exposed here for testing.
40 static void ParseMIMEDescription(const std::string& description, 40 static void ParseMIMEDescription(const std::string& description,
41 std::vector<WebPluginMimeType>* mime_types); 41 std::vector<webkit::WebPluginMimeType>* mime_types);
42 42
43 // Extract a version number from a description string. 43 // Extract a version number from a description string.
44 // This API is only used on Unixes, and is exposed here for testing. 44 // This API is only used on Unixes, and is exposed here for testing.
45 static void ExtractVersionString(const std::string& version, 45 static void ExtractVersionString(const std::string& version,
46 WebPluginInfo* info); 46 webkit::WebPluginInfo* info);
47 #endif 47 #endif
48 48
49 // Unloads all the loaded plugin libraries and cleans up the plugin map. 49 // Unloads all the loaded plugin libraries and cleans up the plugin map.
50 static void UnloadAllPlugins(); 50 static void UnloadAllPlugins();
51 51
52 // Shuts down all loaded plugin instances. 52 // Shuts down all loaded plugin instances.
53 static void ShutdownAllPlugins(); 53 static void ShutdownAllPlugins();
54 54
55 // Get the Plugin's function pointer table. 55 // Get the Plugin's function pointer table.
56 NPPluginFuncs* functions(); 56 NPPluginFuncs* functions();
57 57
58 // Creates a new instance of this plugin. 58 // Creates a new instance of this plugin.
59 PluginInstance* CreateInstance(const std::string& mime_type); 59 PluginInstance* CreateInstance(const std::string& mime_type);
60 60
61 // Called by the instance when the instance is tearing down. 61 // Called by the instance when the instance is tearing down.
62 void CloseInstance(); 62 void CloseInstance();
63 63
64 // Gets information about this plugin and the mime types that it 64 // Gets information about this plugin and the mime types that it
65 // supports. 65 // supports.
66 const WebPluginInfo& plugin_info() { return web_plugin_info_; } 66 const webkit::WebPluginInfo& plugin_info() { return web_plugin_info_; }
67 67
68 bool internal() { return internal_; } 68 bool internal() { return internal_; }
69 69
70 // 70 //
71 // NPAPI functions 71 // NPAPI functions
72 // 72 //
73 73
74 // NPAPI method to initialize a Plugin. 74 // NPAPI method to initialize a Plugin.
75 // Initialize can be safely called multiple times 75 // Initialize can be safely called multiple times
76 NPError NP_Initialize(); 76 NPError NP_Initialize();
(...skipping 18 matching lines...) Expand all
95 void set_defer_unload(bool defer_unload) { 95 void set_defer_unload(bool defer_unload) {
96 defer_unload_ = defer_unload; 96 defer_unload_ = defer_unload;
97 } 97 }
98 98
99 // protected for testability. 99 // protected for testability.
100 protected: 100 protected:
101 friend class base::RefCounted<PluginLib>; 101 friend class base::RefCounted<PluginLib>;
102 102
103 // Creates a new PluginLib. 103 // Creates a new PluginLib.
104 // |entry_points| is non-NULL for internal plugins. 104 // |entry_points| is non-NULL for internal plugins.
105 PluginLib(const WebPluginInfo& info, 105 PluginLib(const webkit::WebPluginInfo& info,
106 const PluginEntryPoints* entry_points); 106 const PluginEntryPoints* entry_points);
107 107
108 virtual ~PluginLib(); 108 virtual ~PluginLib();
109 109
110 // Attempts to load the plugin from the library. 110 // Attempts to load the plugin from the library.
111 // Returns true if it is a legitimate plugin, false otherwise 111 // Returns true if it is a legitimate plugin, false otherwise
112 bool Load(); 112 bool Load();
113 113
114 // Unloads the plugin library. 114 // Unloads the plugin library.
115 void Unload(); 115 void Unload();
116 116
117 // Shutdown the plugin library. 117 // Shutdown the plugin library.
118 void Shutdown(); 118 void Shutdown();
119 119
120 private: 120 private:
121 bool internal_; // True for plugins that are built-in into chrome binaries. 121 bool internal_; // True for plugins that are built-in into chrome binaries.
122 WebPluginInfo web_plugin_info_; // Supported mime types, description 122 webkit::WebPluginInfo web_plugin_info_; // Supported mime types, description
123 base::NativeLibrary library_; // The opened library reference. 123 base::NativeLibrary library_; // The opened library reference.
124 NPPluginFuncs plugin_funcs_; // The struct of plugin side functions. 124 NPPluginFuncs plugin_funcs_; // The struct of plugin side functions.
125 bool initialized_; // Is the plugin initialized? 125 bool initialized_; // Is the plugin initialized?
126 NPSavedData *saved_data_; // Persisted plugin info for NPAPI. 126 NPSavedData *saved_data_; // Persisted plugin info for NPAPI.
127 int instance_count_; // Count of plugins in use. 127 int instance_count_; // Count of plugins in use.
128 bool skip_unload_; // True if library_ should not be unloaded. 128 bool skip_unload_; // True if library_ should not be unloaded.
129 129
130 // Function pointers to entry points into the plugin. 130 // Function pointers to entry points into the plugin.
131 PluginEntryPoints entry_points_; 131 PluginEntryPoints entry_points_;
132 132
133 // Set to true if unloading of the plugin dll is to be deferred. 133 // Set to true if unloading of the plugin dll is to be deferred.
134 bool defer_unload_; 134 bool defer_unload_;
135 135
136 DISALLOW_COPY_AND_ASSIGN(PluginLib); 136 DISALLOW_COPY_AND_ASSIGN(PluginLib);
137 }; 137 };
138 138
139 } // namespace npapi 139 } // namespace npapi
140 } // namespace webkit 140 } // namespace webkit
141 141
142 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_ 142 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_host.cc ('k') | webkit/plugins/npapi/plugin_lib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698