OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/linked_ptr.h" | 9 #include "base/linked_ptr.h" |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Contains information about a single javascript context. | 59 // Contains information about a single javascript context. |
60 struct ContextInfo { | 60 struct ContextInfo { |
61 v8::Persistent<v8::Context> context; | 61 v8::Persistent<v8::Context> context; |
62 std::string extension_id; // empty if the context is not an extension | 62 std::string extension_id; // empty if the context is not an extension |
63 | 63 |
64 // If this context is a content script, parent will be the frame that it | 64 // If this context is a content script, parent will be the frame that it |
65 // was injected in. This is empty if the context is not a content script. | 65 // was injected in. This is empty if the context is not a content script. |
66 v8::Persistent<v8::Context> parent_context; | 66 v8::Persistent<v8::Context> parent_context; |
67 | 67 |
| 68 // The RenderView that this context belongs to. This is not guaranteed to be |
| 69 // a valid pointer, and is used for comparisons only. Do not dereference. |
| 70 RenderView* render_view; |
| 71 |
68 ContextInfo(v8::Persistent<v8::Context> context, | 72 ContextInfo(v8::Persistent<v8::Context> context, |
69 const std::string& extension_id, | 73 const std::string& extension_id, |
70 v8::Persistent<v8::Context> parent_context) | 74 v8::Persistent<v8::Context> parent_context, |
| 75 RenderView* render_view) |
71 : context(context), extension_id(extension_id), | 76 : context(context), extension_id(extension_id), |
72 parent_context(parent_context) {} | 77 parent_context(parent_context), render_view(render_view) {} |
73 }; | 78 }; |
74 typedef std::list< linked_ptr<ContextInfo> > ContextList; | 79 typedef std::list< linked_ptr<ContextInfo> > ContextList; |
75 | 80 |
76 // Returns a mutable reference to the ContextList. | 81 // Returns a mutable reference to the ContextList. |
77 ContextList& GetContexts(); | 82 ContextList& GetContexts(); |
78 | 83 |
79 // Returns a (copied) list of contexts that have the given extension_id. | 84 // Returns a (copied) list of contexts that have the given extension_id. |
80 ContextList GetContextsForExtension(const std::string& extension_id); | 85 ContextList GetContextsForExtension(const std::string& extension_id); |
81 | 86 |
82 // Returns the ContextInfo item that has the given context. | 87 // Returns the ContextInfo item that has the given context. |
(...skipping 20 matching lines...) Expand all Loading... |
103 // Call the named javascript function with the given arguments in a context. | 108 // Call the named javascript function with the given arguments in a context. |
104 // The function name should be reachable from the chromeHidden object, and can | 109 // The function name should be reachable from the chromeHidden object, and can |
105 // be a sub-property like "Port.dispatchOnMessage". | 110 // be a sub-property like "Port.dispatchOnMessage". |
106 void CallFunctionInContext(v8::Handle<v8::Context> context, | 111 void CallFunctionInContext(v8::Handle<v8::Context> context, |
107 const std::string& function_name, int argc, | 112 const std::string& function_name, int argc, |
108 v8::Handle<v8::Value>* argv); | 113 v8::Handle<v8::Value>* argv); |
109 | 114 |
110 } // namespace bindings_utils | 115 } // namespace bindings_utils |
111 | 116 |
112 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ | 117 #endif // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_ |
OLD | NEW |