| 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 // This pointer is only valid on the stack. |
| 147 MessageChannel* GetMessageChannel(); |
| 148 v8::Local<v8::Object> GetMessageChannelObject(); |
| 149 |
| 146 // Return the v8 context that the plugin is in. | 150 // Return the v8 context that the plugin is in. |
| 147 v8::Local<v8::Context> GetContext(); | 151 v8::Local<v8::Context> GetContext(); |
| 148 | 152 |
| 149 // Does some pre-destructor cleanup on the instance. This is necessary | 153 // Does some pre-destructor cleanup on the instance. This is necessary |
| 150 // because some cleanup depends on the plugin instance still existing (like | 154 // because some cleanup depends on the plugin instance still existing (like |
| 151 // calling the plugin's DidDestroy function). This function is called from | 155 // calling the plugin's DidDestroy function). This function is called from |
| 152 // the WebPlugin implementation when WebKit is about to remove the plugin. | 156 // the WebPlugin implementation when WebKit is about to remove the plugin. |
| 153 void Delete(); | 157 void Delete(); |
| 154 | 158 |
| 155 // Returns true if Delete() has been called on this object. | 159 // 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_; } | 186 bool full_frame() const { return full_frame_; } |
| 183 const ppapi::ViewData& view_data() const { return view_data_; } | 187 const ppapi::ViewData& view_data() const { return view_data_; } |
| 184 | 188 |
| 185 // PPP_Instance and PPP_Instance_Private. | 189 // PPP_Instance and PPP_Instance_Private. |
| 186 bool Initialize(const std::vector<std::string>& arg_names, | 190 bool Initialize(const std::vector<std::string>& arg_names, |
| 187 const std::vector<std::string>& arg_values, | 191 const std::vector<std::string>& arg_values, |
| 188 bool full_frame); | 192 bool full_frame); |
| 189 bool HandleDocumentLoad(const blink::WebURLResponse& response); | 193 bool HandleDocumentLoad(const blink::WebURLResponse& response); |
| 190 bool HandleInputEvent(const blink::WebInputEvent& event, | 194 bool HandleInputEvent(const blink::WebInputEvent& event, |
| 191 blink::WebCursorInfo* cursor_info); | 195 blink::WebCursorInfo* cursor_info); |
| 192 PP_Var GetInstanceObject(); | 196 PP_Var GetInstanceObject(v8::Isolate* isolate); |
| 193 void ViewChanged(const gfx::Rect& position, | 197 void ViewChanged(const gfx::Rect& position, |
| 194 const gfx::Rect& clip, | 198 const gfx::Rect& clip, |
| 195 const std::vector<gfx::Rect>& cut_outs_rects); | 199 const std::vector<gfx::Rect>& cut_outs_rects); |
| 196 | 200 |
| 197 // Handlers for composition events. | 201 // Handlers for composition events. |
| 198 bool HandleCompositionStart(const base::string16& text); | 202 bool HandleCompositionStart(const base::string16& text); |
| 199 bool HandleCompositionUpdate( | 203 bool HandleCompositionUpdate( |
| 200 const base::string16& text, | 204 const base::string16& text, |
| 201 const std::vector<blink::WebCompositionUnderline>& underlines, | 205 const std::vector<blink::WebCompositionUnderline>& underlines, |
| 202 int selection_start, | 206 int selection_start, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 // external out-of-process instance. | 515 // external out-of-process instance. |
| 512 PP_ExternalPluginResult ResetAsProxied(scoped_refptr<PluginModule> module); | 516 PP_ExternalPluginResult ResetAsProxied(scoped_refptr<PluginModule> module); |
| 513 | 517 |
| 514 // Checks whether this is a valid instance of the given module. After calling | 518 // 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 | 519 // 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 | 520 // 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 | 521 // method fixes that be checking that either module_ or original_module_ match |
| 518 // the given module. | 522 // the given module. |
| 519 bool IsValidInstanceOf(PluginModule* module); | 523 bool IsValidInstanceOf(PluginModule* module); |
| 520 | 524 |
| 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. | 525 // cc::TextureLayerClient implementation. |
| 526 virtual bool PrepareTextureMailbox( | 526 virtual bool PrepareTextureMailbox( |
| 527 cc::TextureMailbox* mailbox, | 527 cc::TextureMailbox* mailbox, |
| 528 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 528 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
| 529 bool use_shared_memory) OVERRIDE; | 529 bool use_shared_memory) OVERRIDE; |
| 530 | 530 |
| 531 // RenderFrameObserver | 531 // RenderFrameObserver |
| 532 virtual void OnDestruct() OVERRIDE; | 532 virtual void OnDestruct() OVERRIDE; |
| 533 | 533 |
| 534 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 534 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 | 823 // this here by modifying the various plugin attributes and then restoring |
| 824 // them on exit. | 824 // them on exit. |
| 825 blink::WebString width_before_fullscreen_; | 825 blink::WebString width_before_fullscreen_; |
| 826 blink::WebString height_before_fullscreen_; | 826 blink::WebString height_before_fullscreen_; |
| 827 blink::WebString border_before_fullscreen_; | 827 blink::WebString border_before_fullscreen_; |
| 828 blink::WebString style_before_fullscreen_; | 828 blink::WebString style_before_fullscreen_; |
| 829 gfx::Size screen_size_for_fullscreen_; | 829 gfx::Size screen_size_for_fullscreen_; |
| 830 | 830 |
| 831 // The MessageChannel used to implement bidirectional postMessage for the | 831 // The MessageChannel used to implement bidirectional postMessage for the |
| 832 // instance. | 832 // instance. |
| 833 scoped_ptr<MessageChannel> message_channel_; | 833 v8::Persistent<v8::Object> message_channel_; |
| 834 | 834 |
| 835 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 835 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 836 SkBitmap* sad_plugin_; | 836 SkBitmap* sad_plugin_; |
| 837 | 837 |
| 838 typedef std::set<PluginObject*> PluginObjectSet; | 838 typedef std::set<PluginObject*> PluginObjectSet; |
| 839 PluginObjectSet live_plugin_objects_; | 839 PluginObjectSet live_plugin_objects_; |
| 840 | 840 |
| 841 // Classes of events that the plugin has registered for, both for filtering | 841 // Classes of events that the plugin has registered for, both for filtering |
| 842 // and not. The bits are PP_INPUTEVENT_CLASS_*. | 842 // and not. The bits are PP_INPUTEVENT_CLASS_*. |
| 843 uint32_t input_event_mask_; | 843 uint32_t input_event_mask_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 873 scoped_ptr<ExternalDocumentLoader> external_document_loader_; | 873 scoped_ptr<ExternalDocumentLoader> external_document_loader_; |
| 874 bool external_document_load_; | 874 bool external_document_load_; |
| 875 | 875 |
| 876 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private | 876 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private |
| 877 // calls and handles PPB_ContentDecryptor_Private calls. | 877 // calls and handles PPB_ContentDecryptor_Private calls. |
| 878 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; | 878 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; |
| 879 | 879 |
| 880 // The link currently under the cursor. | 880 // The link currently under the cursor. |
| 881 base::string16 link_under_cursor_; | 881 base::string16 link_under_cursor_; |
| 882 | 882 |
| 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 | 883 // 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. | 884 // Isolate in which this Instance was created when interacting with v8. |
| 889 v8::Isolate* isolate_; | 885 v8::Isolate* isolate_; |
| 890 | 886 |
| 891 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; | 887 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; |
| 892 | 888 |
| 893 bool is_deleted_; | 889 bool is_deleted_; |
| 894 | 890 |
| 895 // The text that is currently selected in the plugin. | 891 // The text that is currently selected in the plugin. |
| 896 base::string16 selected_text_; | 892 base::string16 selected_text_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 907 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; | 903 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; |
| 908 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; | 904 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; |
| 909 | 905 |
| 910 friend class PpapiPluginInstanceTest; | 906 friend class PpapiPluginInstanceTest; |
| 911 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); | 907 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); |
| 912 }; | 908 }; |
| 913 | 909 |
| 914 } // namespace content | 910 } // namespace content |
| 915 | 911 |
| 916 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 912 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| OLD | NEW |