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 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ |
7 | 7 |
| 8 #include "base/memory/scoped_vector.h" |
8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
9 #include "ppapi/shared_impl/resource.h" | 10 #include "ppapi/shared_impl/resource.h" |
10 #include "third_party/npapi/bindings/npruntime.h" | 11 #include "third_party/npapi/bindings/npruntime.h" |
11 | 12 |
12 namespace WebKit { | 13 namespace WebKit { |
13 class WebSerializedScriptValue; | 14 class WebSerializedScriptValue; |
14 } | 15 } |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
| 19 namespace internal { |
| 20 class BrowserPluginMethodBinding; |
| 21 } |
| 22 |
18 class BrowserPlugin; | 23 class BrowserPlugin; |
19 | 24 |
20 class BrowserPluginBindings { | 25 class BrowserPluginBindings { |
21 public: | 26 public: |
22 // BrowserPluginNPObject is a simple struct that adds a pointer back to a | 27 // BrowserPluginNPObject is a simple struct that adds a pointer back to a |
23 // BrowserPluginBindings instance. This way, we can use an NPObject to allow | 28 // BrowserPluginBindings instance. This way, we can use an NPObject to allow |
24 // JavaScript interactions without forcing BrowserPluginBindings to inherit | 29 // JavaScript interactions without forcing BrowserPluginBindings to inherit |
25 // from NPObject. | 30 // from NPObject. |
26 struct BrowserPluginNPObject : public NPObject { | 31 struct BrowserPluginNPObject : public NPObject { |
27 BrowserPluginNPObject(); | 32 BrowserPluginNPObject(); |
28 ~BrowserPluginNPObject(); | 33 ~BrowserPluginNPObject(); |
29 | 34 |
30 base::WeakPtr<BrowserPluginBindings> message_channel; | 35 base::WeakPtr<BrowserPluginBindings> message_channel; |
31 }; | 36 }; |
32 | 37 |
33 explicit BrowserPluginBindings(BrowserPlugin* instance); | 38 explicit BrowserPluginBindings(BrowserPlugin* instance); |
34 ~BrowserPluginBindings(); | 39 ~BrowserPluginBindings(); |
35 | 40 |
36 NPObject* np_object() const { return np_object_; } | 41 NPObject* np_object() const { return np_object_; } |
37 | 42 |
38 BrowserPlugin* instance() const { return instance_; } | 43 BrowserPlugin* instance() const { return instance_; } |
| 44 |
| 45 bool HasMethod(NPIdentifier name) const; |
| 46 |
| 47 bool InvokeMethod(NPIdentifier name, |
| 48 const NPVariant* args, |
| 49 uint32 arg_count, |
| 50 NPVariant* result); |
39 private: | 51 private: |
40 BrowserPlugin* instance_; | 52 BrowserPlugin* instance_; |
41 // The NPObject we use to expose postMessage to JavaScript. | 53 // The NPObject we use to expose postMessage to JavaScript. |
42 BrowserPluginNPObject* np_object_; | 54 BrowserPluginNPObject* np_object_; |
43 | 55 |
| 56 typedef ScopedVector<internal::BrowserPluginMethodBinding> BindingList; |
| 57 BindingList method_bindings_; |
| 58 |
44 // This is used to ensure pending tasks will not fire after this object is | 59 // This is used to ensure pending tasks will not fire after this object is |
45 // destroyed. | 60 // destroyed. |
46 base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_; | 61 base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_; |
47 | 62 |
48 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings); | 63 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings); |
49 }; | 64 }; |
50 | 65 |
51 } // namespace content | 66 } // namespace content |
52 | 67 |
53 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ | 68 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ |
OLD | NEW |