[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "extensions/renderer/test_features_native_handler.h" |
| 6 | |
| 7 | #include "base/bind.h" |
| 8 | #include "content/public/renderer/v8_value_converter.h" |
[email protected] | bc495a18 | 2014-05-22 04:27:37 | [diff] [blame] | 9 | #include "extensions/common/extensions_client.h" |
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame] | 10 | #include "extensions/common/features/json_feature_provider_source.h" |
| 11 | #include "extensions/renderer/script_context.h" |
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame] | 12 | |
| 13 | namespace extensions { |
| 14 | |
| 15 | TestFeaturesNativeHandler::TestFeaturesNativeHandler(ScriptContext* context) |
| 16 | : ObjectBackedNativeHandler(context) { |
| 17 | RouteFunction("GetAPIFeatures", |
| 18 | base::Bind(&TestFeaturesNativeHandler::GetAPIFeatures, |
| 19 | base::Unretained(this))); |
| 20 | } |
| 21 | |
| 22 | void TestFeaturesNativeHandler::GetAPIFeatures( |
| 23 | const v8::FunctionCallbackInfo<v8::Value>& args) { |
[email protected] | bc495a18 | 2014-05-22 04:27:37 | [diff] [blame] | 24 | scoped_ptr<JSONFeatureProviderSource> source( |
| 25 | ExtensionsClient::Get()->CreateFeatureProviderSource("api")); |
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame] | 26 | scoped_ptr<content::V8ValueConverter> converter( |
| 27 | content::V8ValueConverter::create()); |
| 28 | args.GetReturnValue().Set( |
[email protected] | bc495a18 | 2014-05-22 04:27:37 | [diff] [blame] | 29 | converter->ToV8Value(&source->dictionary(), context()->v8_context())); |
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | } // namespace extensions |