| 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 <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.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/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "cc/layers/content_layer_client.h" | 19 #include "cc/layers/content_layer_client.h" |
| 20 #include "cc/layers/layer.h" | 20 #include "cc/layers/layer.h" |
| 21 #include "cc/layers/texture_layer_client.h" | 21 #include "cc/layers/texture_layer_client.h" |
| 22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 23 #include "content/public/renderer/pepper_plugin_instance.h" | 23 #include "content/public/renderer/pepper_plugin_instance.h" |
| 24 #include "content/public/renderer/render_frame_observer.h" | 24 #include "content/public/renderer/render_frame_observer.h" |
| 25 #include "content/renderer/mouse_lock_dispatcher.h" | 25 #include "content/renderer/mouse_lock_dispatcher.h" |
| 26 #include "gin/handle.h" |
| 26 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 27 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
| 27 #include "ppapi/c/dev/ppp_printing_dev.h" | 28 #include "ppapi/c/dev/ppp_printing_dev.h" |
| 28 #include "ppapi/c/dev/ppp_selection_dev.h" | 29 #include "ppapi/c/dev/ppp_selection_dev.h" |
| 29 #include "ppapi/c/dev/ppp_text_input_dev.h" | 30 #include "ppapi/c/dev/ppp_text_input_dev.h" |
| 30 #include "ppapi/c/dev/ppp_zoom_dev.h" | 31 #include "ppapi/c/dev/ppp_zoom_dev.h" |
| 31 #include "ppapi/c/pp_completion_callback.h" | 32 #include "ppapi/c/pp_completion_callback.h" |
| 32 #include "ppapi/c/pp_instance.h" | 33 #include "ppapi/c/pp_instance.h" |
| 33 #include "ppapi/c/pp_time.h" | 34 #include "ppapi/c/pp_time.h" |
| 34 #include "ppapi/c/pp_var.h" | 35 #include "ppapi/c/pp_var.h" |
| 35 #include "ppapi/c/ppb_audio_config.h" | 36 #include "ppapi/c/ppb_audio_config.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Create and return a PepperPluginInstanceImpl object which supports the most | 125 // Create and return a PepperPluginInstanceImpl object which supports the most |
| 125 // recent version of PPP_Instance possible by querying the given | 126 // recent version of PPP_Instance possible by querying the given |
| 126 // get_plugin_interface function. If the plugin does not support any valid | 127 // get_plugin_interface function. If the plugin does not support any valid |
| 127 // PPP_Instance interface, returns NULL. | 128 // PPP_Instance interface, returns NULL. |
| 128 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, | 129 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, |
| 129 PluginModule* module, | 130 PluginModule* module, |
| 130 blink::WebPluginContainer* container, | 131 blink::WebPluginContainer* container, |
| 131 const GURL& plugin_url); | 132 const GURL& plugin_url); |
| 132 RenderFrameImpl* render_frame() const { return render_frame_; } | 133 RenderFrameImpl* render_frame() const { return render_frame_; } |
| 133 PluginModule* module() const { return module_.get(); } | 134 PluginModule* module() const { return module_.get(); } |
| 134 MessageChannel& message_channel() { return *message_channel_; } | |
| 135 | 135 |
| 136 blink::WebPluginContainer* container() const { return container_; } | 136 blink::WebPluginContainer* container() const { return container_; } |
| 137 | 137 |
| 138 // Returns the PP_Instance uniquely identifying this instance. Guaranteed | 138 // Returns the PP_Instance uniquely identifying this instance. Guaranteed |
| 139 // nonzero. | 139 // nonzero. |
| 140 PP_Instance pp_instance() const { return pp_instance_; } | 140 PP_Instance pp_instance() const { return pp_instance_; } |
| 141 | 141 |
| 142 ppapi::thunk::ResourceCreationAPI& resource_creation() { | 142 ppapi::thunk::ResourceCreationAPI& resource_creation() { |
| 143 return *resource_creation_.get(); | 143 return *resource_creation_.get(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 MessageChannel* message_channel() { return message_channel_; } |
| 147 v8::Local<v8::Object> GetMessageChannelObject(); |
| 148 |
| 146 // Return the v8 context that the plugin is in. | 149 // Return the v8 context that the plugin is in. |
| 147 v8::Local<v8::Context> GetContext(); | 150 v8::Local<v8::Context> GetContext(); |
| 148 | 151 |
| 149 // Does some pre-destructor cleanup on the instance. This is necessary | 152 // Does some pre-destructor cleanup on the instance. This is necessary |
| 150 // because some cleanup depends on the plugin instance still existing (like | 153 // because some cleanup depends on the plugin instance still existing (like |
| 151 // calling the plugin's DidDestroy function). This function is called from | 154 // calling the plugin's DidDestroy function). This function is called from |
| 152 // the WebPlugin implementation when WebKit is about to remove the plugin. | 155 // the WebPlugin implementation when WebKit is about to remove the plugin. |
| 153 void Delete(); | 156 void Delete(); |
| 154 | 157 |
| 155 // Returns true if Delete() has been called on this object. | 158 // Returns true if Delete() has been called on this object. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 182 bool full_frame() const { return full_frame_; } | 185 bool full_frame() const { return full_frame_; } |
| 183 const ppapi::ViewData& view_data() const { return view_data_; } | 186 const ppapi::ViewData& view_data() const { return view_data_; } |
| 184 | 187 |
| 185 // PPP_Instance and PPP_Instance_Private. | 188 // PPP_Instance and PPP_Instance_Private. |
| 186 bool Initialize(const std::vector<std::string>& arg_names, | 189 bool Initialize(const std::vector<std::string>& arg_names, |
| 187 const std::vector<std::string>& arg_values, | 190 const std::vector<std::string>& arg_values, |
| 188 bool full_frame); | 191 bool full_frame); |
| 189 bool HandleDocumentLoad(const blink::WebURLResponse& response); | 192 bool HandleDocumentLoad(const blink::WebURLResponse& response); |
| 190 bool HandleInputEvent(const blink::WebInputEvent& event, | 193 bool HandleInputEvent(const blink::WebInputEvent& event, |
| 191 blink::WebCursorInfo* cursor_info); | 194 blink::WebCursorInfo* cursor_info); |
| 192 PP_Var GetInstanceObject(); | 195 PP_Var GetInstanceObject(v8::Isolate* isolate); |
| 193 void ViewChanged(const gfx::Rect& position, | 196 void ViewChanged(const gfx::Rect& position, |
| 194 const gfx::Rect& clip, | 197 const gfx::Rect& clip, |
| 195 const std::vector<gfx::Rect>& cut_outs_rects); | 198 const std::vector<gfx::Rect>& cut_outs_rects); |
| 196 | 199 |
| 197 // Handlers for composition events. | 200 // Handlers for composition events. |
| 198 bool HandleCompositionStart(const base::string16& text); | 201 bool HandleCompositionStart(const base::string16& text); |
| 199 bool HandleCompositionUpdate( | 202 bool HandleCompositionUpdate( |
| 200 const base::string16& text, | 203 const base::string16& text, |
| 201 const std::vector<blink::WebCompositionUnderline>& underlines, | 204 const std::vector<blink::WebCompositionUnderline>& underlines, |
| 202 int selection_start, | 205 int selection_start, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 // external out-of-process instance. | 514 // external out-of-process instance. |
| 512 PP_ExternalPluginResult ResetAsProxied(scoped_refptr<PluginModule> module); | 515 PP_ExternalPluginResult ResetAsProxied(scoped_refptr<PluginModule> module); |
| 513 | 516 |
| 514 // Checks whether this is a valid instance of the given module. After calling | 517 // Checks whether this is a valid instance of the given module. After calling |
| 515 // ResetAsProxied above, a NaCl plugin instance's module changes, so external | 518 // ResetAsProxied above, a NaCl plugin instance's module changes, so external |
| 516 // hosts won't recognize it as a valid instance of the original module. This | 519 // hosts won't recognize it as a valid instance of the original module. This |
| 517 // method fixes that be checking that either module_ or original_module_ match | 520 // method fixes that be checking that either module_ or original_module_ match |
| 518 // the given module. | 521 // the given module. |
| 519 bool IsValidInstanceOf(PluginModule* module); | 522 bool IsValidInstanceOf(PluginModule* module); |
| 520 | 523 |
| 521 // Returns the plugin NPP identifier that this plugin will use to identify | |
| 522 // itself when making NPObject scripting calls to WebBindings. | |
| 523 struct _NPP* instanceNPP(); | |
| 524 | |
| 525 // cc::TextureLayerClient implementation. | 524 // cc::TextureLayerClient implementation. |
| 526 virtual bool PrepareTextureMailbox( | 525 virtual bool PrepareTextureMailbox( |
| 527 cc::TextureMailbox* mailbox, | 526 cc::TextureMailbox* mailbox, |
| 528 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 527 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
| 529 bool use_shared_memory) OVERRIDE; | 528 bool use_shared_memory) OVERRIDE; |
| 530 | 529 |
| 531 // RenderFrameObserver | 530 // RenderFrameObserver |
| 532 virtual void OnDestruct() OVERRIDE; | 531 virtual void OnDestruct() OVERRIDE; |
| 533 | 532 |
| 534 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 533 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 // this here by modifying the various plugin attributes and then restoring | 822 // this here by modifying the various plugin attributes and then restoring |
| 824 // them on exit. | 823 // them on exit. |
| 825 blink::WebString width_before_fullscreen_; | 824 blink::WebString width_before_fullscreen_; |
| 826 blink::WebString height_before_fullscreen_; | 825 blink::WebString height_before_fullscreen_; |
| 827 blink::WebString border_before_fullscreen_; | 826 blink::WebString border_before_fullscreen_; |
| 828 blink::WebString style_before_fullscreen_; | 827 blink::WebString style_before_fullscreen_; |
| 829 gfx::Size screen_size_for_fullscreen_; | 828 gfx::Size screen_size_for_fullscreen_; |
| 830 | 829 |
| 831 // The MessageChannel used to implement bidirectional postMessage for the | 830 // The MessageChannel used to implement bidirectional postMessage for the |
| 832 // instance. | 831 // instance. |
| 833 scoped_ptr<MessageChannel> message_channel_; | 832 v8::Persistent<v8::Object> message_channel_object_; |
| 833 |
| 834 // A pointer to the MessageChannel underlying |message_channel_object_|. It is |
| 835 // only valid as long as |message_channel_object_| is alive. |
| 836 MessageChannel* message_channel_; |
| 834 | 837 |
| 835 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 838 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 836 SkBitmap* sad_plugin_; | 839 SkBitmap* sad_plugin_; |
| 837 | 840 |
| 838 typedef std::set<PluginObject*> PluginObjectSet; | 841 typedef std::set<PluginObject*> PluginObjectSet; |
| 839 PluginObjectSet live_plugin_objects_; | 842 PluginObjectSet live_plugin_objects_; |
| 840 | 843 |
| 841 // Classes of events that the plugin has registered for, both for filtering | 844 // Classes of events that the plugin has registered for, both for filtering |
| 842 // and not. The bits are PP_INPUTEVENT_CLASS_*. | 845 // and not. The bits are PP_INPUTEVENT_CLASS_*. |
| 843 uint32_t input_event_mask_; | 846 uint32_t input_event_mask_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 873 scoped_ptr<ExternalDocumentLoader> external_document_loader_; | 876 scoped_ptr<ExternalDocumentLoader> external_document_loader_; |
| 874 bool external_document_load_; | 877 bool external_document_load_; |
| 875 | 878 |
| 876 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private | 879 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private |
| 877 // calls and handles PPB_ContentDecryptor_Private calls. | 880 // calls and handles PPB_ContentDecryptor_Private calls. |
| 878 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; | 881 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; |
| 879 | 882 |
| 880 // The link currently under the cursor. | 883 // The link currently under the cursor. |
| 881 base::string16 link_under_cursor_; | 884 base::string16 link_under_cursor_; |
| 882 | 885 |
| 883 // Dummy NPP value used when calling in to WebBindings, to allow the bindings | |
| 884 // to correctly track NPObjects belonging to this plugin instance. | |
| 885 scoped_ptr<struct _NPP> npp_; | |
| 886 | |
| 887 // We store the isolate at construction so that we can be sure to use the | 886 // We store the isolate at construction so that we can be sure to use the |
| 888 // Isolate in which this Instance was created when interacting with v8. | 887 // Isolate in which this Instance was created when interacting with v8. |
| 889 v8::Isolate* isolate_; | 888 v8::Isolate* isolate_; |
| 890 | 889 |
| 891 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; | 890 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; |
| 892 | 891 |
| 893 bool is_deleted_; | 892 bool is_deleted_; |
| 894 | 893 |
| 895 // The text that is currently selected in the plugin. | 894 // The text that is currently selected in the plugin. |
| 896 base::string16 selected_text_; | 895 base::string16 selected_text_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 907 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; | 906 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; |
| 908 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; | 907 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; |
| 909 | 908 |
| 910 friend class PpapiPluginInstanceTest; | 909 friend class PpapiPluginInstanceTest; |
| 911 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); | 910 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); |
| 912 }; | 911 }; |
| 913 | 912 |
| 914 } // namespace content | 913 } // namespace content |
| 915 | 914 |
| 916 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 915 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| OLD | NEW |