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_MODULE_SYSTEM_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ |
7 | 7 |
vabr (Chromium)
2013/01/23 12:32:56
Lint: add #include for vector<>.
Jeffrey Yasskin
2013/01/23 22:13:17
Done.
| |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/renderer/extensions/native_handler.h" | 11 #include "chrome/renderer/extensions/native_handler.h" |
12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 | 17 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 void Require(const std::string& module_name); | 74 void Require(const std::string& module_name); |
75 v8::Handle<v8::Value> Require(const v8::Arguments& args); | 75 v8::Handle<v8::Value> Require(const v8::Arguments& args); |
76 v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); | 76 v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); |
77 v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); | 77 v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); |
78 | 78 |
79 // Calls the specified method exported by the specified module. This is | 79 // Calls the specified method exported by the specified module. This is |
80 // equivalent to calling require('module_name').method_name() from JS. | 80 // equivalent to calling require('module_name').method_name() from JS. |
81 void CallModuleMethod(const std::string& module_name, | 81 void CallModuleMethod(const std::string& module_name, |
82 const std::string& method_name); | 82 const std::string& method_name); |
83 | 83 |
84 // Calls the specified method exported by the specified module. This is | |
85 // equivalent to calling require('module_name').method_name(args) from JS. | |
86 v8::Local<v8::Value> CallModuleMethod( | |
87 const std::string& module_name, | |
88 const std::string& method_name, | |
89 std::vector<v8::Handle<v8::Value> >* args); | |
90 | |
84 // Register |native_handler| as a potential target for requireNative(), so | 91 // Register |native_handler| as a potential target for requireNative(), so |
85 // calls to requireNative(|name|) from JS will return a new object created by | 92 // calls to requireNative(|name|) from JS will return a new object created by |
86 // |native_handler|. | 93 // |native_handler|. |
87 void RegisterNativeHandler(const std::string& name, | 94 void RegisterNativeHandler(const std::string& name, |
88 scoped_ptr<NativeHandler> native_handler); | 95 scoped_ptr<NativeHandler> native_handler); |
89 | 96 |
90 // Causes requireNative(|name|) to look for its module in |source_map_| | 97 // Causes requireNative(|name|) to look for its module in |source_map_| |
91 // instead of using a registered native handler. This can be used in unit | 98 // instead of using a registered native handler. This can be used in unit |
92 // tests to mock out native modules. | 99 // tests to mock out native modules. |
93 void OverrideNativeHandler(const std::string& name); | 100 void OverrideNativeHandler(const std::string& name); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 scoped_ptr<ExceptionHandler> exception_handler_; | 164 scoped_ptr<ExceptionHandler> exception_handler_; |
158 | 165 |
159 std::set<std::string> overridden_native_handlers_; | 166 std::set<std::string> overridden_native_handlers_; |
160 | 167 |
161 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); | 168 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); |
162 }; | 169 }; |
163 | 170 |
164 } // extensions | 171 } // extensions |
165 | 172 |
166 #endif // CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ | 173 #endif // CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ |
OLD | NEW |