| 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 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 19 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
| 20 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" | 20 #include "ppapi/c/dev/ppp_graphics_3d_dev.h" |
| 21 #include "ppapi/c/dev/ppp_printing_dev.h" | 21 #include "ppapi/c/dev/ppp_printing_dev.h" |
| 22 #include "ppapi/c/pp_instance.h" | 22 #include "ppapi/c/pp_instance.h" |
| 23 #include "ppapi/c/pp_resource.h" | 23 #include "ppapi/c/pp_resource.h" |
| 24 #include "ppapi/c/pp_var.h" | 24 #include "ppapi/c/pp_var.h" |
| 25 #include "ppapi/c/ppp_instance.h" | 25 #include "ppapi/c/ppp_instance.h" |
| 26 #include "ppapi/shared_impl/function_group_base.h" | 26 #include "ppapi/shared_impl/function_group_base.h" |
| 27 #include "ppapi/shared_impl/ppp_instance_combined.h" |
| 27 #include "ppapi/thunk/ppb_instance_api.h" | 28 #include "ppapi/thunk/ppb_instance_api.h" |
| 28 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 29 #include "third_party/skia/include/core/SkRefCnt.h" | 30 #include "third_party/skia/include/core/SkRefCnt.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" |
| 31 #include "ui/gfx/rect.h" | 32 #include "ui/gfx/rect.h" |
| 32 #include "webkit/plugins/ppapi/plugin_delegate.h" | 33 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 33 | 34 |
| 34 typedef struct NPObject NPObject; | 35 typedef struct NPObject NPObject; |
| 35 struct PP_Var; | 36 struct PP_Var; |
| 36 struct PPB_Messaging; | 37 struct PPB_Messaging; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 namespace gfx { | 49 namespace gfx { |
| 49 class Rect; | 50 class Rect; |
| 50 } | 51 } |
| 51 | 52 |
| 52 namespace WebKit { | 53 namespace WebKit { |
| 53 struct WebCursorInfo; | 54 struct WebCursorInfo; |
| 54 class WebInputEvent; | 55 class WebInputEvent; |
| 55 class WebPluginContainer; | 56 class WebPluginContainer; |
| 56 } | 57 } |
| 57 | 58 |
| 59 namespace ppapi { |
| 60 struct PPP_Instance_Combined; |
| 61 } |
| 62 |
| 58 namespace webkit { | 63 namespace webkit { |
| 59 namespace ppapi { | 64 namespace ppapi { |
| 60 | 65 |
| 61 class FullscreenContainer; | 66 class FullscreenContainer; |
| 62 class MessageChannel; | 67 class MessageChannel; |
| 63 class ObjectVar; | 68 class ObjectVar; |
| 64 class PluginDelegate; | 69 class PluginDelegate; |
| 65 class PluginModule; | 70 class PluginModule; |
| 66 class PluginObject; | 71 class PluginObject; |
| 67 class PPB_Graphics2D_Impl; | 72 class PPB_Graphics2D_Impl; |
| 68 class PPB_ImageData_Impl; | 73 class PPB_ImageData_Impl; |
| 69 class PPB_Surface3D_Impl; | 74 class PPB_Surface3D_Impl; |
| 70 class PPB_URLLoader_Impl; | 75 class PPB_URLLoader_Impl; |
| 71 class PPB_URLRequestInfo_Impl; | 76 class PPB_URLRequestInfo_Impl; |
| 72 class Resource; | 77 class Resource; |
| 73 | 78 |
| 74 // Represents one time a plugin appears on one web page. | 79 // Represents one time a plugin appears on one web page. |
| 75 // | 80 // |
| 76 // Note: to get from a PP_Instance to a PluginInstance*, use the | 81 // Note: to get from a PP_Instance to a PluginInstance*, use the |
| 77 // ResourceTracker. | 82 // ResourceTracker. |
| 78 class PluginInstance : public base::RefCounted<PluginInstance>, | 83 class PluginInstance : public base::RefCounted<PluginInstance>, |
| 79 public ::ppapi::FunctionGroupBase, | 84 public ::ppapi::FunctionGroupBase, |
| 80 public ::ppapi::thunk::PPB_Instance_FunctionAPI { | 85 public ::ppapi::thunk::PPB_Instance_FunctionAPI { |
| 81 public: | 86 public: |
| 82 struct PPP_Instance_Combined; | 87 // Create and return a PluginInstance object which supports the |
| 88 // PPP_Instance_0_5 interface. |
| 89 static PluginInstance* Create0_5(PluginDelegate* delegate, |
| 90 PluginModule* module, |
| 91 const void* ppp_instance_if_0_5); |
| 83 | 92 |
| 84 PluginInstance(PluginDelegate* delegate, | 93 // Create and return a PluginInstance object which supports the |
| 85 PluginModule* module, | 94 // PPP_Instance_0_4 interface. |
| 86 PPP_Instance_Combined* instance_interface); | 95 static PluginInstance* Create0_4(PluginDelegate* delegate, |
| 96 PluginModule* module, |
| 97 const void* ppp_instance_if_0_4); |
| 87 | 98 |
| 88 // Delete should be called by the WebPlugin before this destructor. | 99 // Delete should be called by the WebPlugin before this destructor. |
| 89 virtual ~PluginInstance(); | 100 virtual ~PluginInstance(); |
| 90 | 101 |
| 91 // Returns a pointer to the interface implementing PPB_Find that is | 102 // Returns a pointer to the interface implementing PPB_Find that is |
| 92 // exposed to the plugin. | 103 // exposed to the plugin. |
| 93 static const PPB_Messaging* GetMessagingInterface(); | 104 static const PPB_Messaging* GetMessagingInterface(); |
| 94 static const PPB_Zoom_Dev* GetZoomInterface(); | 105 static const PPB_Zoom_Dev* GetZoomInterface(); |
| 95 | 106 |
| 96 PluginDelegate* delegate() const { return delegate_; } | 107 PluginDelegate* delegate() const { return delegate_; } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 ObjectVar* ObjectVarForNPObject(NPObject* np_object) const; | 260 ObjectVar* ObjectVarForNPObject(NPObject* np_object) const; |
| 250 | 261 |
| 251 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or | 262 // Returns true iff the plugin is a full-page plugin (i.e. not in an iframe or |
| 252 // embedded in a page). | 263 // embedded in a page). |
| 253 bool IsFullPagePlugin() const; | 264 bool IsFullPagePlugin() const; |
| 254 | 265 |
| 255 FullscreenContainer* fullscreen_container() const { | 266 FullscreenContainer* fullscreen_container() const { |
| 256 return fullscreen_container_; | 267 return fullscreen_container_; |
| 257 } | 268 } |
| 258 | 269 |
| 259 // TODO(dmichael): Remove this when all plugins are ported to use scripting | |
| 260 // from private interfaces. | |
| 261 struct PPP_Instance_Combined : public PPP_Instance_0_5 { | |
| 262 PPP_Instance_Combined(const PPP_Instance_0_5& instance_if); | |
| 263 PPP_Instance_Combined(const PPP_Instance_0_4& instance_if); | |
| 264 | |
| 265 struct PP_Var (*const GetInstanceObject_0_4)(PP_Instance instance); | |
| 266 }; | |
| 267 template <class InterfaceType> | |
| 268 static PPP_Instance_Combined* new_instance_interface( | |
| 269 const void* interface_object) { | |
| 270 return new PPP_Instance_Combined( | |
| 271 *static_cast<const InterfaceType*>(interface_object)); | |
| 272 } | |
| 273 | |
| 274 // FunctionGroupBase overrides. | 270 // FunctionGroupBase overrides. |
| 275 virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() | 271 virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() |
| 276 OVERRIDE; | 272 OVERRIDE; |
| 277 | 273 |
| 278 // PPB_Instance_API implementation. | 274 // PPB_Instance_API implementation. |
| 279 virtual PP_Bool BindGraphics(PP_Instance instance, | 275 virtual PP_Bool BindGraphics(PP_Instance instance, |
| 280 PP_Resource device) OVERRIDE; | 276 PP_Resource device) OVERRIDE; |
| 281 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; | 277 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; |
| 282 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; | 278 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; |
| 283 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; | 279 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; |
| 284 virtual PP_Var ExecuteScript(PP_Instance instance, | 280 virtual PP_Var ExecuteScript(PP_Instance instance, |
| 285 PP_Var script, | 281 PP_Var script, |
| 286 PP_Var* exception) OVERRIDE; | 282 PP_Var* exception) OVERRIDE; |
| 287 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; | 283 virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; |
| 288 virtual PP_Bool SetFullscreen(PP_Instance instance, | 284 virtual PP_Bool SetFullscreen(PP_Instance instance, |
| 289 PP_Bool fullscreen) OVERRIDE; | 285 PP_Bool fullscreen) OVERRIDE; |
| 290 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; | 286 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; |
| 291 | 287 |
| 292 private: | 288 private: |
| 289 // See the static Create functions above for creating PluginInstance objects. |
| 290 // This constructor is private so that we can hide the PPP_Instance_Combined |
| 291 // details while still having 1 constructor to maintain for member |
| 292 // initialization. |
| 293 PluginInstance(PluginDelegate* delegate, |
| 294 PluginModule* module, |
| 295 ::ppapi::PPP_Instance_Combined* instance_interface); |
| 296 |
| 293 bool LoadFindInterface(); | 297 bool LoadFindInterface(); |
| 294 bool LoadMessagingInterface(); | 298 bool LoadMessagingInterface(); |
| 295 bool LoadPdfInterface(); | 299 bool LoadPdfInterface(); |
| 296 bool LoadSelectionInterface(); | 300 bool LoadSelectionInterface(); |
| 297 bool LoadPrintInterface(); | 301 bool LoadPrintInterface(); |
| 298 bool LoadPrivateInterface(); | 302 bool LoadPrivateInterface(); |
| 299 bool LoadZoomInterface(); | 303 bool LoadZoomInterface(); |
| 300 | 304 |
| 301 // Determines if we think the plugin has focus, both content area and webkit | 305 // Determines if we think the plugin has focus, both content area and webkit |
| 302 // (see has_webkit_focus_ below). | 306 // (see has_webkit_focus_ below). |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // A value of zero indicates the plugin is not backed by a texture. | 340 // A value of zero indicates the plugin is not backed by a texture. |
| 337 void setBackingTextureId(unsigned int id); | 341 void setBackingTextureId(unsigned int id); |
| 338 | 342 |
| 339 // Internal helper function for PrintPage(). | 343 // Internal helper function for PrintPage(). |
| 340 bool PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, | 344 bool PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, |
| 341 int num_ranges, | 345 int num_ranges, |
| 342 WebKit::WebCanvas* canvas); | 346 WebKit::WebCanvas* canvas); |
| 343 | 347 |
| 344 PluginDelegate* delegate_; | 348 PluginDelegate* delegate_; |
| 345 scoped_refptr<PluginModule> module_; | 349 scoped_refptr<PluginModule> module_; |
| 346 scoped_ptr<PPP_Instance_Combined> instance_interface_; | 350 scoped_ptr< ::ppapi::PPP_Instance_Combined> instance_interface_; |
| 347 | 351 |
| 348 PP_Instance pp_instance_; | 352 PP_Instance pp_instance_; |
| 349 | 353 |
| 350 // NULL until we have been initialized. | 354 // NULL until we have been initialized. |
| 351 WebKit::WebPluginContainer* container_; | 355 WebKit::WebPluginContainer* container_; |
| 352 | 356 |
| 353 // Plugin URL. | 357 // Plugin URL. |
| 354 GURL plugin_url_; | 358 GURL plugin_url_; |
| 355 | 359 |
| 356 // Indicates whether this is a full frame instance, which means it represents | 360 // Indicates whether this is a full frame instance, which means it represents |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; | 487 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; |
| 484 NPObjectToObjectVarMap np_object_to_object_var_; | 488 NPObjectToObjectVarMap np_object_to_object_var_; |
| 485 | 489 |
| 486 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 490 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
| 487 }; | 491 }; |
| 488 | 492 |
| 489 } // namespace ppapi | 493 } // namespace ppapi |
| 490 } // namespace webkit | 494 } // namespace webkit |
| 491 | 495 |
| 492 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 496 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
| OLD | NEW |