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/renderer/module_system.h" | |
12 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
13 | 14 |
14 namespace WebKit { | 15 namespace WebKit { |
15 class WebFrame; | 16 class WebFrame; |
16 } | 17 } |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class RenderView; | 20 class RenderView; |
20 } | 21 } |
21 | 22 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 // Call the named method of the chromeHidden object in this context. | 87 // Call the named method of the chromeHidden object in this context. |
87 // The function can be a sub-property like "Port.dispatchOnMessage". Returns | 88 // The function can be a sub-property like "Port.dispatchOnMessage". Returns |
88 // the result of the function call in |result| if |result| is non-NULL. If the | 89 // the result of the function call in |result| if |result| is non-NULL. If the |
89 // named method does not exist, returns false. | 90 // named method does not exist, returns false. |
90 bool CallChromeHiddenMethod( | 91 bool CallChromeHiddenMethod( |
91 const std::string& function_name, | 92 const std::string& function_name, |
92 int argc, | 93 int argc, |
93 v8::Handle<v8::Value>* argv, | 94 v8::Handle<v8::Value>* argv, |
94 v8::Handle<v8::Value>* result) const; | 95 v8::Handle<v8::Value>* result) const; |
95 | 96 |
97 void set_module_system(scoped_ptr<ModuleSystem> module_system) { | |
Aaron Boodman
2012/02/28 02:42:59
Should go up higher w/ other setters.
koz (OOO until 15th September)
2012/03/01 03:41:56
Done.
| |
98 module_system_ = module_system.Pass(); | |
99 } | |
100 | |
96 private: | 101 private: |
97 // The v8 context the bindings are accessible to. We keep a strong reference | 102 // The v8 context the bindings are accessible to. We keep a strong reference |
98 // to it for simplicity. In the case of content scripts, this is necessary | 103 // to it for simplicity. In the case of content scripts, this is necessary |
99 // because we want all scripts from the same extension for the same frame to | 104 // because we want all scripts from the same extension for the same frame to |
100 // run in the same context, so we can't have the contexts being GC'd if | 105 // run in the same context, so we can't have the contexts being GC'd if |
101 // nothing is happening. In the case of page contexts, this isn't necessary | 106 // nothing is happening. In the case of page contexts, this isn't necessary |
102 // since the DOM keeps the context alive, but it makes things simpler to not | 107 // since the DOM keeps the context alive, but it makes things simpler to not |
103 // distinguish the two cases. | 108 // distinguish the two cases. |
104 v8::Persistent<v8::Context> v8_context_; | 109 v8::Persistent<v8::Context> v8_context_; |
105 | 110 |
106 // The WebFrame associated with this context. This can be NULL because this | 111 // The WebFrame associated with this context. This can be NULL because this |
107 // object can outlive is destroyed asynchronously. | 112 // object can outlive is destroyed asynchronously. |
108 WebKit::WebFrame* web_frame_; | 113 WebKit::WebFrame* web_frame_; |
109 | 114 |
110 // The extension ID this context is associated with. | 115 // The extension ID this context is associated with. |
111 std::string extension_id_; | 116 std::string extension_id_; |
112 | 117 |
113 // The type of context. | 118 // The type of context. |
114 ContextType context_type_; | 119 ContextType context_type_; |
115 | 120 |
121 // Owns and structures the JS that is injected to set up extension bindings. | |
122 scoped_ptr<ModuleSystem> module_system_; | |
123 | |
116 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 124 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
117 }; | 125 }; |
118 | 126 |
119 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 127 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
OLD | NEW |