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