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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Call the named method of the chromeHidden object in this context. | 91 // Call the named method of the chromeHidden object in this context. |
92 // The function can be a sub-property like "Port.dispatchOnMessage". Returns | 92 // The function can be a sub-property like "Port.dispatchOnMessage". Returns |
93 // the result of the function call in |result| if |result| is non-NULL. If the | 93 // the result of the function call in |result| if |result| is non-NULL. If the |
94 // named method does not exist, returns false. | 94 // named method does not exist, returns false. |
95 bool CallChromeHiddenMethod( | 95 bool CallChromeHiddenMethod( |
96 const std::string& function_name, | 96 const std::string& function_name, |
97 int argc, | 97 int argc, |
98 v8::Handle<v8::Value>* argv, | 98 v8::Handle<v8::Value>* argv, |
99 v8::Handle<v8::Value>* result) const; | 99 v8::Handle<v8::Value>* result) const; |
100 | 100 |
101 // Returns the set of extension APIs that are available to this context. If no | 101 // Returns the availability of the API |api_name|. |
102 // APIs are available, returns an empty set. | |
103 const std::set<std::string>& GetAvailableExtensionAPIs(); | |
104 | |
105 Feature::Availability GetAvailability(const std::string& api_name); | 102 Feature::Availability GetAvailability(const std::string& api_name); |
106 | 103 |
107 // Returns a string description of the type of context this is. | 104 // Returns a string description of the type of context this is. |
108 std::string GetContextTypeDescription(); | 105 std::string GetContextTypeDescription(); |
109 | 106 |
110 private: | 107 private: |
111 // The v8 context the bindings are accessible to. | 108 // The v8 context the bindings are accessible to. |
112 ScopedPersistent<v8::Context> v8_context_; | 109 ScopedPersistent<v8::Context> v8_context_; |
113 | 110 |
114 // The WebFrame associated with this context. This can be NULL because this | 111 // The WebFrame associated with this context. This can be NULL because this |
115 // object can outlive is destroyed asynchronously. | 112 // object can outlive is destroyed asynchronously. |
116 WebKit::WebFrame* web_frame_; | 113 WebKit::WebFrame* web_frame_; |
117 | 114 |
118 // The extension associated with this context, or NULL if there is none. This | 115 // The extension associated with this context, or NULL if there is none. This |
119 // might be a hosted app in the case that this context is hosting a web URL. | 116 // might be a hosted app in the case that this context is hosting a web URL. |
120 scoped_refptr<const Extension> extension_; | 117 scoped_refptr<const Extension> extension_; |
121 | 118 |
122 // The type of context. | 119 // The type of context. |
123 Feature::Context context_type_; | 120 Feature::Context context_type_; |
124 | 121 |
125 // Owns and structures the JS that is injected to set up extension bindings. | 122 // Owns and structures the JS that is injected to set up extension bindings. |
126 scoped_ptr<ModuleSystem> module_system_; | 123 scoped_ptr<ModuleSystem> module_system_; |
127 | 124 |
128 // The extension APIs available to this context. | |
129 std::set<std::string> available_extension_apis_; | |
130 bool available_extension_apis_initialized_; | |
131 | |
132 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 125 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
133 }; | 126 }; |
134 | 127 |
135 } // namespace extensions | 128 } // namespace extensions |
136 | 129 |
137 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 130 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
OLD | NEW |