OLD | NEW |
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 CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 bool CallChromeHiddenMethod( | 93 bool CallChromeHiddenMethod( |
94 const std::string& function_name, | 94 const std::string& function_name, |
95 int argc, | 95 int argc, |
96 v8::Handle<v8::Value>* argv, | 96 v8::Handle<v8::Value>* argv, |
97 v8::Handle<v8::Value>* result) const; | 97 v8::Handle<v8::Value>* result) const; |
98 | 98 |
99 // Returns the set of extension APIs that are available to this context. If no | 99 // Returns the set of extension APIs that are available to this context. If no |
100 // APIs are available, returns an empty set. | 100 // APIs are available, returns an empty set. |
101 const std::set<std::string>& GetAvailableExtensionAPIs(); | 101 const std::set<std::string>& GetAvailableExtensionAPIs(); |
102 | 102 |
| 103 Feature::Availability GetAvailability(const std::string& api_name); |
| 104 |
103 // Returns a string description of the type of context this is. | 105 // Returns a string description of the type of context this is. |
104 std::string GetContextTypeDescription(); | 106 std::string GetContextTypeDescription(); |
105 | 107 |
106 private: | 108 private: |
107 // The v8 context the bindings are accessible to. We keep a strong reference | 109 // The v8 context the bindings are accessible to. We keep a strong reference |
108 // to it for simplicity. In the case of content scripts, this is necessary | 110 // to it for simplicity. In the case of content scripts, this is necessary |
109 // because we want all scripts from the same extension for the same frame to | 111 // because we want all scripts from the same extension for the same frame to |
110 // run in the same context, so we can't have the contexts being GC'd if | 112 // run in the same context, so we can't have the contexts being GC'd if |
111 // nothing is happening. In the case of page contexts, this isn't necessary | 113 // nothing is happening. In the case of page contexts, this isn't necessary |
112 // since the DOM keeps the context alive, but it makes things simpler to not | 114 // since the DOM keeps the context alive, but it makes things simpler to not |
113 // distinguish the two cases. | 115 // distinguish the two cases. |
114 v8::Persistent<v8::Context> v8_context_; | 116 v8::Persistent<v8::Context> v8_context_; |
115 | 117 |
116 // The WebFrame associated with this context. This can be NULL because this | 118 // The WebFrame associated with this context. This can be NULL because this |
117 // object can outlive is destroyed asynchronously. | 119 // object can outlive is destroyed asynchronously. |
118 WebKit::WebFrame* web_frame_; | 120 WebKit::WebFrame* web_frame_; |
119 | 121 |
120 // The extension associated with this context, or NULL if there is none. This | 122 // The extension associated with this context, or NULL if there is none. This |
121 // might be a hosted app in the case that this context is hosting a web URL. | 123 // might be a hosted app in the case that this context is hosting a web URL. |
122 scoped_refptr<const Extension> extension_; | 124 scoped_refptr<const Extension> extension_; |
123 | 125 |
124 // The type of context. | 126 // The type of context. |
125 Feature::Context context_type_; | 127 Feature::Context context_type_; |
126 | 128 |
127 // Owns and structures the JS that is injected to set up extension bindings. | 129 // Owns and structures the JS that is injected to set up extension bindings. |
128 scoped_ptr<ModuleSystem> module_system_; | 130 scoped_ptr<ModuleSystem> module_system_; |
129 | 131 |
130 // The extension APIs available to this context. | 132 // The extension APIs available to this context. |
131 scoped_ptr<std::set<std::string> > available_extension_apis_; | 133 std::set<std::string> available_extension_apis_; |
| 134 bool available_extension_apis_initialized_; |
132 | 135 |
133 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 136 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
134 }; | 137 }; |
135 | 138 |
136 } // namespace extensions | 139 } // namespace extensions |
137 | 140 |
138 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 141 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
OLD | NEW |