| OLD | NEW |
| 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 // 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_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ |
| 9 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ | 9 #define WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <stack> | 12 #include <stack> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/file_path.h" | 17 #include "base/file_path.h" |
| 18 #include "base/ref_counted.h" | 18 #include "base/ref_counted.h" |
| 19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
| 20 #include "gfx/native_widget_types.h" | 20 #include "gfx/native_widget_types.h" |
| 21 #include "gfx/point.h" | 21 #include "gfx/point.h" |
| 22 #include "gfx/rect.h" | 22 #include "gfx/rect.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 #include "third_party/npapi/bindings/npapi.h" | 24 #include "third_party/npapi/bindings/npapi.h" |
| 25 #include "third_party/npapi/bindings/nphostapi.h" | 25 #include "third_party/npapi/bindings/nphostapi.h" |
| 26 | 26 |
| 27 class MessageLoop; | 27 class MessageLoop; |
| 28 | 28 |
| 29 namespace webkit { | 29 namespace webkit_glue { |
| 30 namespace npapi { | 30 class WebPlugin; |
| 31 class WebPluginResourceClient; |
| 32 } |
| 31 | 33 |
| 34 namespace NPAPI |
| 35 { |
| 32 class PluginLib; | 36 class PluginLib; |
| 33 class PluginHost; | 37 class PluginHost; |
| 34 class PluginStream; | 38 class PluginStream; |
| 35 class PluginStreamUrl; | 39 class PluginStreamUrl; |
| 36 class PluginDataStream; | 40 class PluginDataStream; |
| 37 class WebPlugin; | |
| 38 class WebPluginResourceClient; | |
| 39 | |
| 40 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
| 41 class ScopedCurrentPluginEvent; | 42 class ScopedCurrentPluginEvent; |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 // A PluginInstance is an active, running instance of a Plugin. | 45 // A PluginInstance is an active, running instance of a Plugin. |
| 45 // A single plugin may have many PluginInstances. | 46 // A single plugin may have many PluginInstances. |
| 46 class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { | 47 class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { |
| 47 public: | 48 public: |
| 48 // Create a new instance of a plugin. The PluginInstance | 49 // Create a new instance of a plugin. The PluginInstance |
| 49 // will hold a reference to the plugin. | 50 // will hold a reference to the plugin. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void set_windowless(bool value) { windowless_ = value; } | 89 void set_windowless(bool value) { windowless_ = value; } |
| 89 | 90 |
| 90 // Get/Set whether this instance is transparent. | 91 // Get/Set whether this instance is transparent. |
| 91 // This only applies to windowless plugins. Transparent | 92 // This only applies to windowless plugins. Transparent |
| 92 // plugins require that webkit paint the background. | 93 // plugins require that webkit paint the background. |
| 93 // Default is true. | 94 // Default is true. |
| 94 bool transparent() { return transparent_; } | 95 bool transparent() { return transparent_; } |
| 95 void set_transparent(bool value) { transparent_ = value; } | 96 void set_transparent(bool value) { transparent_ = value; } |
| 96 | 97 |
| 97 // Get/Set the WebPlugin associated with this instance | 98 // Get/Set the WebPlugin associated with this instance |
| 98 WebPlugin* webplugin() { return webplugin_; } | 99 webkit_glue::WebPlugin* webplugin() { return webplugin_; } |
| 99 void set_web_plugin(WebPlugin* webplugin) { | 100 void set_web_plugin(webkit_glue::WebPlugin* webplugin) { |
| 100 webplugin_ = webplugin; | 101 webplugin_ = webplugin; |
| 101 } | 102 } |
| 102 | 103 |
| 103 // Get the mimeType for this plugin stream | 104 // Get the mimeType for this plugin stream |
| 104 const std::string &mime_type() { return mime_type_; } | 105 const std::string &mime_type() { return mime_type_; } |
| 105 | 106 |
| 106 PluginLib* plugin_lib() { return plugin_; } | 107 NPAPI::PluginLib* plugin_lib() { return plugin_; } |
| 107 | 108 |
| 108 #if defined(OS_MACOSX) | 109 #if defined(OS_MACOSX) |
| 109 // Get/Set the Mac NPAPI drawing and event models | 110 // Get/Set the Mac NPAPI drawing and event models |
| 110 NPDrawingModel drawing_model() { return drawing_model_; } | 111 NPDrawingModel drawing_model() { return drawing_model_; } |
| 111 void set_drawing_model(NPDrawingModel value) { drawing_model_ = value; } | 112 void set_drawing_model(NPDrawingModel value) { drawing_model_ = value; } |
| 112 NPEventModel event_model() { return event_model_; } | 113 NPEventModel event_model() { return event_model_; } |
| 113 void set_event_model(NPEventModel value) { event_model_ = value; } | 114 void set_event_model(NPEventModel value) { event_model_ = value; } |
| 114 // Updates the instance's tracking of the location of the plugin location | 115 // Updates the instance's tracking of the location of the plugin location |
| 115 // relative to the upper left of the screen. | 116 // relative to the upper left of the screen. |
| 116 void set_plugin_origin(const gfx::Point& origin) { plugin_origin_ = origin; } | 117 void set_plugin_origin(const gfx::Point& origin) { plugin_origin_ = origin; } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 140 | 141 |
| 141 // This is called when a stream is closed. We remove the stream from the | 142 // This is called when a stream is closed. We remove the stream from the |
| 142 // list, which releases the reference maintained to the stream. | 143 // list, which releases the reference maintained to the stream. |
| 143 void RemoveStream(PluginStream* stream); | 144 void RemoveStream(PluginStream* stream); |
| 144 | 145 |
| 145 // Closes all open streams on this instance. | 146 // Closes all open streams on this instance. |
| 146 void CloseStreams(); | 147 void CloseStreams(); |
| 147 | 148 |
| 148 // Returns the WebPluginResourceClient object for a stream that has become | 149 // Returns the WebPluginResourceClient object for a stream that has become |
| 149 // seekable. | 150 // seekable. |
| 150 WebPluginResourceClient* GetRangeRequest(int id); | 151 webkit_glue::WebPluginResourceClient* GetRangeRequest(int id); |
| 151 | 152 |
| 152 // Have the plugin create it's script object. | 153 // Have the plugin create it's script object. |
| 153 NPObject *GetPluginScriptableObject(); | 154 NPObject *GetPluginScriptableObject(); |
| 154 | 155 |
| 155 // WebViewDelegate methods that we implement. This is for handling | 156 // WebViewDelegate methods that we implement. This is for handling |
| 156 // callbacks during getURLNotify. | 157 // callbacks during getURLNotify. |
| 157 void DidFinishLoadWithReason(const GURL& url, NPReason reason, int notify_id); | 158 void DidFinishLoadWithReason(const GURL& url, NPReason reason, int notify_id); |
| 158 | 159 |
| 159 // If true, send the Mozilla user agent instead of Chrome's to the plugin. | 160 // If true, send the Mozilla user agent instead of Chrome's to the plugin. |
| 160 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } | 161 bool use_mozilla_user_agent() { return use_mozilla_user_agent_; } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // player checks:(. They crash with version 6.0.11.3088 as well. The | 277 // player checks:(. They crash with version 6.0.11.3088 as well. The |
| 277 // following member just adds a 96 byte padding to our PluginInstance class | 278 // following member just adds a 96 byte padding to our PluginInstance class |
| 278 // which is passed in the ndata member. This magic number works correctly on | 279 // which is passed in the ndata member. This magic number works correctly on |
| 279 // Vista with UAC on or off :(. | 280 // Vista with UAC on or off :(. |
| 280 // NOTE: Please dont change the ordering of the member variables | 281 // NOTE: Please dont change the ordering of the member variables |
| 281 // New members should be added after this padding array. | 282 // New members should be added after this padding array. |
| 282 // TODO(iyengar) : Disassemble the Realplayer ndata structure and look into | 283 // TODO(iyengar) : Disassemble the Realplayer ndata structure and look into |
| 283 // the possiblity of conforming to it (http://b/issue?id=936667). We | 284 // the possiblity of conforming to it (http://b/issue?id=936667). We |
| 284 // could also log a bug with Real, which would save the effort. | 285 // could also log a bug with Real, which would save the effort. |
| 285 uint8 zero_padding_[96]; | 286 uint8 zero_padding_[96]; |
| 286 scoped_refptr<PluginLib> plugin_; | 287 scoped_refptr<NPAPI::PluginLib> plugin_; |
| 287 NPP npp_; | 288 NPP npp_; |
| 288 scoped_refptr<PluginHost> host_; | 289 scoped_refptr<PluginHost> host_; |
| 289 NPPluginFuncs* npp_functions_; | 290 NPPluginFuncs* npp_functions_; |
| 290 std::vector<scoped_refptr<PluginStream> > open_streams_; | 291 std::vector<scoped_refptr<PluginStream> > open_streams_; |
| 291 gfx::PluginWindowHandle window_handle_; | 292 gfx::PluginWindowHandle window_handle_; |
| 292 bool windowless_; | 293 bool windowless_; |
| 293 bool transparent_; | 294 bool transparent_; |
| 294 WebPlugin* webplugin_; | 295 webkit_glue::WebPlugin* webplugin_; |
| 295 std::string mime_type_; | 296 std::string mime_type_; |
| 296 GURL get_url_; | 297 GURL get_url_; |
| 297 intptr_t get_notify_data_; | 298 intptr_t get_notify_data_; |
| 298 bool use_mozilla_user_agent_; | 299 bool use_mozilla_user_agent_; |
| 299 #if defined(OS_MACOSX) | 300 #if defined(OS_MACOSX) |
| 300 NPDrawingModel drawing_model_; | 301 NPDrawingModel drawing_model_; |
| 301 NPEventModel event_model_; | 302 NPEventModel event_model_; |
| 302 gfx::Point plugin_origin_; | 303 gfx::Point plugin_origin_; |
| 303 gfx::Rect containing_window_frame_; | 304 gfx::Rect containing_window_frame_; |
| 304 NPCocoaEvent* currently_handled_event_; // weak | 305 NPCocoaEvent* currently_handled_event_; // weak |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 363 } |
| 363 ~ScopedCurrentPluginEvent() { | 364 ~ScopedCurrentPluginEvent() { |
| 364 instance_->set_currently_handled_event(NULL); | 365 instance_->set_currently_handled_event(NULL); |
| 365 } | 366 } |
| 366 private: | 367 private: |
| 367 scoped_refptr<PluginInstance> instance_; | 368 scoped_refptr<PluginInstance> instance_; |
| 368 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); | 369 DISALLOW_COPY_AND_ASSIGN(ScopedCurrentPluginEvent); |
| 369 }; | 370 }; |
| 370 #endif | 371 #endif |
| 371 | 372 |
| 372 } // namespace npapi | 373 } // namespace NPAPI |
| 373 } // namespace webkit | |
| 374 | 374 |
| 375 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_INSTANCE_H_ | 375 #endif // WEBKIT_GLUE_PLUGIN_PLUGIN_INSTANCE_H__ |
| OLD | NEW |