chromeos: dbus: add Bluetooth properties support
[chromium-blink-merge.git] / content / common / npobject_stub.h
blob9b64ce8f75e7e6875a01e7dd28966da7f2b1fbe2
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
3 // found in the LICENSE file.
4 //
5 // A class that receives IPC messages from an NPObjectProxy and calls the real
6 // NPObject.
8 #ifndef CONTENT_COMMON_NPOBJECT_STUB_H_
9 #define CONTENT_COMMON_NPOBJECT_STUB_H_
10 #pragma once
12 #include <vector>
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/common/npobject_base.h"
17 #include "googleurl/src/gurl.h"
18 #include "ipc/ipc_channel.h"
19 #include "ui/gfx/native_widget_types.h"
21 class NPChannelBase;
22 struct NPIdentifier_Param;
23 struct NPObject;
24 struct NPVariant_Param;
26 // This wraps an NPObject and converts IPC messages from NPObjectProxy to calls
27 // to the object. The results are marshalled back. See npobject_proxy.h for
28 // more information.
29 class NPObjectStub : public IPC::Channel::Listener,
30 public IPC::Message::Sender,
31 public base::SupportsWeakPtr<NPObjectStub>,
32 public NPObjectBase {
33 public:
34 NPObjectStub(NPObject* npobject,
35 NPChannelBase* channel,
36 int route_id,
37 gfx::NativeViewId containing_window,
38 const GURL& page_url);
39 virtual ~NPObjectStub();
41 // Schedules tear-down of this stub. The underlying NPObject reference is
42 // released, and further invokations form the IPC channel will fail once this
43 // call has returned. Deletion of the stub is deferred to the main loop, in
44 // case it is touched as the stack unwinds.
45 void DeleteSoon();
47 // IPC::Message::Sender implementation:
48 virtual bool Send(IPC::Message* msg) OVERRIDE;
50 // NPObjectBase implementation.
51 virtual NPObject* GetUnderlyingNPObject() OVERRIDE;
52 virtual IPC::Channel::Listener* GetChannelListener() OVERRIDE;
54 private:
55 // IPC::Channel::Listener implementation:
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
57 virtual void OnChannelError() OVERRIDE;
59 // message handlers
60 void OnRelease(IPC::Message* reply_msg);
61 void OnHasMethod(const NPIdentifier_Param& name,
62 bool* result);
63 void OnInvoke(bool is_default,
64 const NPIdentifier_Param& method,
65 const std::vector<NPVariant_Param>& args,
66 IPC::Message* reply_msg);
67 void OnHasProperty(const NPIdentifier_Param& name,
68 bool* result);
69 void OnGetProperty(const NPIdentifier_Param& name,
70 NPVariant_Param* property,
71 bool* result);
72 void OnSetProperty(const NPIdentifier_Param& name,
73 const NPVariant_Param& property,
74 IPC::Message* reply_msg);
75 void OnRemoveProperty(const NPIdentifier_Param& name,
76 bool* result);
77 void OnInvalidate();
78 void OnEnumeration(std::vector<NPIdentifier_Param>* value,
79 bool* result);
80 void OnConstruct(const std::vector<NPVariant_Param>& args,
81 IPC::Message* reply_msg);
82 void OnEvaluate(const std::string& script, bool popups_allowed,
83 IPC::Message* reply_msg);
85 private:
86 NPObject* npobject_;
87 scoped_refptr<NPChannelBase> channel_;
88 int route_id_;
89 gfx::NativeViewId containing_window_;
91 // The url of the main frame hosting the plugin.
92 GURL page_url_;
95 #endif // CONTENT_COMMON_NPOBJECT_STUB_H_