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