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 |
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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Dumps the debug info from |try_catch| to LOG(ERROR). | 62 // Dumps the debug info from |try_catch| to LOG(ERROR). |
63 static void DumpException(const v8::TryCatch& try_catch); | 63 static void DumpException(const v8::TryCatch& try_catch); |
64 | 64 |
65 // Require the specified module. This is the equivalent of calling | 65 // Require the specified module. This is the equivalent of calling |
66 // require('module_name') from the loaded JS files. | 66 // require('module_name') from the loaded JS files. |
67 void Require(const std::string& module_name); | 67 void Require(const std::string& module_name); |
68 v8::Handle<v8::Value> Require(const v8::Arguments& args); | 68 v8::Handle<v8::Value> Require(const v8::Arguments& args); |
69 v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); | 69 v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); |
70 v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); | 70 v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); |
71 | 71 |
| 72 // Calls the specified method exported by the specified module. This is |
| 73 // equivalent to calling require('module_name').method_name() from JS. |
| 74 void CallModuleMethod(const std::string& module_name, |
| 75 const std::string& method_name); |
| 76 |
72 // Register |native_handler| as a potential target for requireNative(), so | 77 // Register |native_handler| as a potential target for requireNative(), so |
73 // calls to requireNative(|name|) from JS will return a new object created by | 78 // calls to requireNative(|name|) from JS will return a new object created by |
74 // |native_handler|. | 79 // |native_handler|. |
75 void RegisterNativeHandler(const std::string& name, | 80 void RegisterNativeHandler(const std::string& name, |
76 scoped_ptr<NativeHandler> native_handler); | 81 scoped_ptr<NativeHandler> native_handler); |
77 | 82 |
78 // Causes requireNative(|name|) to look for its module in |source_map_| | 83 // Causes requireNative(|name|) to look for its module in |source_map_| |
79 // instead of using a registered native handler. This can be used in unit | 84 // instead of using a registered native handler. This can be used in unit |
80 // tests to mock out native modules. | 85 // tests to mock out native modules. |
81 void OverrideNativeHandler(const std::string& name); | 86 void OverrideNativeHandler(const std::string& name); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 int natives_enabled_; | 140 int natives_enabled_; |
136 | 141 |
137 std::set<std::string> overridden_native_handlers_; | 142 std::set<std::string> overridden_native_handlers_; |
138 | 143 |
139 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); | 144 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); |
140 }; | 145 }; |
141 | 146 |
142 } // extensions | 147 } // extensions |
143 | 148 |
144 #endif // CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ | 149 #endif // CHROME_RENDERER_EXTENSIONS_MODULE_SYSTEM_H_ |
OLD | NEW |