OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PPAPI_PLUGIN_MODULE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/native_library.h" | 17 #include "base/native_library.h" |
18 #include "base/process.h" | 18 #include "base/process.h" |
19 #include "ppapi/c/pp_bool.h" | 19 #include "ppapi/c/pp_bool.h" |
20 #include "ppapi/c/pp_instance.h" | 20 #include "ppapi/c/pp_instance.h" |
21 #include "ppapi/c/pp_module.h" | 21 #include "ppapi/c/pp_module.h" |
22 #include "ppapi/c/ppb.h" | 22 #include "ppapi/c/ppb.h" |
23 #include "ppapi/c/ppb_core.h" | 23 #include "ppapi/c/ppb_core.h" |
24 #include "ppapi/c/private/ppb_nacl_private.h" | 24 #include "ppapi/c/private/ppb_nacl_private.h" |
25 #include "ppapi/shared_impl/ppapi_permissions.h" | 25 #include "ppapi/shared_impl/ppapi_permissions.h" |
26 #include "webkit/plugins/ppapi/plugin_delegate.h" | 26 #include "webkit/plugins/ppapi/plugin_delegate.h" |
27 #include "webkit/plugins/webkit_plugins_export.h" | 27 #include "webkit/plugins/webkit_plugins_export.h" |
28 | 28 |
| 29 typedef void* NPIdentifier; |
| 30 |
| 31 namespace base { |
29 class FilePath; | 32 class FilePath; |
30 typedef void* NPIdentifier; | 33 } |
31 | 34 |
32 namespace ppapi { | 35 namespace ppapi { |
33 class CallbackTracker; | 36 class CallbackTracker; |
34 class WebKitForwarding; | 37 class WebKitForwarding; |
35 } // namespace ppapi | 38 } // namespace ppapi |
36 | 39 |
37 namespace WebKit { | 40 namespace WebKit { |
38 class WebPluginContainer; | 41 class WebPluginContainer; |
39 } // namespace WebKit | 42 } // namespace WebKit |
40 | 43 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 79 |
77 typedef std::set<PluginInstance*> PluginInstanceSet; | 80 typedef std::set<PluginInstance*> PluginInstanceSet; |
78 | 81 |
79 // You must call one of the Init functions after the constructor to create a | 82 // You must call one of the Init functions after the constructor to create a |
80 // module of the type you desire. | 83 // module of the type you desire. |
81 // | 84 // |
82 // The module lifetime delegate is a non-owning pointer that must outlive | 85 // The module lifetime delegate is a non-owning pointer that must outlive |
83 // all plugin modules. In practice it will be a global singleton that | 86 // all plugin modules. In practice it will be a global singleton that |
84 // tracks which modules are alive. | 87 // tracks which modules are alive. |
85 PluginModule(const std::string& name, | 88 PluginModule(const std::string& name, |
86 const FilePath& path, | 89 const base::FilePath& path, |
87 PluginDelegate::ModuleLifetime* lifetime_delegate, | 90 PluginDelegate::ModuleLifetime* lifetime_delegate, |
88 const ::ppapi::PpapiPermissions& perms); | 91 const ::ppapi::PpapiPermissions& perms); |
89 | 92 |
90 ~PluginModule(); | 93 ~PluginModule(); |
91 | 94 |
92 // Sets the given class as being associated with this module. It will be | 95 // Sets the given class as being associated with this module. It will be |
93 // deleted when the module is destroyed. You can only set it once, subsequent | 96 // deleted when the module is destroyed. You can only set it once, subsequent |
94 // sets will assert. | 97 // sets will assert. |
95 // | 98 // |
96 // See EmbedderState above for more. | 99 // See EmbedderState above for more. |
97 void SetEmbedderState(scoped_ptr<EmbedderState> state); | 100 void SetEmbedderState(scoped_ptr<EmbedderState> state); |
98 EmbedderState* GetEmbedderState(); | 101 EmbedderState* GetEmbedderState(); |
99 | 102 |
100 // Initializes this module as an internal plugin with the given entrypoints. | 103 // Initializes this module as an internal plugin with the given entrypoints. |
101 // This is used for "plugins" compiled into Chrome. Returns true on success. | 104 // This is used for "plugins" compiled into Chrome. Returns true on success. |
102 // False means that the plugin can not be used. | 105 // False means that the plugin can not be used. |
103 bool InitAsInternalPlugin(const EntryPoints& entry_points); | 106 bool InitAsInternalPlugin(const EntryPoints& entry_points); |
104 | 107 |
105 // Initializes this module using the given library path as the plugin. | 108 // Initializes this module using the given library path as the plugin. |
106 // Returns true on success. False means that the plugin can not be used. | 109 // Returns true on success. False means that the plugin can not be used. |
107 bool InitAsLibrary(const FilePath& path); | 110 bool InitAsLibrary(const base::FilePath& path); |
108 | 111 |
109 // Initializes this module for the given out of process proxy. This takes | 112 // Initializes this module for the given out of process proxy. This takes |
110 // ownership of the given pointer, even in the failure case. | 113 // ownership of the given pointer, even in the failure case. |
111 void InitAsProxied(PluginDelegate::OutOfProcessProxy* out_of_process_proxy); | 114 void InitAsProxied(PluginDelegate::OutOfProcessProxy* out_of_process_proxy); |
112 | 115 |
113 // Creates a new module for a NaCl instance that will be using the IPC proxy. | 116 // Creates a new module for a NaCl instance that will be using the IPC proxy. |
114 // We can't use the existing module, or new instances of the plugin can't | 117 // We can't use the existing module, or new instances of the plugin can't |
115 // be created. | 118 // be created. |
116 scoped_refptr<PluginModule> CreateModuleForNaClInstance(); | 119 scoped_refptr<PluginModule> CreateModuleForNaClInstance(); |
117 | 120 |
(...skipping 19 matching lines...) Expand all Loading... |
137 // registration. | 140 // registration. |
138 // NOTE: those custom interfaces provided by PpapiInterfaceFactoryManager | 141 // NOTE: those custom interfaces provided by PpapiInterfaceFactoryManager |
139 // will not be considered when called on the browser process. | 142 // will not be considered when called on the browser process. |
140 static bool SupportsInterface(const char* name); | 143 static bool SupportsInterface(const char* name); |
141 | 144 |
142 // Returns the module handle. This may be used before Init() is called (the | 145 // Returns the module handle. This may be used before Init() is called (the |
143 // proxy needs this information to set itself up properly). | 146 // proxy needs this information to set itself up properly). |
144 PP_Module pp_module() const { return pp_module_; } | 147 PP_Module pp_module() const { return pp_module_; } |
145 | 148 |
146 const std::string& name() const { return name_; } | 149 const std::string& name() const { return name_; } |
147 const FilePath& path() const { return path_; } | 150 const base::FilePath& path() const { return path_; } |
148 const ::ppapi::PpapiPermissions& permissions() const { return permissions_; } | 151 const ::ppapi::PpapiPermissions& permissions() const { return permissions_; } |
149 | 152 |
150 PluginInstance* CreateInstance(PluginDelegate* delegate, | 153 PluginInstance* CreateInstance(PluginDelegate* delegate, |
151 WebKit::WebPluginContainer* container, | 154 WebKit::WebPluginContainer* container, |
152 const GURL& plugin_url); | 155 const GURL& plugin_url); |
153 | 156 |
154 // Returns "some" plugin instance associated with this module. This is not | 157 // Returns "some" plugin instance associated with this module. This is not |
155 // guaranteed to be any one in particular. This is normally used to execute | 158 // guaranteed to be any one in particular. This is normally used to execute |
156 // callbacks up to the browser layer that are not inherently per-instance, | 159 // callbacks up to the browser layer that are not inherently per-instance, |
157 // but the delegate lives only on the plugin instance so we need one of them. | 160 // but the delegate lives only on the plugin instance so we need one of them. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // during destruction. | 237 // during destruction. |
235 base::NativeLibrary library_; | 238 base::NativeLibrary library_; |
236 | 239 |
237 // Contains pointers to the entry points of the actual plugin implementation. | 240 // Contains pointers to the entry points of the actual plugin implementation. |
238 // These will be NULL for out-of-process plugins, which is indicated by the | 241 // These will be NULL for out-of-process plugins, which is indicated by the |
239 // presence of the out_of_process_proxy_ value. | 242 // presence of the out_of_process_proxy_ value. |
240 EntryPoints entry_points_; | 243 EntryPoints entry_points_; |
241 | 244 |
242 // The name and file location of the module. | 245 // The name and file location of the module. |
243 const std::string name_; | 246 const std::string name_; |
244 const FilePath path_; | 247 const base::FilePath path_; |
245 | 248 |
246 ::ppapi::PpapiPermissions permissions_; | 249 ::ppapi::PpapiPermissions permissions_; |
247 | 250 |
248 // Non-owning pointers to all instances associated with this module. When | 251 // Non-owning pointers to all instances associated with this module. When |
249 // there are no more instances, this object should be deleted. | 252 // there are no more instances, this object should be deleted. |
250 PluginInstanceSet instances_; | 253 PluginInstanceSet instances_; |
251 | 254 |
252 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); | 255 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); |
253 | 256 |
254 DISALLOW_COPY_AND_ASSIGN(PluginModule); | 257 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
255 }; | 258 }; |
256 | 259 |
257 } // namespace ppapi | 260 } // namespace ppapi |
258 } // namespace webkit | 261 } // namespace webkit |
259 | 262 |
260 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ | 263 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
OLD | NEW |