1 // Copyright 2013 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.
5 // A class that receives IPC messages from an NPObjectProxy and calls the real
8 #ifndef CONTENT_CHILD_NPOBJECT_STUB_H_
9 #define CONTENT_CHILD_NPOBJECT_STUB_H_
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "content/child/npobject_base.h"
16 #include "googleurl/src/gurl.h"
17 #include "ipc/ipc_listener.h"
18 #include "ipc/ipc_sender.h"
24 struct NPIdentifier_Param
;
25 struct NPVariant_Param
;
27 // This wraps an NPObject and converts IPC messages from NPObjectProxy to calls
28 // to the object. The results are marshalled back. See npobject_proxy.h for
30 class NPObjectStub
: public IPC::Listener
,
32 public base::SupportsWeakPtr
<NPObjectStub
>,
35 NPObjectStub(NPObject
* npobject
,
36 NPChannelBase
* channel
,
39 const GURL
& page_url
);
40 virtual ~NPObjectStub();
42 // Schedules tear-down of this stub. The underlying NPObject reference is
43 // released, and further invokations from the IPC channel will fail once this
44 // call has returned. Deletion of the stub is deferred to the main loop, in
45 // case it is touched as the stack unwinds. DeleteSoon() is safe to call
46 // more than once, until control returns to the main loop.
49 // IPC::Sender implementation:
50 virtual bool Send(IPC::Message
* msg
) OVERRIDE
;
52 // NPObjectBase implementation.
53 virtual NPObject
* GetUnderlyingNPObject() OVERRIDE
;
54 virtual IPC::Listener
* GetChannelListener() OVERRIDE
;
57 // IPC::Listener implementation:
58 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
59 virtual void OnChannelError() OVERRIDE
;
62 void OnRelease(IPC::Message
* reply_msg
);
63 void OnHasMethod(const NPIdentifier_Param
& name
,
65 void OnInvoke(bool is_default
,
66 const NPIdentifier_Param
& method
,
67 const std::vector
<NPVariant_Param
>& args
,
68 IPC::Message
* reply_msg
);
69 void OnHasProperty(const NPIdentifier_Param
& name
,
71 void OnGetProperty(const NPIdentifier_Param
& name
,
72 NPVariant_Param
* property
,
74 void OnSetProperty(const NPIdentifier_Param
& name
,
75 const NPVariant_Param
& property
,
76 IPC::Message
* reply_msg
);
77 void OnRemoveProperty(const NPIdentifier_Param
& name
,
80 void OnEnumeration(std::vector
<NPIdentifier_Param
>* value
,
82 void OnConstruct(const std::vector
<NPVariant_Param
>& args
,
83 IPC::Message
* reply_msg
);
84 void OnEvaluate(const std::string
& script
, bool popups_allowed
,
85 IPC::Message
* reply_msg
);
89 scoped_refptr
<NPChannelBase
> channel_
;
93 // The url of the main frame hosting the plugin.
97 } // namespace content
99 #endif // CONTENT_CHILD_NPOBJECT_STUB_H_