| 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/dispatcher.h" | 9 #include "extensions/renderer/dispatcher.h" |
| 10 #include "extensions/renderer/script_context.h" | 10 #include "extensions/renderer/script_context.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 RouteFunction( | 25 RouteFunction( |
| 26 "RunWithNativesEnabledModuleSystem", | 26 "RunWithNativesEnabledModuleSystem", |
| 27 base::Bind(&V8ContextNativeHandler::RunWithNativesEnabledModuleSystem, | 27 base::Bind(&V8ContextNativeHandler::RunWithNativesEnabledModuleSystem, |
| 28 base::Unretained(this))); | 28 base::Unretained(this))); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void V8ContextNativeHandler::GetAvailability( | 31 void V8ContextNativeHandler::GetAvailability( |
| 32 const v8::FunctionCallbackInfo<v8::Value>& args) { | 32 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 33 CHECK_EQ(args.Length(), 1); | 33 CHECK_EQ(args.Length(), 1); |
| 34 v8::Isolate* isolate = args.GetIsolate(); | 34 v8::Isolate* isolate = args.GetIsolate(); |
| 35 std::string api_name = *v8::String::Utf8Value(args[0]->ToString()); | 35 std::string api_name = *v8::String::Utf8Value(args[0]); |
| 36 Feature::Availability availability = context_->GetAvailability(api_name); | 36 Feature::Availability availability = context_->GetAvailability(api_name); |
| 37 | 37 |
| 38 v8::Handle<v8::Object> ret = v8::Object::New(isolate); | 38 v8::Handle<v8::Object> ret = v8::Object::New(isolate); |
| 39 ret->Set(v8::String::NewFromUtf8(isolate, "is_available"), | 39 ret->Set(v8::String::NewFromUtf8(isolate, "is_available"), |
| 40 v8::Boolean::New(isolate, availability.is_available())); | 40 v8::Boolean::New(isolate, availability.is_available())); |
| 41 ret->Set(v8::String::NewFromUtf8(isolate, "message"), | 41 ret->Set(v8::String::NewFromUtf8(isolate, "message"), |
| 42 v8::String::NewFromUtf8(isolate, availability.message().c_str())); | 42 v8::String::NewFromUtf8(isolate, availability.message().c_str())); |
| 43 ret->Set(v8::String::NewFromUtf8(isolate, "result"), | 43 ret->Set(v8::String::NewFromUtf8(isolate, "result"), |
| 44 v8::Integer::New(isolate, availability.result())); | 44 v8::Integer::New(isolate, availability.result())); |
| 45 args.GetReturnValue().Set(ret); | 45 args.GetReturnValue().Set(ret); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 CHECK(args[0]->IsFunction()); | 62 CHECK(args[0]->IsFunction()); |
| 63 v8::Handle<v8::Value> call_with_args[] = { | 63 v8::Handle<v8::Value> call_with_args[] = { |
| 64 context()->module_system()->NewInstance() | 64 context()->module_system()->NewInstance() |
| 65 }; | 65 }; |
| 66 ModuleSystem::NativesEnabledScope natives_enabled(context()->module_system()); | 66 ModuleSystem::NativesEnabledScope natives_enabled(context()->module_system()); |
| 67 context()->CallFunction( | 67 context()->CallFunction( |
| 68 v8::Handle<v8::Function>::Cast(args[0]), 1, call_with_args); | 68 v8::Handle<v8::Function>::Cast(args[0]), 1, call_with_args); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace extensions | 71 } // namespace extensions |
| OLD | NEW |