| 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 CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <memory> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <string> | 14 #include <string> |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 16 #include "base/callback.h" | 17 #include "base/callback.h" |
| 17 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/scoped_ptr.h" | |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "cc/layers/content_layer_client.h" | 24 #include "cc/layers/content_layer_client.h" |
| 25 #include "cc/layers/layer.h" | 25 #include "cc/layers/layer.h" |
| 26 #include "cc/layers/texture_layer_client.h" | 26 #include "cc/layers/texture_layer_client.h" |
| 27 #include "content/common/content_export.h" | 27 #include "content/common/content_export.h" |
| 28 #include "content/public/renderer/pepper_plugin_instance.h" | 28 #include "content/public/renderer/pepper_plugin_instance.h" |
| 29 #include "content/public/renderer/plugin_instance_throttler.h" | 29 #include "content/public/renderer/plugin_instance_throttler.h" |
| 30 #include "content/public/renderer/render_frame.h" | 30 #include "content/public/renderer/render_frame.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 void InstanceCrashed(); | 205 void InstanceCrashed(); |
| 206 | 206 |
| 207 // PPB_Instance and PPB_Instance_Private implementation. | 207 // PPB_Instance and PPB_Instance_Private implementation. |
| 208 bool full_frame() const { return full_frame_; } | 208 bool full_frame() const { return full_frame_; } |
| 209 const ppapi::ViewData& view_data() const { return view_data_; } | 209 const ppapi::ViewData& view_data() const { return view_data_; } |
| 210 | 210 |
| 211 // PPP_Instance and PPP_Instance_Private. | 211 // PPP_Instance and PPP_Instance_Private. |
| 212 bool Initialize(const std::vector<std::string>& arg_names, | 212 bool Initialize(const std::vector<std::string>& arg_names, |
| 213 const std::vector<std::string>& arg_values, | 213 const std::vector<std::string>& arg_values, |
| 214 bool full_frame, | 214 bool full_frame, |
| 215 scoped_ptr<PluginInstanceThrottlerImpl> throttler); | 215 std::unique_ptr<PluginInstanceThrottlerImpl> throttler); |
| 216 bool HandleDocumentLoad(const blink::WebURLResponse& response); | 216 bool HandleDocumentLoad(const blink::WebURLResponse& response); |
| 217 bool HandleInputEvent(const blink::WebInputEvent& event, | 217 bool HandleInputEvent(const blink::WebInputEvent& event, |
| 218 blink::WebCursorInfo* cursor_info); | 218 blink::WebCursorInfo* cursor_info); |
| 219 PP_Var GetInstanceObject(v8::Isolate* isolate); | 219 PP_Var GetInstanceObject(v8::Isolate* isolate); |
| 220 void ViewChanged(const gfx::Rect& window, | 220 void ViewChanged(const gfx::Rect& window, |
| 221 const gfx::Rect& clip, | 221 const gfx::Rect& clip, |
| 222 const gfx::Rect& unobscured, | 222 const gfx::Rect& unobscured, |
| 223 const std::vector<gfx::Rect>& cut_outs_rects); | 223 const std::vector<gfx::Rect>& cut_outs_rects); |
| 224 | 224 |
| 225 // Handlers for composition events. | 225 // Handlers for composition events. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 // Checks whether this is a valid instance of the given module. After calling | 528 // Checks whether this is a valid instance of the given module. After calling |
| 529 // ResetAsProxied above, a NaCl plugin instance's module changes, so external | 529 // ResetAsProxied above, a NaCl plugin instance's module changes, so external |
| 530 // hosts won't recognize it as a valid instance of the original module. This | 530 // hosts won't recognize it as a valid instance of the original module. This |
| 531 // method fixes that be checking that either module_ or original_module_ match | 531 // method fixes that be checking that either module_ or original_module_ match |
| 532 // the given module. | 532 // the given module. |
| 533 bool IsValidInstanceOf(PluginModule* module); | 533 bool IsValidInstanceOf(PluginModule* module); |
| 534 | 534 |
| 535 // cc::TextureLayerClient implementation. | 535 // cc::TextureLayerClient implementation. |
| 536 bool PrepareTextureMailbox( | 536 bool PrepareTextureMailbox( |
| 537 cc::TextureMailbox* mailbox, | 537 cc::TextureMailbox* mailbox, |
| 538 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 538 std::unique_ptr<cc::SingleReleaseCallback>* release_callback, |
| 539 bool use_shared_memory) override; | 539 bool use_shared_memory) override; |
| 540 | 540 |
| 541 // RenderFrameObserver | 541 // RenderFrameObserver |
| 542 void OnDestruct() override; | 542 void OnDestruct() override; |
| 543 | 543 |
| 544 // PluginInstanceThrottler::Observer | 544 // PluginInstanceThrottler::Observer |
| 545 void OnThrottleStateChange() override; | 545 void OnThrottleStateChange() override; |
| 546 void OnHiddenForPlaceholder(bool hidden) override; | 546 void OnHiddenForPlaceholder(bool hidden) override; |
| 547 | 547 |
| 548 private: | 548 private: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 569 int encoded_data_length) override; | 569 int encoded_data_length) override; |
| 570 void didFinishLoading(blink::WebURLLoader* loader, | 570 void didFinishLoading(blink::WebURLLoader* loader, |
| 571 double finish_time, | 571 double finish_time, |
| 572 int64_t total_encoded_data_length) override; | 572 int64_t total_encoded_data_length) override; |
| 573 void didFail(blink::WebURLLoader* loader, | 573 void didFail(blink::WebURLLoader* loader, |
| 574 const blink::WebURLError& error) override; | 574 const blink::WebURLError& error) override; |
| 575 | 575 |
| 576 private: | 576 private: |
| 577 std::list<std::string> data_; | 577 std::list<std::string> data_; |
| 578 bool finished_loading_; | 578 bool finished_loading_; |
| 579 scoped_ptr<blink::WebURLError> error_; | 579 std::unique_ptr<blink::WebURLError> error_; |
| 580 }; | 580 }; |
| 581 | 581 |
| 582 // Implements PPB_Gamepad_API. This is just to avoid having an excessive | 582 // Implements PPB_Gamepad_API. This is just to avoid having an excessive |
| 583 // number of interfaces implemented by PepperPluginInstanceImpl. | 583 // number of interfaces implemented by PepperPluginInstanceImpl. |
| 584 class GamepadImpl : public ppapi::thunk::PPB_Gamepad_API, | 584 class GamepadImpl : public ppapi::thunk::PPB_Gamepad_API, |
| 585 public ppapi::Resource { | 585 public ppapi::Resource { |
| 586 public: | 586 public: |
| 587 GamepadImpl(); | 587 GamepadImpl(); |
| 588 // Resource implementation. | 588 // Resource implementation. |
| 589 ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() override; | 589 ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() override; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 | 695 |
| 696 void RecordFlashJavaScriptUse(); | 696 void RecordFlashJavaScriptUse(); |
| 697 | 697 |
| 698 // Converts the PP_Rect between DIP and Viewport. | 698 // Converts the PP_Rect between DIP and Viewport. |
| 699 void ConvertRectToDIP(PP_Rect* rect) const; | 699 void ConvertRectToDIP(PP_Rect* rect) const; |
| 700 void ConvertDIPToViewport(gfx::Rect* rect) const; | 700 void ConvertDIPToViewport(gfx::Rect* rect) const; |
| 701 | 701 |
| 702 RenderFrameImpl* render_frame_; | 702 RenderFrameImpl* render_frame_; |
| 703 base::Closure instance_deleted_callback_; | 703 base::Closure instance_deleted_callback_; |
| 704 scoped_refptr<PluginModule> module_; | 704 scoped_refptr<PluginModule> module_; |
| 705 scoped_ptr<ppapi::PPP_Instance_Combined> instance_interface_; | 705 std::unique_ptr<ppapi::PPP_Instance_Combined> instance_interface_; |
| 706 // If this is the NaCl plugin, we create a new module when we switch to the | 706 // If this is the NaCl plugin, we create a new module when we switch to the |
| 707 // IPC-based PPAPI proxy. Store the original module and instance interface | 707 // IPC-based PPAPI proxy. Store the original module and instance interface |
| 708 // so we can shut down properly. | 708 // so we can shut down properly. |
| 709 scoped_refptr<PluginModule> original_module_; | 709 scoped_refptr<PluginModule> original_module_; |
| 710 scoped_ptr<ppapi::PPP_Instance_Combined> original_instance_interface_; | 710 std::unique_ptr<ppapi::PPP_Instance_Combined> original_instance_interface_; |
| 711 | 711 |
| 712 PP_Instance pp_instance_; | 712 PP_Instance pp_instance_; |
| 713 | 713 |
| 714 // NULL until we have been initialized. | 714 // NULL until we have been initialized. |
| 715 blink::WebPluginContainer* container_; | 715 blink::WebPluginContainer* container_; |
| 716 scoped_refptr<cc::Layer> compositor_layer_; | 716 scoped_refptr<cc::Layer> compositor_layer_; |
| 717 scoped_refptr<cc::TextureLayer> texture_layer_; | 717 scoped_refptr<cc::TextureLayer> texture_layer_; |
| 718 scoped_ptr<blink::WebLayer> web_layer_; | 718 std::unique_ptr<blink::WebLayer> web_layer_; |
| 719 bool layer_bound_to_fullscreen_; | 719 bool layer_bound_to_fullscreen_; |
| 720 bool layer_is_hardware_; | 720 bool layer_is_hardware_; |
| 721 | 721 |
| 722 // Plugin URL. | 722 // Plugin URL. |
| 723 const GURL plugin_url_; | 723 const GURL plugin_url_; |
| 724 | 724 |
| 725 GURL document_url_; | 725 GURL document_url_; |
| 726 | 726 |
| 727 // Used to track Flash-specific metrics. | 727 // Used to track Flash-specific metrics. |
| 728 const bool is_flash_plugin_; | 728 const bool is_flash_plugin_; |
| 729 | 729 |
| 730 // Set to true the first time the plugin is clicked. Used to collect metrics. | 730 // Set to true the first time the plugin is clicked. Used to collect metrics. |
| 731 bool has_been_clicked_; | 731 bool has_been_clicked_; |
| 732 | 732 |
| 733 // Used to track if JavaScript has ever been used for this plugin instance. | 733 // Used to track if JavaScript has ever been used for this plugin instance. |
| 734 bool javascript_used_; | 734 bool javascript_used_; |
| 735 | 735 |
| 736 // Responsible for turning on throttling if Power Saver is on. | 736 // Responsible for turning on throttling if Power Saver is on. |
| 737 scoped_ptr<PluginInstanceThrottlerImpl> throttler_; | 737 std::unique_ptr<PluginInstanceThrottlerImpl> throttler_; |
| 738 | 738 |
| 739 // Indicates whether this is a full frame instance, which means it represents | 739 // Indicates whether this is a full frame instance, which means it represents |
| 740 // an entire document rather than an embed tag. | 740 // an entire document rather than an embed tag. |
| 741 bool full_frame_; | 741 bool full_frame_; |
| 742 | 742 |
| 743 // Stores the current state of the plugin view. | 743 // Stores the current state of the plugin view. |
| 744 ppapi::ViewData view_data_; | 744 ppapi::ViewData view_data_; |
| 745 // The last state sent to the plugin. It is only valid after | 745 // The last state sent to the plugin. It is only valid after |
| 746 // |sent_initial_did_change_view_| is set to true. | 746 // |sent_initial_did_change_view_| is set to true. |
| 747 ppapi::ViewData last_sent_view_data_; | 747 ppapi::ViewData last_sent_view_data_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 764 // all elements of the page, one one from the browser, which is whether the | 764 // all elements of the page, one one from the browser, which is whether the |
| 765 // tab/window has focus. We tell the plugin it has focus only when both of | 765 // tab/window has focus. We tell the plugin it has focus only when both of |
| 766 // these values are set to true. | 766 // these values are set to true. |
| 767 bool has_webkit_focus_; | 767 bool has_webkit_focus_; |
| 768 bool has_content_area_focus_; | 768 bool has_content_area_focus_; |
| 769 | 769 |
| 770 // The id of the current find operation, or -1 if none is in process. | 770 // The id of the current find operation, or -1 if none is in process. |
| 771 int find_identifier_; | 771 int find_identifier_; |
| 772 | 772 |
| 773 // Helper object that creates resources. | 773 // Helper object that creates resources. |
| 774 scoped_ptr<ppapi::thunk::ResourceCreationAPI> resource_creation_; | 774 std::unique_ptr<ppapi::thunk::ResourceCreationAPI> resource_creation_; |
| 775 | 775 |
| 776 // The plugin-provided interfaces. | 776 // The plugin-provided interfaces. |
| 777 // When adding PPP interfaces, make sure to reset them in ResetAsProxied. | 777 // When adding PPP interfaces, make sure to reset them in ResetAsProxied. |
| 778 const PPP_Find_Private* plugin_find_interface_; | 778 const PPP_Find_Private* plugin_find_interface_; |
| 779 const PPP_InputEvent* plugin_input_event_interface_; | 779 const PPP_InputEvent* plugin_input_event_interface_; |
| 780 const PPP_MouseLock* plugin_mouse_lock_interface_; | 780 const PPP_MouseLock* plugin_mouse_lock_interface_; |
| 781 const PPP_Pdf* plugin_pdf_interface_; | 781 const PPP_Pdf* plugin_pdf_interface_; |
| 782 const PPP_Instance_Private* plugin_private_interface_; | 782 const PPP_Instance_Private* plugin_private_interface_; |
| 783 const PPP_TextInput_Dev* plugin_textinput_interface_; | 783 const PPP_TextInput_Dev* plugin_textinput_interface_; |
| 784 | 784 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 813 scoped_refptr<ppapi::Resource> gamepad_impl_; | 813 scoped_refptr<ppapi::Resource> gamepad_impl_; |
| 814 scoped_refptr<ppapi::Resource> uma_private_impl_; | 814 scoped_refptr<ppapi::Resource> uma_private_impl_; |
| 815 | 815 |
| 816 // The plugin print interface. | 816 // The plugin print interface. |
| 817 const PPP_Printing_Dev* plugin_print_interface_; | 817 const PPP_Printing_Dev* plugin_print_interface_; |
| 818 | 818 |
| 819 // The plugin 3D interface. | 819 // The plugin 3D interface. |
| 820 const PPP_Graphics3D* plugin_graphics_3d_interface_; | 820 const PPP_Graphics3D* plugin_graphics_3d_interface_; |
| 821 | 821 |
| 822 // Contains the cursor if it's set by the plugin. | 822 // Contains the cursor if it's set by the plugin. |
| 823 scoped_ptr<blink::WebCursorInfo> cursor_; | 823 std::unique_ptr<blink::WebCursorInfo> cursor_; |
| 824 | 824 |
| 825 // Set to true if this plugin thinks it will always be on top. This allows us | 825 // Set to true if this plugin thinks it will always be on top. This allows us |
| 826 // to use a more optimized painting path in some cases. | 826 // to use a more optimized painting path in some cases. |
| 827 bool always_on_top_; | 827 bool always_on_top_; |
| 828 // Even if |always_on_top_| is true, the plugin is not fully visible if there | 828 // Even if |always_on_top_| is true, the plugin is not fully visible if there |
| 829 // are some cut-out areas (occupied by iframes higher in the stacking order). | 829 // are some cut-out areas (occupied by iframes higher in the stacking order). |
| 830 // This information is used in the optimized painting path. | 830 // This information is used in the optimized painting path. |
| 831 std::vector<gfx::Rect> cut_outs_rects_; | 831 std::vector<gfx::Rect> cut_outs_rects_; |
| 832 | 832 |
| 833 // Implementation of PPB_FlashFullscreen. | 833 // Implementation of PPB_FlashFullscreen. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 | 898 |
| 899 // We store the arguments so we can re-send them if we are reset to talk to | 899 // We store the arguments so we can re-send them if we are reset to talk to |
| 900 // NaCl via the IPC NaCl proxy. | 900 // NaCl via the IPC NaCl proxy. |
| 901 std::vector<std::string> argn_; | 901 std::vector<std::string> argn_; |
| 902 std::vector<std::string> argv_; | 902 std::vector<std::string> argv_; |
| 903 | 903 |
| 904 // Non-owning pointer to the document loader, if any. | 904 // Non-owning pointer to the document loader, if any. |
| 905 blink::WebURLLoaderClient* document_loader_; | 905 blink::WebURLLoaderClient* document_loader_; |
| 906 // State for deferring document loads. Used only by external instances. | 906 // State for deferring document loads. Used only by external instances. |
| 907 blink::WebURLResponse external_document_response_; | 907 blink::WebURLResponse external_document_response_; |
| 908 scoped_ptr<ExternalDocumentLoader> external_document_loader_; | 908 std::unique_ptr<ExternalDocumentLoader> external_document_loader_; |
| 909 bool external_document_load_; | 909 bool external_document_load_; |
| 910 | 910 |
| 911 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private | 911 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private |
| 912 // calls and handles PPB_ContentDecryptor_Private calls. | 912 // calls and handles PPB_ContentDecryptor_Private calls. |
| 913 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; | 913 std::unique_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; |
| 914 | 914 |
| 915 // The link currently under the cursor. | 915 // The link currently under the cursor. |
| 916 base::string16 link_under_cursor_; | 916 base::string16 link_under_cursor_; |
| 917 | 917 |
| 918 // We store the isolate at construction so that we can be sure to use the | 918 // We store the isolate at construction so that we can be sure to use the |
| 919 // Isolate in which this Instance was created when interacting with v8. | 919 // Isolate in which this Instance was created when interacting with v8. |
| 920 v8::Isolate* isolate_; | 920 v8::Isolate* isolate_; |
| 921 | 921 |
| 922 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; | 922 std::unique_ptr<MouseLockDispatcher::LockTarget> lock_target_; |
| 923 | 923 |
| 924 bool is_deleted_; | 924 bool is_deleted_; |
| 925 | 925 |
| 926 // The text that is currently selected in the plugin. | 926 // The text that is currently selected in the plugin. |
| 927 base::string16 selected_text_; | 927 base::string16 selected_text_; |
| 928 | 928 |
| 929 bool initialized_; | 929 bool initialized_; |
| 930 | 930 |
| 931 // We use a weak ptr factory for scheduling DidChangeView events so that we | 931 // We use a weak ptr factory for scheduling DidChangeView events so that we |
| 932 // can tell whether updates are pending and consolidate them. When there's | 932 // can tell whether updates are pending and consolidate them. When there's |
| 933 // already a weak ptr pending (HasWeakPtrs is true), code should update the | 933 // already a weak ptr pending (HasWeakPtrs is true), code should update the |
| 934 // view_data_ but not send updates. This also allows us to cancel scheduled | 934 // view_data_ but not send updates. This also allows us to cancel scheduled |
| 935 // view change events. | 935 // view change events. |
| 936 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; | 936 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; |
| 937 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; | 937 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; |
| 938 | 938 |
| 939 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); | 939 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); |
| 940 }; | 940 }; |
| 941 | 941 |
| 942 } // namespace content | 942 } // namespace content |
| 943 | 943 |
| 944 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 944 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| OLD | NEW |