| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 bool CallChromeHiddenMethod( | 92 bool CallChromeHiddenMethod( |
| 93 const std::string& function_name, | 93 const std::string& function_name, |
| 94 int argc, | 94 int argc, |
| 95 v8::Handle<v8::Value>* argv, | 95 v8::Handle<v8::Value>* argv, |
| 96 v8::Handle<v8::Value>* result) const; | 96 v8::Handle<v8::Value>* result) const; |
| 97 | 97 |
| 98 // Returns the set of extension APIs that are available to this context. If no | 98 // Returns the set of extension APIs that are available to this context. If no |
| 99 // APIs are available, returns an empty set. | 99 // APIs are available, returns an empty set. |
| 100 const std::set<std::string>& GetAvailableExtensionAPIs(); | 100 const std::set<std::string>& GetAvailableExtensionAPIs(); |
| 101 | 101 |
| 102 // Returns a string description of the type of context this is. |
| 103 std::string GetContextTypeDescription(); |
| 104 |
| 102 private: | 105 private: |
| 103 // The v8 context the bindings are accessible to. We keep a strong reference | 106 // The v8 context the bindings are accessible to. We keep a strong reference |
| 104 // to it for simplicity. In the case of content scripts, this is necessary | 107 // to it for simplicity. In the case of content scripts, this is necessary |
| 105 // because we want all scripts from the same extension for the same frame to | 108 // because we want all scripts from the same extension for the same frame to |
| 106 // run in the same context, so we can't have the contexts being GC'd if | 109 // run in the same context, so we can't have the contexts being GC'd if |
| 107 // nothing is happening. In the case of page contexts, this isn't necessary | 110 // nothing is happening. In the case of page contexts, this isn't necessary |
| 108 // since the DOM keeps the context alive, but it makes things simpler to not | 111 // since the DOM keeps the context alive, but it makes things simpler to not |
| 109 // distinguish the two cases. | 112 // distinguish the two cases. |
| 110 v8::Persistent<v8::Context> v8_context_; | 113 v8::Persistent<v8::Context> v8_context_; |
| 111 | 114 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 // Owns and structures the JS that is injected to set up extension bindings. | 126 // Owns and structures the JS that is injected to set up extension bindings. |
| 124 scoped_ptr<ModuleSystem> module_system_; | 127 scoped_ptr<ModuleSystem> module_system_; |
| 125 | 128 |
| 126 // The extension APIs available to this context. | 129 // The extension APIs available to this context. |
| 127 scoped_ptr<std::set<std::string> > available_extension_apis_; | 130 scoped_ptr<std::set<std::string> > available_extension_apis_; |
| 128 | 131 |
| 129 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 132 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
| 130 }; | 133 }; |
| 131 | 134 |
| 132 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 135 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
| OLD | NEW |