OLD | NEW |
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 // TODO: Need to deal with NPAPI's NPSavedData. | 5 // TODO: Need to deal with NPAPI's NPSavedData. |
6 // I haven't seen plugins use it yet. | 6 // I haven't seen plugins use it yet. |
7 | 7 |
8 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ | 8 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ |
9 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ | 9 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 class MessageLoop; | 27 class MessageLoop; |
28 | 28 |
29 namespace webkit { | 29 namespace webkit { |
30 namespace npapi { | 30 namespace npapi { |
31 | 31 |
32 class PluginLib; | 32 class PluginLib; |
33 class PluginHost; | 33 class PluginHost; |
34 class PluginStream; | 34 class PluginStream; |
35 class PluginStreamUrl; | 35 class PluginStreamUrl; |
36 class PluginDataStream; | |
37 class WebPlugin; | 36 class WebPlugin; |
38 class WebPluginResourceClient; | 37 class WebPluginResourceClient; |
39 | 38 |
40 #if defined(OS_MACOSX) | 39 #if defined(OS_MACOSX) |
41 class ScopedCurrentPluginEvent; | 40 class ScopedCurrentPluginEvent; |
42 #endif | 41 #endif |
43 | 42 |
44 // A PluginInstance is an active, running instance of a Plugin. | 43 // A PluginInstance is an active, running instance of a Plugin. |
45 // A single plugin may have many PluginInstances. | 44 // A single plugin may have many PluginInstances. |
46 class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { | 45 class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { |
47 public: | 46 public: |
48 // Create a new instance of a plugin. The PluginInstance | 47 // Create a new instance of a plugin. The PluginInstance |
49 // will hold a reference to the plugin. | 48 // will hold a reference to the plugin. |
50 PluginInstance(PluginLib *plugin, const std::string &mime_type); | 49 PluginInstance(PluginLib* plugin, const std::string &mime_type); |
51 | 50 |
52 // Activates the instance by calling NPP_New. | 51 // Activates the instance by calling NPP_New. |
53 // This should be called after our instance is all | 52 // This should be called after our instance is all |
54 // setup from the host side and we are ready to receive | 53 // setup from the host side and we are ready to receive |
55 // requests from the plugin. We must not call any | 54 // requests from the plugin. We must not call any |
56 // functions on the plugin instance until start has | 55 // functions on the plugin instance until start has |
57 // been called. | 56 // been called. |
58 // | 57 // |
59 // url: The instance URL. | 58 // url: The instance URL. |
60 // param_names: the list of names of attributes passed via the | 59 // param_names: the list of names of attributes passed via the |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void RemoveStream(PluginStream* stream); | 142 void RemoveStream(PluginStream* stream); |
144 | 143 |
145 // Closes all open streams on this instance. | 144 // Closes all open streams on this instance. |
146 void CloseStreams(); | 145 void CloseStreams(); |
147 | 146 |
148 // Returns the WebPluginResourceClient object for a stream that has become | 147 // Returns the WebPluginResourceClient object for a stream that has become |
149 // seekable. | 148 // seekable. |
150 WebPluginResourceClient* GetRangeRequest(int id); | 149 WebPluginResourceClient* GetRangeRequest(int id); |
151 | 150 |
152 // Have the plugin create it's script object. | 151 // Have the plugin create it's script object. |
153 NPObject *GetPluginScriptableObject(); | 152 NPObject* GetPluginScriptableObject(); |
154 | 153 |
155 // Returns the form value of this instance. | 154 // Returns the form value of this instance. |
156 bool GetFormValue(string16* value); | 155 bool GetFormValue(string16* value); |
157 | 156 |
158 // WebViewDelegate methods that we implement. This is for handling | 157 // WebViewDelegate methods that we implement. This is for handling |
159 // callbacks during getURLNotify. | 158 // callbacks during getURLNotify. |
160 void DidFinishLoadWithReason(const GURL& url, NPReason reason, int notify_id); | 159 void DidFinishLoadWithReason(const GURL& url, NPReason reason, int notify_id); |
161 | 160 |
162 // If true, send the Mozilla user agent instead of Chrome's to the plugin. | 161 // If true, send the Mozilla user agent instead of Chrome's to the plugin. |
163 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } | 162 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } |
164 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } | 163 void set_use_mozilla_user_agent() { use_mozilla_user_agent_ = true; } |
165 | 164 |
166 // If the plugin instance is backed by a texture, return its ID in the | 165 // If the plugin instance is backed by a texture, return its ID in the |
167 // compositor's namespace. Otherwise return 0. Returns 0 by default. | 166 // compositor's namespace. Otherwise return 0. Returns 0 by default. |
168 unsigned GetBackingTextureId(); | 167 unsigned GetBackingTextureId(); |
169 | 168 |
170 // Helper that implements NPN_PluginThreadAsyncCall semantics | 169 // Helper that implements NPN_PluginThreadAsyncCall semantics |
171 void PluginThreadAsyncCall(void (*func)(void *), | 170 void PluginThreadAsyncCall(void (*func)(void *), |
172 void *userData); | 171 void* userData); |
173 | 172 |
174 uint32 ScheduleTimer(uint32 interval, | 173 uint32 ScheduleTimer(uint32 interval, |
175 NPBool repeat, | 174 NPBool repeat, |
176 void (*func)(NPP id, uint32 timer_id)); | 175 void (*func)(NPP id, uint32 timer_id)); |
177 | 176 |
178 void UnscheduleTimer(uint32 timer_id); | 177 void UnscheduleTimer(uint32 timer_id); |
179 | 178 |
180 bool ConvertPoint(double source_x, double source_y, | 179 bool ConvertPoint(double source_x, double source_y, |
181 NPCoordinateSpace source_space, | 180 NPCoordinateSpace source_space, |
182 double* dest_x, double* dest_y, | 181 double* dest_x, double* dest_y, |
183 NPCoordinateSpace dest_space); | 182 NPCoordinateSpace dest_space); |
184 | 183 |
185 NPError PopUpContextMenu(NPMenu* menu); | 184 NPError PopUpContextMenu(NPMenu* menu); |
186 | 185 |
187 // | 186 // |
188 // NPAPI methods for calling the Plugin Instance | 187 // NPAPI methods for calling the Plugin Instance |
189 // | 188 // |
190 NPError NPP_New(unsigned short, short, char *[], char *[]); | 189 NPError NPP_New(unsigned short, short, char *[], char *[]); |
191 NPError NPP_SetWindow(NPWindow *); | 190 NPError NPP_SetWindow(NPWindow*); |
192 NPError NPP_NewStream(NPMIMEType, NPStream *, NPBool, unsigned short *); | 191 NPError NPP_NewStream(NPMIMEType, NPStream*, NPBool, unsigned short*); |
193 NPError NPP_DestroyStream(NPStream *, NPReason); | 192 NPError NPP_DestroyStream(NPStream*, NPReason); |
194 int NPP_WriteReady(NPStream *); | 193 int NPP_WriteReady(NPStream*); |
195 int NPP_Write(NPStream *, int, int, void *); | 194 int NPP_Write(NPStream*, int, int, void*); |
196 void NPP_StreamAsFile(NPStream *, const char *); | 195 void NPP_StreamAsFile(NPStream*, const char*); |
197 void NPP_URLNotify(const char *, NPReason, void *); | 196 void NPP_URLNotify(const char*, NPReason, void*); |
198 NPError NPP_GetValue(NPPVariable, void *); | 197 NPError NPP_GetValue(NPPVariable, void*); |
199 NPError NPP_SetValue(NPNVariable, void *); | 198 NPError NPP_SetValue(NPNVariable, void*); |
200 short NPP_HandleEvent(void*); | 199 short NPP_HandleEvent(void*); |
201 void NPP_Destroy(); | 200 void NPP_Destroy(); |
202 bool NPP_Print(NPPrint* platform_print); | 201 bool NPP_Print(NPPrint* platform_print); |
203 void NPP_URLRedirectNotify(const char* url, int32_t status, | 202 void NPP_URLRedirectNotify(const char* url, int32_t status, |
204 void* notify_data); | 203 void* notify_data); |
205 | 204 |
206 void SendJavaScriptStream(const GURL& url, | 205 void SendJavaScriptStream(const GURL& url, |
207 const std::string& result, | 206 const std::string& result, |
208 bool success, | 207 bool success, |
209 int notify_id); | 208 int notify_id); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Sets the event that the plugin is currently handling. The object is not | 250 // Sets the event that the plugin is currently handling. The object is not |
252 // owned or copied, so the caller must call this again with NULL before the | 251 // owned or copied, so the caller must call this again with NULL before the |
253 // event pointer becomes invalid. Clients use ScopedCurrentPluginEvent rather | 252 // event pointer becomes invalid. Clients use ScopedCurrentPluginEvent rather |
254 // than calling this directly. | 253 // than calling this directly. |
255 void set_currently_handled_event(NPCocoaEvent* event) { | 254 void set_currently_handled_event(NPCocoaEvent* event) { |
256 currently_handled_event_ = event; | 255 currently_handled_event_ = event; |
257 } | 256 } |
258 #endif | 257 #endif |
259 | 258 |
260 ~PluginInstance(); | 259 ~PluginInstance(); |
261 void OnPluginThreadAsyncCall(void (*func)(void *), void *userData); | 260 void OnPluginThreadAsyncCall(void (*func)(void *), void* userData); |
262 void OnTimerCall(void (*func)(NPP id, uint32 timer_id), | 261 void OnTimerCall(void (*func)(NPP id, uint32 timer_id), |
263 NPP id, uint32 timer_id); | 262 NPP id, uint32 timer_id); |
264 bool IsValidStream(const NPStream* stream); | 263 bool IsValidStream(const NPStream* stream); |
265 void GetNotifyData(int notify_id, bool* notify, void** notify_data); | 264 void GetNotifyData(int notify_id, bool* notify, void** notify_data); |
266 | 265 |
267 // This is a hack to get the real player plugin to work with chrome | 266 // This is a hack to get the real player plugin to work with chrome |
268 // The real player plugin dll(nppl3260) when loaded by firefox is loaded via | 267 // The real player plugin dll(nppl3260) when loaded by firefox is loaded via |
269 // the NS COM API which is analogous to win32 COM. So the NPAPI functions in | 268 // the NS COM API which is analogous to win32 COM. So the NPAPI functions in |
270 // the plugin are invoked via an interface by firefox. The plugin instance | 269 // the plugin are invoked via an interface by firefox. The plugin instance |
271 // handle which is passed to every NPAPI method is owned by the real player | 270 // handle which is passed to every NPAPI method is owned by the real player |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 private: | 363 private: |
365 scoped_refptr<PluginInstance> instance_; | 364 scoped_refptr<PluginInstance> instance_; |
366 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); | 365 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); |
367 }; | 366 }; |
368 #endif | 367 #endif |
369 | 368 |
370 } // namespace npapi | 369 } // namespace npapi |
371 } // namespace webkit | 370 } // namespace webkit |
372 | 371 |
373 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ | 372 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ |
OLD | NEW |