| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "extensions/renderer/v8_context_native_handler.h" | 5 #include "extensions/renderer/v8_context_native_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "extensions/common/features/feature.h" | 8 #include "extensions/common/features/feature.h" |
| 9 #include "extensions/renderer/script_context.h" | 9 #include "extensions/renderer/script_context.h" |
| 10 #include "extensions/renderer/script_context_set.h" | 10 #include "extensions/renderer/script_context_set.h" |
| 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 V8ContextNativeHandler::V8ContextNativeHandler(ScriptContext* context) | 15 V8ContextNativeHandler::V8ContextNativeHandler(ScriptContext* context) |
| 16 : ObjectBackedNativeHandler(context), context_(context) { | 16 : ObjectBackedNativeHandler(context), context_(context) { |
| 17 RouteFunction("GetAvailability", | 17 RouteFunction("GetAvailability", |
| 18 base::Bind(&V8ContextNativeHandler::GetAvailability, | 18 base::Bind(&V8ContextNativeHandler::GetAvailability, |
| 19 base::Unretained(this))); | 19 base::Unretained(this))); |
| 20 RouteFunction("GetModuleSystem", | 20 RouteFunction("GetModuleSystem", |
| 21 base::Bind(&V8ContextNativeHandler::GetModuleSystem, | 21 base::Bind(&V8ContextNativeHandler::GetModuleSystem, |
| 22 base::Unretained(this))); | 22 base::Unretained(this))); |
| 23 RouteFunction( | 23 RouteFunction("RunWithNativesEnabled", "test", |
| 24 "RunWithNativesEnabled", | 24 base::Bind(&V8ContextNativeHandler::RunWithNativesEnabled, |
| 25 base::Bind(&V8ContextNativeHandler::RunWithNativesEnabled, | 25 base::Unretained(this))); |
| 26 base::Unretained(this))); | |
| 27 } | 26 } |
| 28 | 27 |
| 29 void V8ContextNativeHandler::GetAvailability( | 28 void V8ContextNativeHandler::GetAvailability( |
| 30 const v8::FunctionCallbackInfo<v8::Value>& args) { | 29 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 31 CHECK_EQ(args.Length(), 1); | 30 CHECK_EQ(args.Length(), 1); |
| 32 v8::Isolate* isolate = args.GetIsolate(); | 31 v8::Isolate* isolate = args.GetIsolate(); |
| 33 std::string api_name = *v8::String::Utf8Value(args[0]); | 32 std::string api_name = *v8::String::Utf8Value(args[0]); |
| 34 Feature::Availability availability = context_->GetAvailability(api_name); | 33 Feature::Availability availability = context_->GetAvailability(api_name); |
| 35 | 34 |
| 36 v8::Local<v8::Object> ret = v8::Object::New(isolate); | 35 v8::Local<v8::Object> ret = v8::Object::New(isolate); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 55 | 54 |
| 56 void V8ContextNativeHandler::RunWithNativesEnabled( | 55 void V8ContextNativeHandler::RunWithNativesEnabled( |
| 57 const v8::FunctionCallbackInfo<v8::Value>& args) { | 56 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 58 CHECK_EQ(args.Length(), 1); | 57 CHECK_EQ(args.Length(), 1); |
| 59 CHECK(args[0]->IsFunction()); | 58 CHECK(args[0]->IsFunction()); |
| 60 ModuleSystem::NativesEnabledScope natives_enabled(context()->module_system()); | 59 ModuleSystem::NativesEnabledScope natives_enabled(context()->module_system()); |
| 61 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0])); | 60 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0])); |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace extensions | 63 } // namespace extensions |
| OLD | NEW |