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 | |
110 // Returns a string description of the type of context this is. | 106 // Returns a string description of the type of context this is. |
111 std::string GetContextTypeDescription(); | 107 std::string GetContextTypeDescription(); |
112 | 108 |
113 // RequestSender::Source implementation. | 109 // RequestSender::Source implementation. |
114 virtual ChromeV8Context* GetContext() OVERRIDE; | 110 virtual ChromeV8Context* GetContext() OVERRIDE; |
115 virtual void OnResponseReceived(const std::string& name, | 111 virtual void OnResponseReceived(const std::string& name, |
116 int request_id, | 112 int request_id, |
117 bool success, | 113 bool success, |
118 const base::ListValue& response, | 114 const base::ListValue& response, |
119 const std::string& error) OVERRIDE; | 115 const std::string& error) OVERRIDE; |
120 | 116 |
121 private: | 117 private: |
122 Feature::Availability GetAvailabilityInternal(const std::string& api_name, | |
123 const Extension* extension); | |
124 | |
125 // The v8 context the bindings are accessible to. | 118 // The v8 context the bindings are accessible to. |
126 ScopedPersistent<v8::Context> v8_context_; | 119 ScopedPersistent<v8::Context> v8_context_; |
127 | 120 |
128 // The WebFrame associated with this context. This can be NULL because this | 121 // The WebFrame associated with this context. This can be NULL because this |
129 // object can outlive is destroyed asynchronously. | 122 // object can outlive is destroyed asynchronously. |
130 WebKit::WebFrame* web_frame_; | 123 WebKit::WebFrame* web_frame_; |
131 | 124 |
132 // The extension associated with this context, or NULL if there is none. This | 125 // The extension associated with this context, or NULL if there is none. This |
133 // might be a hosted app in the case that this context is hosting a web URL. | 126 // might be a hosted app in the case that this context is hosting a web URL. |
134 scoped_refptr<const Extension> extension_; | 127 scoped_refptr<const Extension> extension_; |
135 | 128 |
136 // The type of context. | 129 // The type of context. |
137 Feature::Context context_type_; | 130 Feature::Context context_type_; |
138 | 131 |
139 // Owns and structures the JS that is injected to set up extension bindings. | 132 // Owns and structures the JS that is injected to set up extension bindings. |
140 scoped_ptr<ModuleSystem> module_system_; | 133 scoped_ptr<ModuleSystem> module_system_; |
141 | 134 |
142 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 135 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
143 }; | 136 }; |
144 | 137 |
145 } // namespace extensions | 138 } // namespace extensions |
146 | 139 |
147 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 140 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
OLD | NEW |