OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 class that receives IPC messages from an NPObjectProxy and calls the real | 5 // A class that receives IPC messages from an NPObjectProxy and calls the real |
6 // NPObject. | 6 // NPObject. |
7 | 7 |
8 #ifndef CONTENT_COMMON_NPOBJECT_STUB_H_ | 8 #ifndef CONTENT_COMMON_NPOBJECT_STUB_H_ |
9 #define CONTENT_COMMON_NPOBJECT_STUB_H_ | 9 #define CONTENT_COMMON_NPOBJECT_STUB_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "content/common/npobject_base.h" | 16 #include "content/common/npobject_base.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "ipc/ipc_channel.h" | 18 #include "ipc/ipc_listener.h" |
| 19 #include "ipc/ipc_sender.h" |
19 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
20 | 21 |
21 class NPChannelBase; | 22 class NPChannelBase; |
22 struct NPIdentifier_Param; | 23 struct NPIdentifier_Param; |
23 struct NPObject; | 24 struct NPObject; |
24 struct NPVariant_Param; | 25 struct NPVariant_Param; |
25 | 26 |
26 // This wraps an NPObject and converts IPC messages from NPObjectProxy to calls | 27 // 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 // to the object. The results are marshalled back. See npobject_proxy.h for |
28 // more information. | 29 // more information. |
29 class NPObjectStub : public IPC::Channel::Listener, | 30 class NPObjectStub : public IPC::Listener, |
30 public IPC::Message::Sender, | 31 public IPC::Sender, |
31 public base::SupportsWeakPtr<NPObjectStub>, | 32 public base::SupportsWeakPtr<NPObjectStub>, |
32 public NPObjectBase { | 33 public NPObjectBase { |
33 public: | 34 public: |
34 NPObjectStub(NPObject* npobject, | 35 NPObjectStub(NPObject* npobject, |
35 NPChannelBase* channel, | 36 NPChannelBase* channel, |
36 int route_id, | 37 int route_id, |
37 gfx::NativeViewId containing_window, | 38 gfx::NativeViewId containing_window, |
38 const GURL& page_url); | 39 const GURL& page_url); |
39 virtual ~NPObjectStub(); | 40 virtual ~NPObjectStub(); |
40 | 41 |
41 // Schedules tear-down of this stub. The underlying NPObject reference is | 42 // 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 // 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 // call has returned. Deletion of the stub is deferred to the main loop, in |
44 // case it is touched as the stack unwinds. DeleteSoon() is safe to call | 45 // case it is touched as the stack unwinds. DeleteSoon() is safe to call |
45 // more than once, until control returns to the main loop. | 46 // more than once, until control returns to the main loop. |
46 void DeleteSoon(); | 47 void DeleteSoon(); |
47 | 48 |
48 // IPC::Message::Sender implementation: | 49 // IPC::Sender implementation: |
49 virtual bool Send(IPC::Message* msg) OVERRIDE; | 50 virtual bool Send(IPC::Message* msg) OVERRIDE; |
50 | 51 |
51 // NPObjectBase implementation. | 52 // NPObjectBase implementation. |
52 virtual NPObject* GetUnderlyingNPObject() OVERRIDE; | 53 virtual NPObject* GetUnderlyingNPObject() OVERRIDE; |
53 virtual IPC::Channel::Listener* GetChannelListener() OVERRIDE; | 54 virtual IPC::Listener* GetChannelListener() OVERRIDE; |
54 | 55 |
55 private: | 56 private: |
56 // IPC::Channel::Listener implementation: | 57 // IPC::Listener implementation: |
57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
58 virtual void OnChannelError() OVERRIDE; | 59 virtual void OnChannelError() OVERRIDE; |
59 | 60 |
60 // message handlers | 61 // message handlers |
61 void OnRelease(IPC::Message* reply_msg); | 62 void OnRelease(IPC::Message* reply_msg); |
62 void OnHasMethod(const NPIdentifier_Param& name, | 63 void OnHasMethod(const NPIdentifier_Param& name, |
63 bool* result); | 64 bool* result); |
64 void OnInvoke(bool is_default, | 65 void OnInvoke(bool is_default, |
65 const NPIdentifier_Param& method, | 66 const NPIdentifier_Param& method, |
66 const std::vector<NPVariant_Param>& args, | 67 const std::vector<NPVariant_Param>& args, |
(...skipping 20 matching lines...) Expand all Loading... |
87 NPObject* npobject_; | 88 NPObject* npobject_; |
88 scoped_refptr<NPChannelBase> channel_; | 89 scoped_refptr<NPChannelBase> channel_; |
89 int route_id_; | 90 int route_id_; |
90 gfx::NativeViewId containing_window_; | 91 gfx::NativeViewId containing_window_; |
91 | 92 |
92 // The url of the main frame hosting the plugin. | 93 // The url of the main frame hosting the plugin. |
93 GURL page_url_; | 94 GURL page_url_; |
94 }; | 95 }; |
95 | 96 |
96 #endif // CONTENT_COMMON_NPOBJECT_STUB_H_ | 97 #endif // CONTENT_COMMON_NPOBJECT_STUB_H_ |
OLD | NEW |