| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // A proxy for NPObject that sends all calls to the object to an NPObjectStub | 5 // A proxy for NPObject that sends all calls to the object to an NPObjectStub |
| 6 // running in a different process. | 6 // running in a different process. |
| 7 | 7 |
| 8 #ifndef CHROME_PLUGIN_NPOBJECT_PROXY_H_ | 8 #ifndef CHROME_PLUGIN_NPOBJECT_PROXY_H_ |
| 9 #define CHROME_PLUGIN_NPOBJECT_PROXY_H_ | 9 #define CHROME_PLUGIN_NPOBJECT_PROXY_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public NPObjectBase { | 32 public NPObjectBase { |
| 33 public: | 33 public: |
| 34 ~NPObjectProxy(); | 34 ~NPObjectProxy(); |
| 35 | 35 |
| 36 static NPObject* Create(PluginChannelBase* channel, | 36 static NPObject* Create(PluginChannelBase* channel, |
| 37 int route_id, | 37 int route_id, |
| 38 gfx::NativeViewId containing_window, | 38 gfx::NativeViewId containing_window, |
| 39 const GURL& page_url); | 39 const GURL& page_url); |
| 40 | 40 |
| 41 // IPC::Message::Sender implementation: | 41 // IPC::Message::Sender implementation: |
| 42 bool Send(IPC::Message* msg); | 42 virtual bool Send(IPC::Message* msg); |
| 43 int route_id() { return route_id_; } | 43 int route_id() { return route_id_; } |
| 44 PluginChannelBase* channel() { return channel_; } | 44 PluginChannelBase* channel() { return channel_; } |
| 45 | 45 |
| 46 // The next 9 functions are called on NPObjects from the plugin and browser. | 46 // The next 9 functions are called on NPObjects from the plugin and browser. |
| 47 static bool NPHasMethod(NPObject *obj, | 47 static bool NPHasMethod(NPObject *obj, |
| 48 NPIdentifier name); | 48 NPIdentifier name); |
| 49 static bool NPInvoke(NPObject *obj, | 49 static bool NPInvoke(NPObject *obj, |
| 50 NPIdentifier name, | 50 NPIdentifier name, |
| 51 const NPVariant *args, | 51 const NPVariant *args, |
| 52 uint32_t arg_count, | 52 uint32_t arg_count, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bool is_default, | 84 bool is_default, |
| 85 NPIdentifier name, | 85 NPIdentifier name, |
| 86 const NPVariant *args, | 86 const NPVariant *args, |
| 87 uint32_t arg_count, | 87 uint32_t arg_count, |
| 88 NPVariant *result); | 88 NPVariant *result); |
| 89 | 89 |
| 90 static NPObjectProxy* GetProxy(NPObject* object); | 90 static NPObjectProxy* GetProxy(NPObject* object); |
| 91 static const NPClass* npclass() { return &npclass_proxy_; } | 91 static const NPClass* npclass() { return &npclass_proxy_; } |
| 92 | 92 |
| 93 // NPObjectBase implementation. | 93 // NPObjectBase implementation. |
| 94 virtual NPObject* GetUnderlyingNPObject() { | 94 virtual NPObject* GetUnderlyingNPObject(); |
| 95 return NULL; | |
| 96 } | |
| 97 | 95 |
| 98 IPC::Channel::Listener* GetChannelListener() { | 96 virtual IPC::Channel::Listener* GetChannelListener(); |
| 99 return static_cast<IPC::Channel::Listener*>(this); | |
| 100 } | |
| 101 | 97 |
| 102 private: | 98 private: |
| 103 NPObjectProxy(PluginChannelBase* channel, | 99 NPObjectProxy(PluginChannelBase* channel, |
| 104 int route_id, | 100 int route_id, |
| 105 gfx::NativeViewId containing_window, | 101 gfx::NativeViewId containing_window, |
| 106 const GURL& page_url); | 102 const GURL& page_url); |
| 107 | 103 |
| 108 // IPC::Channel::Listener implementation: | 104 // IPC::Channel::Listener implementation: |
| 109 void OnMessageReceived(const IPC::Message& msg); | 105 virtual void OnMessageReceived(const IPC::Message& msg); |
| 110 void OnChannelError(); | 106 virtual void OnChannelError(); |
| 111 | 107 |
| 112 static NPObject* NPAllocate(NPP, NPClass*); | 108 static NPObject* NPAllocate(NPP, NPClass*); |
| 113 static void NPDeallocate(NPObject* npObj); | 109 static void NPDeallocate(NPObject* npObj); |
| 114 | 110 |
| 115 // This function is only caled on NPObjects from the plugin. | 111 // This function is only caled on NPObjects from the plugin. |
| 116 static void NPPInvalidate(NPObject *obj); | 112 static void NPPInvalidate(NPObject *obj); |
| 117 static NPClass npclass_proxy_; | 113 static NPClass npclass_proxy_; |
| 118 | 114 |
| 119 scoped_refptr<PluginChannelBase> channel_; | 115 scoped_refptr<PluginChannelBase> channel_; |
| 120 int route_id_; | 116 int route_id_; |
| 121 gfx::NativeViewId containing_window_; | 117 gfx::NativeViewId containing_window_; |
| 122 | 118 |
| 123 // The url of the main frame hosting the plugin. | 119 // The url of the main frame hosting the plugin. |
| 124 GURL page_url_; | 120 GURL page_url_; |
| 125 }; | 121 }; |
| 126 | 122 |
| 127 #endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_ | 123 #endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_ |
| OLD | NEW |