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

Side by Side Diff: chrome/plugin/npobject_proxy.h

Issue 6672048: Move plugin code to content. (Closed) Base URL: svn://chrome-svn/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
« no previous file with comments | « chrome/plugin/npobject_base.h ('k') | chrome/plugin/npobject_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // A proxy for NPObject that sends all calls to the object to an NPObjectStub
6 // running in a different process.
7
8 #ifndef CHROME_PLUGIN_NPOBJECT_PROXY_H_
9 #define CHROME_PLUGIN_NPOBJECT_PROXY_H_
10 #pragma once
11
12 #include "base/ref_counted.h"
13 #include "chrome/plugin/npobject_base.h"
14 #include "googleurl/src/gurl.h"
15 #include "ipc/ipc_channel.h"
16 #include "third_party/npapi/bindings/npruntime.h"
17 #include "ui/gfx/native_widget_types.h"
18
19 class PluginChannelBase;
20 struct NPObject;
21
22 // When running a plugin in a different process from the renderer, we need to
23 // proxy calls to NPObjects across process boundaries. This happens both ways,
24 // as a plugin can get an NPObject for the window, and a page can get an
25 // NPObject for the plugin. In the process that interacts with the NPobject we
26 // give it an NPObjectProxy instead. All calls to it are sent across an IPC
27 // channel (specifically, a PluginChannelBase). The NPObjectStub on the other
28 // side translates the IPC messages into calls to the actual NPObject, and
29 // returns the marshalled result.
30 class NPObjectProxy : public IPC::Channel::Listener,
31 public IPC::Message::Sender,
32 public NPObjectBase {
33 public:
34 ~NPObjectProxy();
35
36 static NPObject* Create(PluginChannelBase* channel,
37 int route_id,
38 gfx::NativeViewId containing_window,
39 const GURL& page_url);
40
41 // IPC::Message::Sender implementation:
42 virtual bool Send(IPC::Message* msg);
43 int route_id() { return route_id_; }
44 PluginChannelBase* channel() { return channel_; }
45
46 // The next 9 functions are called on NPObjects from the plugin and browser.
47 static bool NPHasMethod(NPObject *obj,
48 NPIdentifier name);
49 static bool NPInvoke(NPObject *obj,
50 NPIdentifier name,
51 const NPVariant *args,
52 uint32_t arg_count,
53 NPVariant *result);
54 static bool NPInvokeDefault(NPObject *npobj,
55 const NPVariant *args,
56 uint32_t arg_count,
57 NPVariant *result);
58 static bool NPHasProperty(NPObject *obj,
59 NPIdentifier name);
60 static bool NPGetProperty(NPObject *obj,
61 NPIdentifier name,
62 NPVariant *result);
63 static bool NPSetProperty(NPObject *obj,
64 NPIdentifier name,
65 const NPVariant *value);
66 static bool NPRemoveProperty(NPObject *obj,
67 NPIdentifier name);
68 static bool NPNEnumerate(NPObject *obj,
69 NPIdentifier **value,
70 uint32_t *count);
71 static bool NPNConstruct(NPObject *npobj,
72 const NPVariant *args,
73 uint32_t arg_count,
74 NPVariant *result);
75
76 // The next two functions are only called on NPObjects from the browser.
77 static bool NPNEvaluate(NPP npp,
78 NPObject *obj,
79 NPString *script,
80 NPVariant *result);
81
82 static bool NPInvokePrivate(NPP npp,
83 NPObject *obj,
84 bool is_default,
85 NPIdentifier name,
86 const NPVariant *args,
87 uint32_t arg_count,
88 NPVariant *result);
89
90 static NPObjectProxy* GetProxy(NPObject* object);
91 static const NPClass* npclass() { return &npclass_proxy_; }
92
93 // NPObjectBase implementation.
94 virtual NPObject* GetUnderlyingNPObject();
95
96 virtual IPC::Channel::Listener* GetChannelListener();
97
98 private:
99 NPObjectProxy(PluginChannelBase* channel,
100 int route_id,
101 gfx::NativeViewId containing_window,
102 const GURL& page_url);
103
104 // IPC::Channel::Listener implementation:
105 virtual bool OnMessageReceived(const IPC::Message& msg);
106 virtual void OnChannelError();
107
108 static NPObject* NPAllocate(NPP, NPClass*);
109 static void NPDeallocate(NPObject* npObj);
110
111 // This function is only caled on NPObjects from the plugin.
112 static void NPPInvalidate(NPObject *obj);
113 static NPClass npclass_proxy_;
114
115 scoped_refptr<PluginChannelBase> channel_;
116 int route_id_;
117 gfx::NativeViewId containing_window_;
118
119 // The url of the main frame hosting the plugin.
120 GURL page_url_;
121 };
122
123 #endif // CHROME_PLUGIN_NPOBJECT_PROXY_H_
OLDNEW
« no previous file with comments | « chrome/plugin/npobject_base.h ('k') | chrome/plugin/npobject_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698