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 "content/renderer/pepper/message_channel.h" |
| 27 #include "gin/handle.h" |
26 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 28 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
27 #include "ppapi/c/dev/ppp_printing_dev.h" | 29 #include "ppapi/c/dev/ppp_printing_dev.h" |
28 #include "ppapi/c/dev/ppp_selection_dev.h" | 30 #include "ppapi/c/dev/ppp_selection_dev.h" |
29 #include "ppapi/c/dev/ppp_text_input_dev.h" | 31 #include "ppapi/c/dev/ppp_text_input_dev.h" |
30 #include "ppapi/c/dev/ppp_zoom_dev.h" | 32 #include "ppapi/c/dev/ppp_zoom_dev.h" |
31 #include "ppapi/c/pp_completion_callback.h" | 33 #include "ppapi/c/pp_completion_callback.h" |
32 #include "ppapi/c/pp_instance.h" | 34 #include "ppapi/c/pp_instance.h" |
33 #include "ppapi/c/pp_time.h" | 35 #include "ppapi/c/pp_time.h" |
34 #include "ppapi/c/pp_var.h" | 36 #include "ppapi/c/pp_var.h" |
35 #include "ppapi/c/ppb_audio_config.h" | 37 #include "ppapi/c/ppb_audio_config.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 97 } |
96 | 98 |
97 namespace v8 { | 99 namespace v8 { |
98 class Isolate; | 100 class Isolate; |
99 } | 101 } |
100 | 102 |
101 namespace content { | 103 namespace content { |
102 | 104 |
103 class ContentDecryptorDelegate; | 105 class ContentDecryptorDelegate; |
104 class FullscreenContainer; | 106 class FullscreenContainer; |
105 class MessageChannel; | |
106 class PepperCompositorHost; | 107 class PepperCompositorHost; |
107 class PepperGraphics2DHost; | 108 class PepperGraphics2DHost; |
108 class PluginModule; | 109 class PluginModule; |
109 class PluginObject; | 110 class PluginObject; |
110 class PPB_Graphics3D_Impl; | 111 class PPB_Graphics3D_Impl; |
111 class PPB_ImageData_Impl; | 112 class PPB_ImageData_Impl; |
112 class PPB_URLLoader_Impl; | 113 class PPB_URLLoader_Impl; |
113 class RenderFrameImpl; | 114 class RenderFrameImpl; |
114 class RenderViewImpl; | 115 class RenderViewImpl; |
115 | 116 |
(...skipping 11 matching lines...) Expand all Loading... |
127 // Create and return a PepperPluginInstanceImpl object which supports the most | 128 // Create and return a PepperPluginInstanceImpl object which supports the most |
128 // recent version of PPP_Instance possible by querying the given | 129 // recent version of PPP_Instance possible by querying the given |
129 // get_plugin_interface function. If the plugin does not support any valid | 130 // get_plugin_interface function. If the plugin does not support any valid |
130 // PPP_Instance interface, returns NULL. | 131 // PPP_Instance interface, returns NULL. |
131 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, | 132 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, |
132 PluginModule* module, | 133 PluginModule* module, |
133 blink::WebPluginContainer* container, | 134 blink::WebPluginContainer* container, |
134 const GURL& plugin_url); | 135 const GURL& plugin_url); |
135 RenderFrameImpl* render_frame() const { return render_frame_; } | 136 RenderFrameImpl* render_frame() const { return render_frame_; } |
136 PluginModule* module() const { return module_.get(); } | 137 PluginModule* module() const { return module_.get(); } |
137 MessageChannel& message_channel() { return *message_channel_; } | |
138 | 138 |
139 blink::WebPluginContainer* container() const { return container_; } | 139 blink::WebPluginContainer* container() const { return container_; } |
140 | 140 |
141 // Returns the PP_Instance uniquely identifying this instance. Guaranteed | 141 // Returns the PP_Instance uniquely identifying this instance. Guaranteed |
142 // nonzero. | 142 // nonzero. |
143 PP_Instance pp_instance() const { return pp_instance_; } | 143 PP_Instance pp_instance() const { return pp_instance_; } |
144 | 144 |
145 ppapi::thunk::ResourceCreationAPI& resource_creation() { | 145 ppapi::thunk::ResourceCreationAPI& resource_creation() { |
146 return *resource_creation_.get(); | 146 return *resource_creation_.get(); |
147 } | 147 } |
148 | 148 |
| 149 // This pointer is only valid on the stack. |
| 150 MessageChannel* GetMessageChannel(); |
| 151 v8::Local<v8::Object> GetMessageChannelObject(); |
| 152 |
| 153 v8::Handle<v8::Context> GetPluginContext(); |
| 154 |
149 // Does some pre-destructor cleanup on the instance. This is necessary | 155 // Does some pre-destructor cleanup on the instance. This is necessary |
150 // because some cleanup depends on the plugin instance still existing (like | 156 // because some cleanup depends on the plugin instance still existing (like |
151 // calling the plugin's DidDestroy function). This function is called from | 157 // calling the plugin's DidDestroy function). This function is called from |
152 // the WebPlugin implementation when WebKit is about to remove the plugin. | 158 // the WebPlugin implementation when WebKit is about to remove the plugin. |
153 void Delete(); | 159 void Delete(); |
154 | 160 |
155 // Returns true if Delete() has been called on this object. | 161 // Returns true if Delete() has been called on this object. |
156 bool is_deleted() const; | 162 bool is_deleted() const; |
157 | 163 |
158 // Paints the current backing store to the web page. | 164 // Paints the current backing store to the web page. |
(...skipping 23 matching lines...) Expand all Loading... |
182 bool full_frame() const { return full_frame_; } | 188 bool full_frame() const { return full_frame_; } |
183 const ppapi::ViewData& view_data() const { return view_data_; } | 189 const ppapi::ViewData& view_data() const { return view_data_; } |
184 | 190 |
185 // PPP_Instance and PPP_Instance_Private. | 191 // PPP_Instance and PPP_Instance_Private. |
186 bool Initialize(const std::vector<std::string>& arg_names, | 192 bool Initialize(const std::vector<std::string>& arg_names, |
187 const std::vector<std::string>& arg_values, | 193 const std::vector<std::string>& arg_values, |
188 bool full_frame); | 194 bool full_frame); |
189 bool HandleDocumentLoad(const blink::WebURLResponse& response); | 195 bool HandleDocumentLoad(const blink::WebURLResponse& response); |
190 bool HandleInputEvent(const blink::WebInputEvent& event, | 196 bool HandleInputEvent(const blink::WebInputEvent& event, |
191 blink::WebCursorInfo* cursor_info); | 197 blink::WebCursorInfo* cursor_info); |
192 PP_Var GetInstanceObject(); | 198 PP_Var GetInstanceObject(v8::Isolate* isolate); |
193 void ViewChanged(const gfx::Rect& position, | 199 void ViewChanged(const gfx::Rect& position, |
194 const gfx::Rect& clip, | 200 const gfx::Rect& clip, |
195 const std::vector<gfx::Rect>& cut_outs_rects); | 201 const std::vector<gfx::Rect>& cut_outs_rects); |
196 | 202 |
197 // Handlers for composition events. | 203 // Handlers for composition events. |
198 bool HandleCompositionStart(const base::string16& text); | 204 bool HandleCompositionStart(const base::string16& text); |
199 bool HandleCompositionUpdate( | 205 bool HandleCompositionUpdate( |
200 const base::string16& text, | 206 const base::string16& text, |
201 const std::vector<blink::WebCompositionUnderline>& underlines, | 207 const std::vector<blink::WebCompositionUnderline>& underlines, |
202 int selection_start, | 208 int selection_start, |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // external out-of-process instance. | 517 // external out-of-process instance. |
512 PP_ExternalPluginResult ResetAsProxied(scoped_refptr<PluginModule> module); | 518 PP_ExternalPluginResult ResetAsProxied(scoped_refptr<PluginModule> module); |
513 | 519 |
514 // Checks whether this is a valid instance of the given module. After calling | 520 // 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 | 521 // 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 | 522 // 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 | 523 // method fixes that be checking that either module_ or original_module_ match |
518 // the given module. | 524 // the given module. |
519 bool IsValidInstanceOf(PluginModule* module); | 525 bool IsValidInstanceOf(PluginModule* module); |
520 | 526 |
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. | 527 // cc::TextureLayerClient implementation. |
526 virtual bool PrepareTextureMailbox( | 528 virtual bool PrepareTextureMailbox( |
527 cc::TextureMailbox* mailbox, | 529 cc::TextureMailbox* mailbox, |
528 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 530 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
529 bool use_shared_memory) OVERRIDE; | 531 bool use_shared_memory) OVERRIDE; |
530 | 532 |
531 // RenderFrameObserver | 533 // RenderFrameObserver |
532 virtual void OnDestruct() OVERRIDE; | 534 virtual void OnDestruct() OVERRIDE; |
533 | 535 |
534 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 536 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 | 825 // this here by modifying the various plugin attributes and then restoring |
824 // them on exit. | 826 // them on exit. |
825 blink::WebString width_before_fullscreen_; | 827 blink::WebString width_before_fullscreen_; |
826 blink::WebString height_before_fullscreen_; | 828 blink::WebString height_before_fullscreen_; |
827 blink::WebString border_before_fullscreen_; | 829 blink::WebString border_before_fullscreen_; |
828 blink::WebString style_before_fullscreen_; | 830 blink::WebString style_before_fullscreen_; |
829 gfx::Size screen_size_for_fullscreen_; | 831 gfx::Size screen_size_for_fullscreen_; |
830 | 832 |
831 // The MessageChannel used to implement bidirectional postMessage for the | 833 // The MessageChannel used to implement bidirectional postMessage for the |
832 // instance. | 834 // instance. |
833 scoped_ptr<MessageChannel> message_channel_; | 835 v8::Persistent<v8::Object> message_channel_; |
834 | 836 |
835 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 837 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
836 SkBitmap* sad_plugin_; | 838 SkBitmap* sad_plugin_; |
837 | 839 |
838 typedef std::set<PluginObject*> PluginObjectSet; | 840 typedef std::set<PluginObject*> PluginObjectSet; |
839 PluginObjectSet live_plugin_objects_; | 841 PluginObjectSet live_plugin_objects_; |
840 | 842 |
841 // Classes of events that the plugin has registered for, both for filtering | 843 // Classes of events that the plugin has registered for, both for filtering |
842 // and not. The bits are PP_INPUTEVENT_CLASS_*. | 844 // and not. The bits are PP_INPUTEVENT_CLASS_*. |
843 uint32_t input_event_mask_; | 845 uint32_t input_event_mask_; |
(...skipping 29 matching lines...) Expand all Loading... |
873 scoped_ptr<ExternalDocumentLoader> external_document_loader_; | 875 scoped_ptr<ExternalDocumentLoader> external_document_loader_; |
874 bool external_document_load_; | 876 bool external_document_load_; |
875 | 877 |
876 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private | 878 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private |
877 // calls and handles PPB_ContentDecryptor_Private calls. | 879 // calls and handles PPB_ContentDecryptor_Private calls. |
878 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; | 880 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; |
879 | 881 |
880 // The link currently under the cursor. | 882 // The link currently under the cursor. |
881 base::string16 link_under_cursor_; | 883 base::string16 link_under_cursor_; |
882 | 884 |
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 | 885 // 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. | 886 // Isolate in which this Instance was created when interacting with v8. |
889 v8::Isolate* isolate_; | 887 v8::Isolate* isolate_; |
890 | 888 |
891 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; | 889 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; |
892 | 890 |
893 bool is_deleted_; | 891 bool is_deleted_; |
894 | 892 |
895 // The text that is currently selected in the plugin. | 893 // The text that is currently selected in the plugin. |
896 base::string16 selected_text_; | 894 base::string16 selected_text_; |
(...skipping 10 matching lines...) Expand all Loading... |
907 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; | 905 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; |
908 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; | 906 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; |
909 | 907 |
910 friend class PpapiPluginInstanceTest; | 908 friend class PpapiPluginInstanceTest; |
911 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); | 909 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); |
912 }; | 910 }; |
913 | 911 |
914 } // namespace content | 912 } // namespace content |
915 | 913 |
916 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 914 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
OLD | NEW |