Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / extensions / renderer / v8_context_native_handler.cc
index 56cd973..09f9c8a 100644 (file)
@@ -22,6 +22,10 @@ V8ContextNativeHandler::V8ContextNativeHandler(ScriptContext* context,
   RouteFunction("GetModuleSystem",
                 base::Bind(&V8ContextNativeHandler::GetModuleSystem,
                            base::Unretained(this)));
+  RouteFunction(
+      "RunWithNativesEnabledModuleSystem",
+      base::Bind(&V8ContextNativeHandler::RunWithNativesEnabledModuleSystem,
+                 base::Unretained(this)));
 }
 
 void V8ContextNativeHandler::GetAvailability(
@@ -52,4 +56,16 @@ void V8ContextNativeHandler::GetModuleSystem(
   args.GetReturnValue().Set(context->module_system()->NewInstance());
 }
 
+void V8ContextNativeHandler::RunWithNativesEnabledModuleSystem(
+    const v8::FunctionCallbackInfo<v8::Value>& args) {
+  CHECK_EQ(args.Length(), 1);
+  CHECK(args[0]->IsFunction());
+  v8::Handle<v8::Value> call_with_args[] = {
+    context()->module_system()->NewInstance()
+  };
+  ModuleSystem::NativesEnabledScope natives_enabled(context()->module_system());
+  context()->CallFunction(
+      v8::Handle<v8::Function>::Cast(args[0]), 1, call_with_args);
+}
+
 }  // namespace extensions