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

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

Issue 19761007: Move NPAPI implementation out of webkit/plugins/npapi and into content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 7 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/native_library.h"
14 #include "build/build_config.h"
15 #include "third_party/npapi/bindings/nphostapi.h"
16 #include "webkit/plugins/npapi/webplugin.h"
17 #include "webkit/plugins/webkit_plugins_export.h"
18 #include "webkit/plugins/webplugininfo.h"
19
20 namespace base {
21 class FilePath;
22 }
23
24 namespace webkit {
25 namespace npapi {
26
27 class PluginInstance;
28
29 // This struct holds entry points into a plugin. The entry points are
30 // slightly different between Win/Mac and Unixes. Note that the interface for
31 // querying plugins is synchronous and it is preferable to use a higher-level
32 // asynchronous information to query information.
33 struct PluginEntryPoints {
34 #if !defined(OS_POSIX) || defined(OS_MACOSX)
35 NP_GetEntryPointsFunc np_getentrypoints;
36 #endif
37 NP_InitializeFunc np_initialize;
38 NP_ShutdownFunc np_shutdown;
39 };
40
41 // A PluginLib is a single NPAPI Plugin Library, and is the lifecycle
42 // manager for new PluginInstances.
43 class WEBKIT_PLUGINS_EXPORT PluginLib : public base::RefCounted<PluginLib> {
44 public:
45 static PluginLib* CreatePluginLib(const base::FilePath& filename);
46
47 // Unloads all the loaded plugin libraries and cleans up the plugin map.
48 static void UnloadAllPlugins();
49
50 // Shuts down all loaded plugin instances.
51 static void ShutdownAllPlugins();
52
53 // Get the Plugin's function pointer table.
54 NPPluginFuncs* functions();
55
56 // Creates a new instance of this plugin.
57 PluginInstance* CreateInstance(const std::string& mime_type);
58
59 // Called by the instance when the instance is tearing down.
60 void CloseInstance();
61
62 // Gets information about this plugin and the mime types that it
63 // supports.
64 const webkit::WebPluginInfo& plugin_info() { return web_plugin_info_; }
65
66 //
67 // NPAPI functions
68 //
69
70 // NPAPI method to initialize a Plugin.
71 // Initialize can be safely called multiple times
72 NPError NP_Initialize();
73
74 // NPAPI method to shutdown a Plugin.
75 void NP_Shutdown(void);
76
77 // NPAPI method to clear locally stored data (LSO's or "Flash cookies").
78 NPError NP_ClearSiteData(const char* site, uint64 flags, uint64 max_age);
79
80 // NPAPI method to get a NULL-terminated list of all sites under which data
81 // is stored.
82 char** NP_GetSitesWithData();
83
84 int instance_count() const { return instance_count_; }
85
86 // Prevents the library code from being unload when Unload() is called (since
87 // some plugins crash if unloaded).
88 void PreventLibraryUnload();
89
90 // Indicates whether plugin unload can be deferred.
91 void set_defer_unload(bool defer_unload) {
92 defer_unload_ = defer_unload;
93 }
94
95 // protected for testability.
96 protected:
97 friend class base::RefCounted<PluginLib>;
98
99 // Creates a new PluginLib.
100 explicit PluginLib(const webkit::WebPluginInfo& info);
101
102 virtual ~PluginLib();
103
104 // Attempts to load the plugin from the library.
105 // Returns true if it is a legitimate plugin, false otherwise
106 bool Load();
107
108 // Unloads the plugin library.
109 void Unload();
110
111 // Shutdown the plugin library.
112 void Shutdown();
113
114 private:
115 webkit::WebPluginInfo web_plugin_info_; // Supported mime types, description
116 base::NativeLibrary library_; // The opened library reference.
117 NPPluginFuncs plugin_funcs_; // The struct of plugin side functions.
118 bool initialized_; // Is the plugin initialized?
119 NPSavedData *saved_data_; // Persisted plugin info for NPAPI.
120 int instance_count_; // Count of plugins in use.
121 bool skip_unload_; // True if library_ should not be unloaded.
122
123 // Function pointers to entry points into the plugin.
124 PluginEntryPoints entry_points_;
125
126 // Set to true if unloading of the plugin dll is to be deferred.
127 bool defer_unload_;
128
129 DISALLOW_COPY_AND_ASSIGN(PluginLib);
130 };
131
132 } // namespace npapi
133 } // namespace webkit
134
135 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698