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