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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // named method does not exist, returns false. | 96 // named method does not exist, returns false. |
97 bool CallChromeHiddenMethod( | 97 bool CallChromeHiddenMethod( |
98 const std::string& function_name, | 98 const std::string& function_name, |
99 int argc, | 99 int argc, |
100 v8::Handle<v8::Value>* argv, | 100 v8::Handle<v8::Value>* argv, |
101 v8::Handle<v8::Value>* result) const; | 101 v8::Handle<v8::Value>* result) const; |
102 | 102 |
103 // Returns the availability of the API |api_name|. | 103 // Returns the availability of the API |api_name|. |
104 Feature::Availability GetAvailability(const std::string& api_name); | 104 Feature::Availability GetAvailability(const std::string& api_name); |
105 | 105 |
| 106 // Returns the availability of the API |api_name| without taking into account |
| 107 // the context's extension. |
| 108 Feature::Availability GetAvailabilityForContext(const std::string& api_name); |
| 109 |
106 // Returns a string description of the type of context this is. | 110 // Returns a string description of the type of context this is. |
107 std::string GetContextTypeDescription(); | 111 std::string GetContextTypeDescription(); |
108 | 112 |
109 // RequestSender::Source implementation. | 113 // RequestSender::Source implementation. |
110 virtual ChromeV8Context* GetContext() OVERRIDE; | 114 virtual ChromeV8Context* GetContext() OVERRIDE; |
111 virtual void OnResponseReceived(const std::string& name, | 115 virtual void OnResponseReceived(const std::string& name, |
112 int request_id, | 116 int request_id, |
113 bool success, | 117 bool success, |
114 const base::ListValue& response, | 118 const base::ListValue& response, |
115 const std::string& error) OVERRIDE; | 119 const std::string& error) OVERRIDE; |
116 | 120 |
117 private: | 121 private: |
| 122 Feature::Availability GetAvailabilityInternal(const std::string& api_name, |
| 123 const Extension* extension); |
| 124 |
118 // The v8 context the bindings are accessible to. | 125 // The v8 context the bindings are accessible to. |
119 ScopedPersistent<v8::Context> v8_context_; | 126 ScopedPersistent<v8::Context> v8_context_; |
120 | 127 |
121 // The WebFrame associated with this context. This can be NULL because this | 128 // The WebFrame associated with this context. This can be NULL because this |
122 // object can outlive is destroyed asynchronously. | 129 // object can outlive is destroyed asynchronously. |
123 WebKit::WebFrame* web_frame_; | 130 WebKit::WebFrame* web_frame_; |
124 | 131 |
125 // The extension associated with this context, or NULL if there is none. This | 132 // The extension associated with this context, or NULL if there is none. This |
126 // might be a hosted app in the case that this context is hosting a web URL. | 133 // might be a hosted app in the case that this context is hosting a web URL. |
127 scoped_refptr<const Extension> extension_; | 134 scoped_refptr<const Extension> extension_; |
128 | 135 |
129 // The type of context. | 136 // The type of context. |
130 Feature::Context context_type_; | 137 Feature::Context context_type_; |
131 | 138 |
132 // Owns and structures the JS that is injected to set up extension bindings. | 139 // Owns and structures the JS that is injected to set up extension bindings. |
133 scoped_ptr<ModuleSystem> module_system_; | 140 scoped_ptr<ModuleSystem> module_system_; |
134 | 141 |
135 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 142 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
136 }; | 143 }; |
137 | 144 |
138 } // namespace extensions | 145 } // namespace extensions |
139 | 146 |
140 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 147 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
OLD | NEW |