| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace bindings_utils { | 23 namespace bindings_utils { |
| 24 | 24 |
| 25 // Contains information about a JavaScript context that is hosting extension | 25 // Contains information about a JavaScript context that is hosting extension |
| 26 // bindings. | 26 // bindings. |
| 27 struct ContextInfo { | 27 struct ContextInfo { |
| 28 ContextInfo(v8::Persistent<v8::Context> context, | 28 ContextInfo(v8::Persistent<v8::Context> context, |
| 29 const std::string& extension_id, | 29 const std::string& extension_id, |
| 30 WebKit::WebFrame* frame); | 30 WebKit::WebFrame* frame); |
| 31 ~ContextInfo(); | 31 ~ContextInfo(); |
| 32 | 32 |
| 33 // Returns the web frame associated with this context. Can also return NULL if | |
| 34 // the context has been disassociated with the frame, and not GC'd yet. | |
| 35 WebKit::WebFrame* GetWebFrame() const; | |
| 36 | |
| 37 // Returns the RenderView associated wit hthis context. Can also return NULL. | |
| 38 RenderView* GetRenderView() const; | |
| 39 | |
| 40 v8::Persistent<v8::Context> context; | 33 v8::Persistent<v8::Context> context; |
| 41 | 34 |
| 42 // The extension ID this context is associated with. | 35 // The extension ID this context is associated with. |
| 43 std::string extension_id; | 36 std::string extension_id; |
| 44 | 37 |
| 45 // The frame the context is associated with. ContextInfo can outlive its | 38 // The frame the context is associated with. ContextInfo can outlive its |
| 46 // frame, so this should not be dereferenced. Use GetWebFrame() instead for | 39 // frame, so this should not be dereferenced. It is stored only for use for |
| 47 // most cases. This is used for comparisons during unload when GetWebFrame() | 40 // comparison. |
| 48 // doesn't work. | |
| 49 void* unsafe_frame; | 41 void* unsafe_frame; |
| 50 | 42 |
| 51 // A count of the number of events that are listening in this context. When | 43 // A count of the number of events that are listening in this context. When |
| 52 // this is zero, |context| will be a weak handle. | 44 // this is zero, |context| will be a weak handle. |
| 53 int num_connected_events; | 45 int num_connected_events; |
| 54 }; | 46 }; |
| 55 typedef std::list< linked_ptr<ContextInfo> > ContextList; | 47 typedef std::list< linked_ptr<ContextInfo> > ContextList; |
| 56 | 48 |
| 57 // Returns a mutable reference to the ContextList. Note: be careful using this. | 49 // Returns a mutable reference to the ContextList. Note: be careful using this. |
| 58 // Calling into javascript may result in the list being modified, so don't rely | 50 // Calling into javascript may result in the list being modified, so don't rely |
| (...skipping 29 matching lines...) Expand all Loading... |
| 88 // be a sub-property like "Port.dispatchOnMessage". Returns the result of | 80 // be a sub-property like "Port.dispatchOnMessage". Returns the result of |
| 89 // the function call. If an exception is thrown an empty Handle will be | 81 // the function call. If an exception is thrown an empty Handle will be |
| 90 // returned. | 82 // returned. |
| 91 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, | 83 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, |
| 92 const std::string& function_name, int argc, | 84 const std::string& function_name, int argc, |
| 93 v8::Handle<v8::Value>* argv); | 85 v8::Handle<v8::Value>* argv); |
| 94 | 86 |
| 95 } // namespace bindings_utils | 87 } // namespace bindings_utils |
| 96 | 88 |
| 97 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 89 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
| OLD | NEW |