Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(759)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.h

Issue 459553003: Replace NPObject usage in ppapi with gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 // Called when |message_channel_| is destroyed as it may be destroyed prior to
149 // the plugin being destroyed.
150 void MessageChannelDestroyed();
151
146 // Return the v8 context that the plugin is in. 152 // Return the v8 context that the plugin is in.
147 v8::Local<v8::Context> GetContext(); 153 v8::Local<v8::Context> GetContext();
148 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.
(...skipping 26 matching lines...) Expand all
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
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
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_object_;
836
837 // A pointer to the MessageChannel underlying |message_channel_object_|. It is
838 // only valid as long as |message_channel_object_| is alive.
839 MessageChannel* message_channel_;
834 840
835 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. 841 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer.
836 SkBitmap* sad_plugin_; 842 SkBitmap* sad_plugin_;
837 843
838 typedef std::set<PluginObject*> PluginObjectSet; 844 typedef std::set<PluginObject*> PluginObjectSet;
839 PluginObjectSet live_plugin_objects_; 845 PluginObjectSet live_plugin_objects_;
840 846
841 // Classes of events that the plugin has registered for, both for filtering 847 // Classes of events that the plugin has registered for, both for filtering
842 // and not. The bits are PP_INPUTEVENT_CLASS_*. 848 // and not. The bits are PP_INPUTEVENT_CLASS_*.
843 uint32_t input_event_mask_; 849 uint32_t input_event_mask_;
(...skipping 29 matching lines...) Expand all
873 scoped_ptr<ExternalDocumentLoader> external_document_loader_; 879 scoped_ptr<ExternalDocumentLoader> external_document_loader_;
874 bool external_document_load_; 880 bool external_document_load_;
875 881
876 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private 882 // The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private
877 // calls and handles PPB_ContentDecryptor_Private calls. 883 // calls and handles PPB_ContentDecryptor_Private calls.
878 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; 884 scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_;
879 885
880 // The link currently under the cursor. 886 // The link currently under the cursor.
881 base::string16 link_under_cursor_; 887 base::string16 link_under_cursor_;
882 888
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 889 // 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. 890 // Isolate in which this Instance was created when interacting with v8.
889 v8::Isolate* isolate_; 891 v8::Isolate* isolate_;
890 892
891 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_; 893 scoped_ptr<MouseLockDispatcher::LockTarget> lock_target_;
892 894
893 bool is_deleted_; 895 bool is_deleted_;
894 896
895 // The text that is currently selected in the plugin. 897 // The text that is currently selected in the plugin.
896 base::string16 selected_text_; 898 base::string16 selected_text_;
(...skipping 10 matching lines...) Expand all
907 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; 909 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_;
908 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; 910 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_;
909 911
910 friend class PpapiPluginInstanceTest; 912 friend class PpapiPluginInstanceTest;
911 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); 913 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl);
912 }; 914 };
913 915
914 } // namespace content 916 } // namespace content
915 917
916 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ 918 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/message_channel.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698