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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.h

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 namespace WebKit { 46 namespace WebKit {
47 struct WebCursorInfo; 47 struct WebCursorInfo;
48 class WebInputEvent; 48 class WebInputEvent;
49 class WebPluginContainer; 49 class WebPluginContainer;
50 } 50 }
51 51
52 namespace webkit { 52 namespace webkit {
53 namespace ppapi { 53 namespace ppapi {
54 54
55 class FullscreenContainer; 55 class FullscreenContainer;
56 class MessageChannel;
56 class ObjectVar; 57 class ObjectVar;
57 class PluginDelegate; 58 class PluginDelegate;
58 class PluginModule; 59 class PluginModule;
59 class PluginObject; 60 class PluginObject;
60 class PPB_Graphics2D_Impl; 61 class PPB_Graphics2D_Impl;
61 class PPB_ImageData_Impl; 62 class PPB_ImageData_Impl;
62 class PPB_Surface3D_Impl; 63 class PPB_Surface3D_Impl;
63 class PPB_URLLoader_Impl; 64 class PPB_URLLoader_Impl;
64 class Resource; 65 class Resource;
65 66
66 // Represents one time a plugin appears on one web page. 67 // Represents one time a plugin appears on one web page.
67 // 68 //
68 // Note: to get from a PP_Instance to a PluginInstance*, use the 69 // Note: to get from a PP_Instance to a PluginInstance*, use the
69 // ResourceTracker. 70 // ResourceTracker.
70 class PluginInstance : public base::RefCounted<PluginInstance> { 71 class PluginInstance : public base::RefCounted<PluginInstance> {
71 public: 72 public:
73 enum InterfaceOwner {
74 BROWSER_OWNS_INTERFACE,
75 PLUGIN_OWNS_INTERFACE
76 };
77
72 PluginInstance(PluginDelegate* delegate, 78 PluginInstance(PluginDelegate* delegate,
73 PluginModule* module, 79 PluginModule* module,
74 const PPP_Instance* instance_interface); 80 const PPP_Instance* instance_interface,
81 InterfaceOwner ppp_instance_owner);
75 ~PluginInstance(); 82 ~PluginInstance();
76 83
77 static const PPB_Instance* GetInterface(); 84 static const void* GetInterface(const std::string& interface);
78 85
79 // Returns a pointer to the interface implementing PPB_Find that is 86 // Returns a pointer to the interface implementing PPB_Find that is
80 // exposed to the plugin. 87 // exposed to the plugin.
81 static const PPB_Find_Dev* GetFindInterface(); 88 static const PPB_Find_Dev* GetFindInterface();
82 static const PPB_Fullscreen_Dev* GetFullscreenInterface(); 89 static const PPB_Fullscreen_Dev* GetFullscreenInterface();
83 static const PPB_Zoom_Dev* GetZoomInterface(); 90 static const PPB_Zoom_Dev* GetZoomInterface();
84 91
85 PluginDelegate* delegate() const { return delegate_; } 92 PluginDelegate* delegate() const { return delegate_; }
86 PluginModule* module() const { return module_.get(); } 93 PluginModule* module() const { return module_.get(); }
94 MessageChannel& message_channel() { return *message_channel_; }
87 95
88 WebKit::WebPluginContainer* container() const { return container_; } 96 WebKit::WebPluginContainer* container() const { return container_; }
89 97
90 const gfx::Rect& position() const { return position_; } 98 const gfx::Rect& position() const { return position_; }
91 const gfx::Rect& clip() const { return clip_; } 99 const gfx::Rect& clip() const { return clip_; }
92 100
93 int find_identifier() const { return find_identifier_; } 101 int find_identifier() const { return find_identifier_; }
94 102
95 void set_always_on_top(bool on_top) { always_on_top_ = on_top; } 103 void set_always_on_top(bool on_top) { always_on_top_ = on_top; }
96 104
(...skipping 28 matching lines...) Expand all
125 // Called when the out-of-process plugin implementing this instance crashed. 133 // Called when the out-of-process plugin implementing this instance crashed.
126 void InstanceCrashed(); 134 void InstanceCrashed();
127 135
128 // PPB_Instance implementation. 136 // PPB_Instance implementation.
129 PP_Var GetWindowObject(); 137 PP_Var GetWindowObject();
130 PP_Var GetOwnerElementObject(); 138 PP_Var GetOwnerElementObject();
131 bool BindGraphics(PP_Resource graphics_id); 139 bool BindGraphics(PP_Resource graphics_id);
132 bool full_frame() const { return full_frame_; } 140 bool full_frame() const { return full_frame_; }
133 bool SetCursor(PP_CursorType_Dev type); 141 bool SetCursor(PP_CursorType_Dev type);
134 PP_Var ExecuteScript(PP_Var script, PP_Var* exception); 142 PP_Var ExecuteScript(PP_Var script, PP_Var* exception);
143 void PostMessage(PP_Var message);
135 144
136 // PPP_Instance pass-through. 145 // PPP_Instance pass-through.
137 void Delete(); 146 void Delete();
138 bool Initialize(WebKit::WebPluginContainer* container, 147 bool Initialize(WebKit::WebPluginContainer* container,
139 const std::vector<std::string>& arg_names, 148 const std::vector<std::string>& arg_names,
140 const std::vector<std::string>& arg_values, 149 const std::vector<std::string>& arg_values,
141 bool full_frame); 150 bool full_frame);
142 bool HandleDocumentLoad(PPB_URLLoader_Impl* loader); 151 bool HandleDocumentLoad(PPB_URLLoader_Impl* loader);
143 bool HandleInputEvent(const WebKit::WebInputEvent& event, 152 bool HandleInputEvent(const WebKit::WebInputEvent& event,
144 WebKit::WebCursorInfo* cursor_info); 153 WebKit::WebCursorInfo* cursor_info);
154 void HandleMessage(PP_Var message);
145 PP_Var GetInstanceObject(); 155 PP_Var GetInstanceObject();
146 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); 156 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip);
147 157
148 // Notifications about focus changes, see has_webkit_focus_ below. 158 // Notifications about focus changes, see has_webkit_focus_ below.
149 void SetWebKitFocus(bool has_focus); 159 void SetWebKitFocus(bool has_focus);
150 void SetContentAreaFocus(bool has_focus); 160 void SetContentAreaFocus(bool has_focus);
151 161
152 // Notifications that the view has rendered the page and that it has been 162 // Notifications that the view has rendered the page and that it has been
153 // flushed to the screen. These messages are used to send Flush callbacks to 163 // flushed to the screen. These messages are used to send Flush callbacks to
154 // the plugin for DeviceContext2D. 164 // the plugin for DeviceContext2D.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 bool always_on_top_; 361 bool always_on_top_;
352 362
353 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: 363 // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note:
354 // there is a transition state where fullscreen_container_ is non-NULL but 364 // there is a transition state where fullscreen_container_ is non-NULL but
355 // fullscreen_ is false (see above). 365 // fullscreen_ is false (see above).
356 FullscreenContainer* fullscreen_container_; 366 FullscreenContainer* fullscreen_container_;
357 367
358 // True if we are in fullscreen mode. Note: it is false during the transition. 368 // True if we are in fullscreen mode. Note: it is false during the transition.
359 bool fullscreen_; 369 bool fullscreen_;
360 370
371 // The MessageChannel used to implement bidirectional postMessage for the
372 // instance.
373 scoped_ptr<MessageChannel> message_channel_;
374
361 typedef std::set<PluginObject*> PluginObjectSet; 375 typedef std::set<PluginObject*> PluginObjectSet;
362 PluginObjectSet live_plugin_objects_; 376 PluginObjectSet live_plugin_objects_;
363 377
364 // Tracks all live ObjectVars used by this module so we can map NPObjects to 378 // Tracks all live ObjectVars used by this module so we can map NPObjects to
365 // the corresponding object. These are non-owning references. 379 // the corresponding object. These are non-owning references.
366 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; 380 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap;
367 NPObjectToObjectVarMap np_object_to_object_var_; 381 NPObjectToObjectVarMap np_object_to_object_var_;
368 382
383 // Specifies whether the PPP_Instance interface (instance_interface_) is
384 // owned by the browser or the plug-in. If the browser had to create it for
385 // backwards-compatibility, the browser must delete it when the instance is
386 // destroyed. Under normal circumstances, the interface is owned by the
387 // plugin and the browser must not delete it.
388 InterfaceOwner ppp_instance_owner_;
389
369 DISALLOW_COPY_AND_ASSIGN(PluginInstance); 390 DISALLOW_COPY_AND_ASSIGN(PluginInstance);
370 }; 391 };
371 392
372 } // namespace ppapi 393 } // namespace ppapi
373 } // namespace webkit 394 } // namespace webkit
374 395
375 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_ 396 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698