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