| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // Represents one time a plugin appears on one web page. | 90 // Represents one time a plugin appears on one web page. |
| 91 // | 91 // |
| 92 // Note: to get from a PP_Instance to a PluginInstance*, use the | 92 // Note: to get from a PP_Instance to a PluginInstance*, use the |
| 93 // ResourceTracker. | 93 // ResourceTracker. |
| 94 class WEBKIT_PLUGINS_EXPORT PluginInstance : | 94 class WEBKIT_PLUGINS_EXPORT PluginInstance : |
| 95 public base::RefCounted<PluginInstance>, | 95 public base::RefCounted<PluginInstance>, |
| 96 public base::SupportsWeakPtr<PluginInstance>, | 96 public base::SupportsWeakPtr<PluginInstance>, |
| 97 public ::ppapi::PPB_Instance_Shared { | 97 public ::ppapi::PPB_Instance_Shared { |
| 98 public: | 98 public: |
| 99 // Create and return a PluginInstance object which supports the | 99 // Create and return a PluginInstance object which supports the most recent |
| 100 // given version. | 100 // version of PPP_Instance possible by querying the given get_plugin_interface |
| 101 static PluginInstance* Create1_0(PluginDelegate* delegate, | 101 // function. If the plugin does not support any valid PPP_Instance interface, |
| 102 PluginModule* module, | 102 // returns NULL. |
| 103 const void* ppp_instance_if_1_0); | 103 static PluginInstance* Create(PluginDelegate* delegate, PluginModule* module); |
| 104 static PluginInstance* Create1_1(PluginDelegate* delegate, | |
| 105 PluginModule* module, | |
| 106 const void* ppp_instance_if_1_1); | |
| 107 | |
| 108 // Delete should be called by the WebPlugin before this destructor. | 104 // Delete should be called by the WebPlugin before this destructor. |
| 109 virtual ~PluginInstance(); | 105 virtual ~PluginInstance(); |
| 110 | 106 |
| 111 PluginDelegate* delegate() const { return delegate_; } | 107 PluginDelegate* delegate() const { return delegate_; } |
| 112 PluginModule* module() const { return module_.get(); } | 108 PluginModule* module() const { return module_.get(); } |
| 113 MessageChannel& message_channel() { return *message_channel_; } | 109 MessageChannel& message_channel() { return *message_channel_; } |
| 114 | 110 |
| 115 WebKit::WebPluginContainer* container() const { return container_; } | 111 WebKit::WebPluginContainer* container() const { return container_; } |
| 116 | 112 |
| 117 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } | 113 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 PP_URLComponents_Dev* components) OVERRIDE; | 394 PP_URLComponents_Dev* components) OVERRIDE; |
| 399 virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE; | 395 virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE; |
| 400 virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, | 396 virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, |
| 401 PP_Instance target) OVERRIDE; | 397 PP_Instance target) OVERRIDE; |
| 402 virtual PP_Var GetDocumentURL(PP_Instance instance, | 398 virtual PP_Var GetDocumentURL(PP_Instance instance, |
| 403 PP_URLComponents_Dev* components) OVERRIDE; | 399 PP_URLComponents_Dev* components) OVERRIDE; |
| 404 virtual PP_Var GetPluginInstanceURL( | 400 virtual PP_Var GetPluginInstanceURL( |
| 405 PP_Instance instance, | 401 PP_Instance instance, |
| 406 PP_URLComponents_Dev* components) OVERRIDE; | 402 PP_URLComponents_Dev* components) OVERRIDE; |
| 407 | 403 |
| 404 // Reset this instance as proxied. Resets cached interfaces to point to the |
| 405 // proxy and re-sends DidCreate, DidChangeView, and HandleDocumentLoad (if |
| 406 // necessary). |
| 407 // This is for use with the NaCl proxy. |
| 408 bool ResetAsProxied(); |
| 409 |
| 408 private: | 410 private: |
| 409 // See the static Create functions above for creating PluginInstance objects. | 411 // See the static Create functions above for creating PluginInstance objects. |
| 410 // This constructor is private so that we can hide the PPP_Instance_Combined | 412 // This constructor is private so that we can hide the PPP_Instance_Combined |
| 411 // details while still having 1 constructor to maintain for member | 413 // details while still having 1 constructor to maintain for member |
| 412 // initialization. | 414 // initialization. |
| 413 PluginInstance(PluginDelegate* delegate, | 415 PluginInstance(PluginDelegate* delegate, |
| 414 PluginModule* module, | 416 PluginModule* module, |
| 415 ::ppapi::PPP_Instance_Combined* instance_interface); | 417 ::ppapi::PPP_Instance_Combined* instance_interface); |
| 416 | 418 |
| 417 bool LoadFindInterface(); | 419 bool LoadFindInterface(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 bool full_frame_; | 508 bool full_frame_; |
| 507 | 509 |
| 508 // Stores the current state of the plugin view. | 510 // Stores the current state of the plugin view. |
| 509 ::ppapi::ViewData view_data_; | 511 ::ppapi::ViewData view_data_; |
| 510 | 512 |
| 511 // Indicates if we've ever sent a didChangeView to the plugin. This ensure we | 513 // Indicates if we've ever sent a didChangeView to the plugin. This ensure we |
| 512 // always send an initial notification, even if the position and clip are the | 514 // always send an initial notification, even if the position and clip are the |
| 513 // same as the default values. | 515 // same as the default values. |
| 514 bool sent_initial_did_change_view_; | 516 bool sent_initial_did_change_view_; |
| 515 | 517 |
| 516 // Set to true when we've scheduled an asynchronous DidChangeView update for | 518 // We use a weak ptr factory for scheduling DidChangeView events so that we |
| 517 // the purposes of consolidating updates. When this is set, code should | 519 // can tell whether updates are pending and consolidate them. When there's |
| 518 // update the view_data_ but not send updates. It will be cleared once the | 520 // already a weak ptr pending (HasWeakPtrs is true), code should update the |
| 519 // asynchronous update has been sent out. | 521 // view_data_ but not send updates. This also allows us to cancel scheduled |
| 520 bool suppress_did_change_view_; | 522 // view change events. |
| 523 base::WeakPtrFactory<PluginInstance> view_change_weak_ptr_factory_; |
| 521 | 524 |
| 522 // The current device context for painting in 2D or 3D. | 525 // The current device context for painting in 2D or 3D. |
| 523 scoped_refptr< ::ppapi::Resource> bound_graphics_; | 526 scoped_refptr< ::ppapi::Resource> bound_graphics_; |
| 524 | 527 |
| 525 // We track two types of focus, one from WebKit, which is the focus among | 528 // We track two types of focus, one from WebKit, which is the focus among |
| 526 // all elements of the page, one one from the browser, which is whether the | 529 // all elements of the page, one one from the browser, which is whether the |
| 527 // tab/window has focus. We tell the plugin it has focus only when both of | 530 // tab/window has focus. We tell the plugin it has focus only when both of |
| 528 // these values are set to true. | 531 // these values are set to true. |
| 529 bool has_webkit_focus_; | 532 bool has_webkit_focus_; |
| 530 bool has_content_area_focus_; | 533 bool has_content_area_focus_; |
| 531 | 534 |
| 532 // The id of the current find operation, or -1 if none is in process. | 535 // The id of the current find operation, or -1 if none is in process. |
| 533 int find_identifier_; | 536 int find_identifier_; |
| 534 | 537 |
| 535 // Helper object that creates resources. | 538 // Helper object that creates resources. |
| 536 ResourceCreationImpl resource_creation_; | 539 ResourceCreationImpl resource_creation_; |
| 537 | 540 |
| 538 // The plugin-provided interfaces. | 541 // The plugin-provided interfaces. |
| 539 const PPP_Find_Dev* plugin_find_interface_; | 542 const PPP_Find_Dev* plugin_find_interface_; |
| 543 const PPP_InputEvent* plugin_input_event_interface_; |
| 540 const PPP_Messaging* plugin_messaging_interface_; | 544 const PPP_Messaging* plugin_messaging_interface_; |
| 541 const PPP_MouseLock* plugin_mouse_lock_interface_; | 545 const PPP_MouseLock* plugin_mouse_lock_interface_; |
| 542 const PPP_InputEvent* plugin_input_event_interface_; | 546 const PPP_Pdf* plugin_pdf_interface_; |
| 543 const PPP_Instance_Private* plugin_private_interface_; | 547 const PPP_Instance_Private* plugin_private_interface_; |
| 544 const PPP_Pdf* plugin_pdf_interface_; | |
| 545 const PPP_Selection_Dev* plugin_selection_interface_; | 548 const PPP_Selection_Dev* plugin_selection_interface_; |
| 546 const PPP_TextInput_Dev* plugin_textinput_interface_; | 549 const PPP_TextInput_Dev* plugin_textinput_interface_; |
| 547 const PPP_Zoom_Dev* plugin_zoom_interface_; | 550 const PPP_Zoom_Dev* plugin_zoom_interface_; |
| 548 | 551 |
| 549 // Flags indicating whether we have asked this plugin instance for the | 552 // Flags indicating whether we have asked this plugin instance for the |
| 550 // corresponding interfaces, so that we can ask only once. | 553 // corresponding interfaces, so that we can ask only once. |
| 551 bool checked_for_plugin_input_event_interface_; | 554 bool checked_for_plugin_input_event_interface_; |
| 552 bool checked_for_plugin_messaging_interface_; | 555 bool checked_for_plugin_messaging_interface_; |
| 553 | 556 |
| 554 // This is only valid between a successful PrintBegin call and a PrintEnd | 557 // This is only valid between a successful PrintBegin call and a PrintEnd |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 648 |
| 646 PP_CompletionCallback lock_mouse_callback_; | 649 PP_CompletionCallback lock_mouse_callback_; |
| 647 | 650 |
| 648 // Track pending user gestures so out-of-process plugins can respond to | 651 // Track pending user gestures so out-of-process plugins can respond to |
| 649 // a user gesture after it has been processed. | 652 // a user gesture after it has been processed. |
| 650 PP_TimeTicks pending_user_gesture_; | 653 PP_TimeTicks pending_user_gesture_; |
| 651 | 654 |
| 652 // The Flash proxy is associated with the instance. | 655 // The Flash proxy is associated with the instance. |
| 653 PPB_Flash_Impl flash_impl_; | 656 PPB_Flash_Impl flash_impl_; |
| 654 | 657 |
| 658 // We store the arguments so we can re-send them if we are reset to talk to |
| 659 // NaCl via the IPC NaCl proxy. |
| 660 std::vector<std::string> argn_; |
| 661 std::vector<std::string> argv_; |
| 662 |
| 663 // This is NULL unless HandleDocumentLoad has called. In that case, we store |
| 664 // the pointer so we can re-send it later if we are reset to talk to NaCl. |
| 665 scoped_refptr<PPB_URLLoader_Impl> document_loader_; |
| 666 |
| 655 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 667 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
| 656 }; | 668 }; |
| 657 | 669 |
| 658 } // namespace ppapi | 670 } // namespace ppapi |
| 659 } // namespace webkit | 671 } // namespace webkit |
| 660 | 672 |
| 661 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ | 673 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ |
| OLD | NEW |