Index: webkit/plugins/ppapi/ppapi_plugin_instance.h |
=================================================================== |
--- webkit/plugins/ppapi/ppapi_plugin_instance.h (revision 77426) |
+++ webkit/plugins/ppapi/ppapi_plugin_instance.h (working copy) |
@@ -53,6 +53,7 @@ |
namespace ppapi { |
class FullscreenContainer; |
+class MessageChannel; |
class ObjectVar; |
class PluginDelegate; |
class PluginModule; |
@@ -69,12 +70,18 @@ |
// ResourceTracker. |
class PluginInstance : public base::RefCounted<PluginInstance> { |
public: |
+ enum InterfaceOwner { |
+ BROWSER_OWNS_INTERFACE, |
+ PLUGIN_OWNS_INTERFACE |
+ }; |
+ |
PluginInstance(PluginDelegate* delegate, |
PluginModule* module, |
- const PPP_Instance* instance_interface); |
+ const PPP_Instance* instance_interface, |
+ InterfaceOwner ppp_instance_owner); |
~PluginInstance(); |
- static const PPB_Instance* GetInterface(); |
+ static const void* GetInterface(const std::string& interface); |
// Returns a pointer to the interface implementing PPB_Find that is |
// exposed to the plugin. |
@@ -84,6 +91,7 @@ |
PluginDelegate* delegate() const { return delegate_; } |
PluginModule* module() const { return module_.get(); } |
+ MessageChannel& message_channel() { return *message_channel_; } |
WebKit::WebPluginContainer* container() const { return container_; } |
@@ -132,6 +140,7 @@ |
bool full_frame() const { return full_frame_; } |
bool SetCursor(PP_CursorType_Dev type); |
PP_Var ExecuteScript(PP_Var script, PP_Var* exception); |
+ void PostMessage(PP_Var message); |
// PPP_Instance pass-through. |
void Delete(); |
@@ -142,6 +151,7 @@ |
bool HandleDocumentLoad(PPB_URLLoader_Impl* loader); |
bool HandleInputEvent(const WebKit::WebInputEvent& event, |
WebKit::WebCursorInfo* cursor_info); |
+ void HandleMessage(PP_Var message); |
PP_Var GetInstanceObject(); |
void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); |
@@ -358,6 +368,10 @@ |
// True if we are in fullscreen mode. Note: it is false during the transition. |
bool fullscreen_; |
+ // The MessageChannel used to implement bidirectional postMessage for the |
+ // instance. |
+ scoped_ptr<MessageChannel> message_channel_; |
+ |
typedef std::set<PluginObject*> PluginObjectSet; |
PluginObjectSet live_plugin_objects_; |
@@ -366,6 +380,13 @@ |
typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap; |
NPObjectToObjectVarMap np_object_to_object_var_; |
+ // Specifies whether the PPP_Instance interface (instance_interface_) is |
+ // owned by the browser or the plug-in. If the browser had to create it for |
+ // backwards-compatibility, the browser must delete it when the instance is |
+ // destroyed. Under normal circumstances, the interface is owned by the |
+ // plugin and the browser must not delete it. |
+ InterfaceOwner ppp_instance_owner_; |
+ |
DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
}; |