| 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_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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "ppapi/c/private/ppb_nacl_private.h" | 39 #include "ppapi/c/private/ppb_nacl_private.h" |
| 40 #include "ppapi/c/private/ppp_instance_private.h" | 40 #include "ppapi/c/private/ppp_instance_private.h" |
| 41 #include "ppapi/shared_impl/ppb_instance_shared.h" | 41 #include "ppapi/shared_impl/ppb_instance_shared.h" |
| 42 #include "ppapi/shared_impl/ppb_view_shared.h" | 42 #include "ppapi/shared_impl/ppb_view_shared.h" |
| 43 #include "ppapi/shared_impl/singleton_resource_id.h" | 43 #include "ppapi/shared_impl/singleton_resource_id.h" |
| 44 #include "ppapi/shared_impl/tracked_callback.h" | 44 #include "ppapi/shared_impl/tracked_callback.h" |
| 45 #include "ppapi/thunk/ppb_gamepad_api.h" | 45 #include "ppapi/thunk/ppb_gamepad_api.h" |
| 46 #include "ppapi/thunk/resource_creation_api.h" | 46 #include "ppapi/thunk/resource_creation_api.h" |
| 47 #include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h" | 47 #include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h" |
| 48 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 48 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 49 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoaderClient.
h" |
| 50 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" |
| 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
| 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureToken.h
" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureToken.h
" |
| 51 #include "third_party/skia/include/core/SkRefCnt.h" | 53 #include "third_party/skia/include/core/SkRefCnt.h" |
| 52 #include "ui/base/ime/text_input_type.h" | 54 #include "ui/base/ime/text_input_type.h" |
| 53 #include "ui/gfx/rect.h" | 55 #include "ui/gfx/rect.h" |
| 54 #include "webkit/plugins/ppapi/plugin_delegate.h" | 56 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 55 #include "webkit/plugins/ppapi/ppp_pdf.h" | 57 #include "webkit/plugins/ppapi/ppp_pdf.h" |
| 56 #include "webkit/plugins/webkit_plugins_export.h" | 58 #include "webkit/plugins/webkit_plugins_export.h" |
| 57 | 59 |
| 58 struct PP_Point; | 60 struct PP_Point; |
| 59 | 61 |
| 60 class SkBitmap; | 62 class SkBitmap; |
| 61 class TransportDIB; | 63 class TransportDIB; |
| 62 | 64 |
| 63 namespace WebKit { | 65 namespace WebKit { |
| 64 class WebInputEvent; | 66 class WebInputEvent; |
| 65 class WebLayer; | 67 class WebLayer; |
| 66 class WebMouseEvent; | 68 class WebMouseEvent; |
| 67 class WebPluginContainer; | 69 class WebPluginContainer; |
| 70 class WebURLLoader; |
| 71 class WebURLResponse; |
| 68 struct WebCompositionUnderline; | 72 struct WebCompositionUnderline; |
| 69 struct WebCursorInfo; | 73 struct WebCursorInfo; |
| 74 struct WebURLError; |
| 70 struct WebPrintParams; | 75 struct WebPrintParams; |
| 71 } | 76 } |
| 72 | 77 |
| 73 namespace cc { | 78 namespace cc { |
| 74 class TextureLayer; | 79 class TextureLayer; |
| 75 } | 80 } |
| 76 | 81 |
| 77 namespace ppapi { | 82 namespace ppapi { |
| 78 struct InputEventData; | 83 struct InputEventData; |
| 79 struct PPP_Instance_Combined; | 84 struct PPP_Instance_Combined; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 MessageChannel& message_channel() { return *message_channel_; } | 129 MessageChannel& message_channel() { return *message_channel_; } |
| 125 | 130 |
| 126 WebKit::WebPluginContainer* container() const { return container_; } | 131 WebKit::WebPluginContainer* container() const { return container_; } |
| 127 | 132 |
| 128 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } | 133 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } |
| 129 | 134 |
| 130 // Returns the PP_Instance uniquely identifying this instance. Guaranteed | 135 // Returns the PP_Instance uniquely identifying this instance. Guaranteed |
| 131 // nonzero. | 136 // nonzero. |
| 132 PP_Instance pp_instance() const { return pp_instance_; } | 137 PP_Instance pp_instance() const { return pp_instance_; } |
| 133 | 138 |
| 139 ::ppapi::PPP_Instance_Combined* instance_interface() const { |
| 140 return instance_interface_.get(); |
| 141 } |
| 142 |
| 134 ::ppapi::thunk::ResourceCreationAPI& resource_creation() { | 143 ::ppapi::thunk::ResourceCreationAPI& resource_creation() { |
| 135 return *resource_creation_.get(); | 144 return *resource_creation_.get(); |
| 136 } | 145 } |
| 137 | 146 |
| 138 // Does some pre-destructor cleanup on the instance. This is necessary | 147 // Does some pre-destructor cleanup on the instance. This is necessary |
| 139 // because some cleanup depends on the plugin instance still existing (like | 148 // because some cleanup depends on the plugin instance still existing (like |
| 140 // calling the plugin's DidDestroy function). This function is called from | 149 // calling the plugin's DidDestroy function). This function is called from |
| 141 // the WebPlugin implementation when WebKit is about to remove the plugin. | 150 // the WebPlugin implementation when WebKit is about to remove the plugin. |
| 142 void Delete(); | 151 void Delete(); |
| 143 | 152 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 166 void CommitBackingTexture(); | 175 void CommitBackingTexture(); |
| 167 | 176 |
| 168 // Called when the out-of-process plugin implementing this instance crashed. | 177 // Called when the out-of-process plugin implementing this instance crashed. |
| 169 void InstanceCrashed(); | 178 void InstanceCrashed(); |
| 170 | 179 |
| 171 // PPB_Instance and PPB_Instance_Private implementation. | 180 // PPB_Instance and PPB_Instance_Private implementation. |
| 172 const GURL& plugin_url() const { return plugin_url_; } | 181 const GURL& plugin_url() const { return plugin_url_; } |
| 173 bool full_frame() const { return full_frame_; } | 182 bool full_frame() const { return full_frame_; } |
| 174 const ::ppapi::ViewData& view_data() const { return view_data_; } | 183 const ::ppapi::ViewData& view_data() const { return view_data_; } |
| 175 | 184 |
| 176 // PPP_Instance and PPP_Instance_Private pass-through. | 185 // PPP_Instance and PPP_Instance_Private. |
| 177 bool Initialize(const std::vector<std::string>& arg_names, | 186 bool Initialize(const std::vector<std::string>& arg_names, |
| 178 const std::vector<std::string>& arg_values, | 187 const std::vector<std::string>& arg_values, |
| 179 bool full_frame); | 188 bool full_frame); |
| 180 bool HandleDocumentLoad(PPB_URLLoader_Impl* loader); | 189 bool HandleDocumentLoad(const WebKit::WebURLResponse& response); |
| 181 bool HandleInputEvent(const WebKit::WebInputEvent& event, | 190 bool HandleInputEvent(const WebKit::WebInputEvent& event, |
| 182 WebKit::WebCursorInfo* cursor_info); | 191 WebKit::WebCursorInfo* cursor_info); |
| 183 PP_Var GetInstanceObject(); | 192 PP_Var GetInstanceObject(); |
| 184 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip, | 193 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip, |
| 185 const std::vector<gfx::Rect>& cut_outs_rects); | 194 const std::vector<gfx::Rect>& cut_outs_rects); |
| 186 | 195 |
| 187 // Handlers for composition events. | 196 // Handlers for composition events. |
| 188 bool HandleCompositionStart(const base::string16& text); | 197 bool HandleCompositionStart(const base::string16& text); |
| 189 bool HandleCompositionUpdate( | 198 bool HandleCompositionUpdate( |
| 190 const base::string16& text, | 199 const base::string16& text, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // Simulates an input event to the plugin by passing it down to WebKit, | 354 // Simulates an input event to the plugin by passing it down to WebKit, |
| 346 // which sends it back up to the plugin as if it came from the user. | 355 // which sends it back up to the plugin as if it came from the user. |
| 347 void SimulateInputEvent(const ::ppapi::InputEventData& input_event); | 356 void SimulateInputEvent(const ::ppapi::InputEventData& input_event); |
| 348 | 357 |
| 349 // Simulates an IME event at the level of RenderView which sends it back up to | 358 // Simulates an IME event at the level of RenderView which sends it back up to |
| 350 // the plugin as if it came from the user. | 359 // the plugin as if it came from the user. |
| 351 bool SimulateIMEEvent(const ::ppapi::InputEventData& input_event); | 360 bool SimulateIMEEvent(const ::ppapi::InputEventData& input_event); |
| 352 void SimulateImeSetCompositionEvent( | 361 void SimulateImeSetCompositionEvent( |
| 353 const ::ppapi::InputEventData& input_event); | 362 const ::ppapi::InputEventData& input_event); |
| 354 | 363 |
| 364 // The document loader is valid when the plugin is "full-frame" and in this |
| 365 // case is non-NULL as long as the corresponding loader resource is alive. |
| 366 // This pointer is non-owning, so the loader must use set_document_loader to |
| 367 // clear itself when it is destroyed. |
| 368 WebKit::WebURLLoaderClient* document_loader() const { |
| 369 return document_loader_; |
| 370 } |
| 371 void set_document_loader(WebKit::WebURLLoaderClient* loader) { |
| 372 document_loader_ = loader; |
| 373 } |
| 374 |
| 355 ContentDecryptorDelegate* GetContentDecryptorDelegate(); | 375 ContentDecryptorDelegate* GetContentDecryptorDelegate(); |
| 356 | 376 |
| 357 // PPB_Instance_API implementation. | 377 // PPB_Instance_API implementation. |
| 358 virtual PP_Bool BindGraphics(PP_Instance instance, | 378 virtual PP_Bool BindGraphics(PP_Instance instance, |
| 359 PP_Resource device) OVERRIDE; | 379 PP_Resource device) OVERRIDE; |
| 360 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; | 380 virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; |
| 361 virtual const ::ppapi::ViewData* GetViewData(PP_Instance instance) OVERRIDE; | 381 virtual const ::ppapi::ViewData* GetViewData(PP_Instance instance) OVERRIDE; |
| 362 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE; | 382 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) OVERRIDE; |
| 363 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; | 383 virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; |
| 364 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; | 384 virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // Checks whether this is a valid instance of the given module. After calling | 498 // Checks whether this is a valid instance of the given module. After calling |
| 479 // ResetAsProxied above, a NaCl plugin instance's module changes, so external | 499 // ResetAsProxied above, a NaCl plugin instance's module changes, so external |
| 480 // hosts won't recognize it as a valid instance of the original module. This | 500 // hosts won't recognize it as a valid instance of the original module. This |
| 481 // method fixes that be checking that either module_ or original_module_ match | 501 // method fixes that be checking that either module_ or original_module_ match |
| 482 // the given module. | 502 // the given module. |
| 483 bool IsValidInstanceOf(PluginModule* module); | 503 bool IsValidInstanceOf(PluginModule* module); |
| 484 | 504 |
| 485 private: | 505 private: |
| 486 friend class PpapiUnittest; | 506 friend class PpapiUnittest; |
| 487 | 507 |
| 508 // Class to record document load notifications and play them back once the |
| 509 // real document loader becomes available. Used only by NaCl instances. |
| 510 class NaClDocumentLoader : public WebKit::WebURLLoaderClient { |
| 511 public: |
| 512 NaClDocumentLoader(); |
| 513 virtual ~NaClDocumentLoader(); |
| 514 |
| 515 void ReplayReceivedData(WebURLLoaderClient* document_loader); |
| 516 |
| 517 // WebKit::WebURLLoaderClient implementation. |
| 518 virtual void didReceiveData(WebKit::WebURLLoader* loader, |
| 519 const char* data, |
| 520 int data_length, |
| 521 int encoded_data_length); |
| 522 virtual void didFinishLoading(WebKit::WebURLLoader* loader, |
| 523 double finish_time); |
| 524 virtual void didFail(WebKit::WebURLLoader* loader, |
| 525 const WebKit::WebURLError& error); |
| 526 |
| 527 private: |
| 528 std::list<std::string> data_; |
| 529 bool finished_loading_; |
| 530 scoped_ptr<WebKit::WebURLError> error_; |
| 531 }; |
| 532 |
| 488 // Implements PPB_Gamepad_API. This is just to avoid having an excessive | 533 // Implements PPB_Gamepad_API. This is just to avoid having an excessive |
| 489 // number of interfaces implemented by PluginInstance. | 534 // number of interfaces implemented by PluginInstance. |
| 490 class GamepadImpl : public ::ppapi::thunk::PPB_Gamepad_API, | 535 class GamepadImpl : public ::ppapi::thunk::PPB_Gamepad_API, |
| 491 public ::ppapi::Resource { | 536 public ::ppapi::Resource { |
| 492 public: | 537 public: |
| 493 explicit GamepadImpl(PluginDelegate* delegate); | 538 explicit GamepadImpl(PluginDelegate* delegate); |
| 494 // Resource implementation. | 539 // Resource implementation. |
| 495 virtual ::ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE; | 540 virtual ::ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE; |
| 496 virtual void Sample(PP_Instance instance, | 541 virtual void Sample(PP_Instance instance, |
| 497 PP_GamepadsSampleData* data) OVERRIDE; | 542 PP_GamepadsSampleData* data) OVERRIDE; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // Track pending user gestures so out-of-process plugins can respond to | 816 // Track pending user gestures so out-of-process plugins can respond to |
| 772 // a user gesture after it has been processed. | 817 // a user gesture after it has been processed. |
| 773 PP_TimeTicks pending_user_gesture_; | 818 PP_TimeTicks pending_user_gesture_; |
| 774 WebKit::WebUserGestureToken pending_user_gesture_token_; | 819 WebKit::WebUserGestureToken pending_user_gesture_token_; |
| 775 | 820 |
| 776 // We store the arguments so we can re-send them if we are reset to talk to | 821 // We store the arguments so we can re-send them if we are reset to talk to |
| 777 // NaCl via the IPC NaCl proxy. | 822 // NaCl via the IPC NaCl proxy. |
| 778 std::vector<std::string> argn_; | 823 std::vector<std::string> argn_; |
| 779 std::vector<std::string> argv_; | 824 std::vector<std::string> argv_; |
| 780 | 825 |
| 781 // This is NULL unless HandleDocumentLoad has called. In that case, we store | 826 // Non-owning pointer to the document loader, if any. |
| 782 // the pointer so we can re-send it later if we are reset to talk to NaCl. | 827 WebKit::WebURLLoaderClient* document_loader_; |
| 783 scoped_refptr<PPB_URLLoader_Impl> document_loader_; | 828 // State for deferring document loads. Used only by NaCl instances. |
| 829 WebKit::WebURLResponse nacl_document_response_; |
| 830 scoped_ptr<NaClDocumentLoader> nacl_document_loader_; |
| 831 bool nacl_document_load_; |
| 784 | 832 |
| 785 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private | 833 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private |
| 786 // calls and handles PPB_ContentDecryptor_Private calls. | 834 // calls and handles PPB_ContentDecryptor_Private calls. |
| 787 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; | 835 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; |
| 788 | 836 |
| 789 friend class PpapiPluginInstanceTest; | 837 friend class PpapiPluginInstanceTest; |
| 790 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 838 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
| 791 }; | 839 }; |
| 792 | 840 |
| 793 } // namespace ppapi | 841 } // namespace ppapi |
| 794 } // namespace webkit | 842 } // namespace webkit |
| 795 | 843 |
| 796 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 844 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
| OLD | NEW |