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