| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 ModuleSystem* module_system_; | 49 ModuleSystem* module_system_; |
| 50 DISALLOW_COPY_AND_ASSIGN(NativesEnabledScope); | 50 DISALLOW_COPY_AND_ASSIGN(NativesEnabledScope); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // |source_map| is a weak pointer. | 53 // |source_map| is a weak pointer. |
| 54 explicit ModuleSystem(v8::Handle<v8::Context> context, SourceMap* source_map); | 54 explicit ModuleSystem(v8::Handle<v8::Context> context, SourceMap* source_map); |
| 55 virtual ~ModuleSystem(); | 55 virtual ~ModuleSystem(); |
| 56 | 56 |
| 57 // Returns true if the current context has a ModuleSystem installed in it. |
| 58 static bool IsPresentInCurrentContext(); |
| 59 |
| 57 // Require the specified module. This is the equivalent of calling | 60 // Require the specified module. This is the equivalent of calling |
| 58 // require('module_name') from the loaded JS files. | 61 // require('module_name') from the loaded JS files. |
| 59 void Require(const std::string& module_name); | 62 void Require(const std::string& module_name); |
| 60 v8::Handle<v8::Value> Require(const v8::Arguments& args); | 63 v8::Handle<v8::Value> Require(const v8::Arguments& args); |
| 61 v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); | 64 v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); |
| 62 v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); | 65 v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); |
| 63 | 66 |
| 64 // Register |native_handler| as a potential target for requireNative(), so | 67 // Register |native_handler| as a potential target for requireNative(), so |
| 65 // calls to requireNative(|name|) from JS will return a new object created by | 68 // calls to requireNative(|name|) from JS will return a new object created by |
| 66 // |native_handler|. | 69 // |native_handler|. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 NativeHandlerMap native_handler_map_; | 121 NativeHandlerMap native_handler_map_; |
| 119 | 122 |
| 120 // When 0, natives are disabled, otherwise indicates how many callers have | 123 // When 0, natives are disabled, otherwise indicates how many callers have |
| 121 // pinned natives as enabled. | 124 // pinned natives as enabled. |
| 122 int natives_enabled_; | 125 int natives_enabled_; |
| 123 | 126 |
| 124 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); | 127 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); |
| 125 }; | 128 }; |
| 126 | 129 |
| 127 #endif // CHROME_RENDERER_MODULE_SYSTEM_H_ | 130 #endif // CHROME_RENDERER_MODULE_SYSTEM_H_ |
| OLD | NEW |