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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "chrome/common/extensions/feature.h" | 12 #include "chrome/common/extensions/feature.h" |
13 #include "chrome/renderer/module_system.h" | 13 #include "chrome/renderer/module_system.h" |
14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
15 | 15 |
16 namespace WebKit { | 16 namespace WebKit { |
17 class WebFrame; | 17 class WebFrame; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class RenderView; | 21 class RenderView; |
22 } | 22 } |
23 | 23 |
| 24 namespace extensions { |
| 25 class Extension; |
| 26 } |
| 27 |
24 // Chrome's wrapper for a v8 context. | 28 // Chrome's wrapper for a v8 context. |
25 // | 29 // |
26 // TODO(aa): Consider converting this back to a set of bindings_utils. It would | 30 // TODO(aa): Consider converting this back to a set of bindings_utils. It would |
27 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then | 31 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then |
28 // we won't need this object and it's a bit less state to keep track of. | 32 // we won't need this object and it's a bit less state to keep track of. |
29 class ChromeV8Context { | 33 class ChromeV8Context { |
30 public: | 34 public: |
31 ChromeV8Context(v8::Handle<v8::Context> context, | 35 ChromeV8Context(v8::Handle<v8::Context> context, |
32 WebKit::WebFrame* frame, | 36 WebKit::WebFrame* frame, |
33 const Extension* extension, | 37 const extensions::Extension* extension, |
34 extensions::Feature::Context context_type); | 38 extensions::Feature::Context context_type); |
35 ~ChromeV8Context(); | 39 ~ChromeV8Context(); |
36 | 40 |
37 v8::Handle<v8::Context> v8_context() const { | 41 v8::Handle<v8::Context> v8_context() const { |
38 return v8_context_; | 42 return v8_context_; |
39 } | 43 } |
40 | 44 |
41 const Extension* extension() const { | 45 const extensions::Extension* extension() const { |
42 return extension_.get(); | 46 return extension_.get(); |
43 } | 47 } |
44 | 48 |
45 WebKit::WebFrame* web_frame() const { | 49 WebKit::WebFrame* web_frame() const { |
46 return web_frame_; | 50 return web_frame_; |
47 } | 51 } |
48 void clear_web_frame() { | 52 void clear_web_frame() { |
49 web_frame_ = NULL; | 53 web_frame_ = NULL; |
50 } | 54 } |
51 | 55 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // 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 |
108 // distinguish the two cases. | 112 // distinguish the two cases. |
109 v8::Persistent<v8::Context> v8_context_; | 113 v8::Persistent<v8::Context> v8_context_; |
110 | 114 |
111 // The WebFrame associated with this context. This can be NULL because this | 115 // The WebFrame associated with this context. This can be NULL because this |
112 // object can outlive is destroyed asynchronously. | 116 // object can outlive is destroyed asynchronously. |
113 WebKit::WebFrame* web_frame_; | 117 WebKit::WebFrame* web_frame_; |
114 | 118 |
115 // The extension associated with this context, or NULL if there is none. This | 119 // The extension associated with this context, or NULL if there is none. This |
116 // might be a hosted app in the case that this context is hosting a web URL. | 120 // might be a hosted app in the case that this context is hosting a web URL. |
117 scoped_refptr<const Extension> extension_; | 121 scoped_refptr<const extensions::Extension> extension_; |
118 | 122 |
119 // The type of context. | 123 // The type of context. |
120 extensions::Feature::Context context_type_; | 124 extensions::Feature::Context context_type_; |
121 | 125 |
122 // 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. |
123 scoped_ptr<ModuleSystem> module_system_; | 127 scoped_ptr<ModuleSystem> module_system_; |
124 | 128 |
125 // The extension APIs available to this context. | 129 // The extension APIs available to this context. |
126 scoped_ptr<std::set<std::string> > available_extension_apis_; | 130 scoped_ptr<std::set<std::string> > available_extension_apis_; |
127 | 131 |
128 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 132 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
129 }; | 133 }; |
130 | 134 |
131 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 135 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
OLD | NEW |