Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_bindings.h

Issue 11826005: Browser Plugin: Implement BrowserPluginObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/scoped_vector.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "ppapi/shared_impl/resource.h" 10 #include "ppapi/shared_impl/resource.h"
11 #include "third_party/npapi/bindings/npruntime.h" 11 #include "third_party/npapi/bindings/npruntime.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class BrowserPlugin; 15 class BrowserPluginImpl;
16 class BrowserPluginMethodBinding; 16 class BrowserPluginMethodBinding;
17 class BrowserPluginPropertyBinding; 17 class BrowserPluginPropertyBinding;
18 18
19 class BrowserPluginBindings { 19 class BrowserPluginBindings {
20 public: 20 public:
21 // BrowserPluginNPObject is a simple struct that adds a pointer back to a 21 // BrowserPluginNPObject is a simple struct that adds a pointer back to a
22 // BrowserPluginBindings instance. This way, we can use an NPObject to allow 22 // BrowserPluginBindings instance. This way, we can use an NPObject to allow
23 // JavaScript interactions without forcing BrowserPluginBindings to inherit 23 // JavaScript interactions without forcing BrowserPluginBindings to inherit
24 // from NPObject. 24 // from NPObject.
25 struct BrowserPluginNPObject : public NPObject { 25 struct BrowserPluginNPObject : public NPObject {
26 BrowserPluginNPObject(); 26 BrowserPluginNPObject();
27 ~BrowserPluginNPObject(); 27 ~BrowserPluginNPObject();
28 28
29 base::WeakPtr<BrowserPluginBindings> message_channel; 29 base::WeakPtr<BrowserPluginBindings> message_channel;
30 }; 30 };
31 31
32 explicit BrowserPluginBindings(BrowserPlugin* instance); 32 explicit BrowserPluginBindings(BrowserPluginImpl* instance);
33 ~BrowserPluginBindings(); 33 ~BrowserPluginBindings();
34 34
35 NPObject* np_object() const { return np_object_; } 35 NPObject* np_object() const { return np_object_; }
36 36
37 BrowserPlugin* instance() const { return instance_; } 37 BrowserPluginImpl* instance() const { return instance_; }
38 38
39 bool HasMethod(NPIdentifier name) const; 39 bool HasMethod(NPIdentifier name) const;
40 40
41 bool InvokeMethod(NPIdentifier name, 41 bool InvokeMethod(NPIdentifier name,
42 const NPVariant* args, 42 const NPVariant* args,
43 uint32 arg_count, 43 uint32 arg_count,
44 NPVariant* result); 44 NPVariant* result);
45 45
46 bool HasProperty(NPIdentifier name) const; 46 bool HasProperty(NPIdentifier name) const;
47 bool SetProperty(NPObject* np_obj, 47 bool SetProperty(NPObject* np_obj,
48 NPIdentifier name, 48 NPIdentifier name,
49 const NPVariant* variant); 49 const NPVariant* variant);
50 bool GetProperty(NPIdentifier name, NPVariant* result); 50 bool GetProperty(NPIdentifier name, NPVariant* result);
51
52 void AddMethodBinding(BrowserPluginMethodBinding* method_binding);
sadrul 2013/01/09 15:21:54 Comment on ownership/lifetime
Fady Samuel 2013/01/09 17:41:24 Done.
53 void AddPropertyBinding(BrowserPluginPropertyBinding* property_binding);
54
51 private: 55 private:
52 BrowserPlugin* instance_; 56 BrowserPluginImpl* instance_;
53 // The NPObject we use to expose postMessage to JavaScript. 57 // The NPObject we use to expose postMessage to JavaScript.
54 BrowserPluginNPObject* np_object_; 58 BrowserPluginNPObject* np_object_;
55 59
56 typedef ScopedVector<BrowserPluginMethodBinding> BindingList; 60 typedef ScopedVector<BrowserPluginMethodBinding> BindingList;
57 BindingList method_bindings_; 61 BindingList method_bindings_;
58 typedef ScopedVector<BrowserPluginPropertyBinding> PropertyBindingList; 62 typedef ScopedVector<BrowserPluginPropertyBinding> PropertyBindingList;
59 PropertyBindingList property_bindings_; 63 PropertyBindingList property_bindings_;
60 64
61 // This is used to ensure pending tasks will not fire after this object is 65 // This is used to ensure pending tasks will not fire after this object is
62 // destroyed. 66 // destroyed.
63 base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_; 67 base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings); 69 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings);
66 }; 70 };
67 71
68 } // namespace content 72 } // namespace content
69 73
70 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ 74 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698