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/weak_ptr.h" |
| 9 #include "ppapi/shared_impl/resource.h" |
| 10 #include "third_party/npapi/bindings/npruntime.h" |
| 11 |
| 12 namespace WebKit { |
| 13 class WebSerializedScriptValue; |
| 14 } |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class BrowserPlugin; |
| 19 |
| 20 class BrowserPluginBindings { |
| 21 public: |
| 22 // BrowserPluginNPObject is a simple struct that adds a pointer back to a |
| 23 // BrowserPluginBindings instance. This way, we can use an NPObject to allow |
| 24 // JavaScript interactions without forcing BrowserPluginBindings to inherit |
| 25 // from NPObject. |
| 26 struct BrowserPluginNPObject : public NPObject { |
| 27 BrowserPluginNPObject(); |
| 28 ~BrowserPluginNPObject(); |
| 29 |
| 30 base::WeakPtr<BrowserPluginBindings> message_channel; |
| 31 }; |
| 32 |
| 33 explicit BrowserPluginBindings(BrowserPlugin* instance); |
| 34 ~BrowserPluginBindings(); |
| 35 |
| 36 NPObject* np_object() const { return np_object_; } |
| 37 |
| 38 BrowserPlugin* instance() const { return instance_; } |
| 39 private: |
| 40 BrowserPlugin* instance_; |
| 41 // The NPObject we use to expose postMessage to JavaScript. |
| 42 BrowserPluginNPObject* np_object_; |
| 43 |
| 44 // This is used to ensure pending tasks will not fire after this object is |
| 45 // destroyed. |
| 46 base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings); |
| 49 }; |
| 50 |
| 51 } // namespace content |
| 52 |
| 53 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__ |
OLD | NEW |