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/test_features_native_handler.h" | 5 #include "extensions/renderer/test_features_native_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/public/renderer/v8_value_converter.h" | 8 #include "content/public/renderer/v8_value_converter.h" |
| 9 #include "extensions/common/extensions_client.h" |
9 #include "extensions/common/features/json_feature_provider_source.h" | 10 #include "extensions/common/features/json_feature_provider_source.h" |
10 #include "extensions/renderer/script_context.h" | 11 #include "extensions/renderer/script_context.h" |
11 #include "grit/common_resources.h" | |
12 #include "grit/extensions_resources.h" | |
13 | 12 |
14 namespace extensions { | 13 namespace extensions { |
15 | 14 |
16 TestFeaturesNativeHandler::TestFeaturesNativeHandler(ScriptContext* context) | 15 TestFeaturesNativeHandler::TestFeaturesNativeHandler(ScriptContext* context) |
17 : ObjectBackedNativeHandler(context) { | 16 : ObjectBackedNativeHandler(context) { |
18 RouteFunction("GetAPIFeatures", | 17 RouteFunction("GetAPIFeatures", |
19 base::Bind(&TestFeaturesNativeHandler::GetAPIFeatures, | 18 base::Bind(&TestFeaturesNativeHandler::GetAPIFeatures, |
20 base::Unretained(this))); | 19 base::Unretained(this))); |
21 } | 20 } |
22 | 21 |
23 void TestFeaturesNativeHandler::GetAPIFeatures( | 22 void TestFeaturesNativeHandler::GetAPIFeatures( |
24 const v8::FunctionCallbackInfo<v8::Value>& args) { | 23 const v8::FunctionCallbackInfo<v8::Value>& args) { |
25 JSONFeatureProviderSource source("api"); | 24 scoped_ptr<JSONFeatureProviderSource> source( |
26 // TODO(rockot): Only inlcude extensions features here. Chrome should add | 25 ExtensionsClient::Get()->CreateFeatureProviderSource("api")); |
27 // its own native handler for Chrome features. | |
28 source.LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); | |
29 source.LoadJSON(IDR_EXTENSION_API_FEATURES); | |
30 scoped_ptr<content::V8ValueConverter> converter( | 26 scoped_ptr<content::V8ValueConverter> converter( |
31 content::V8ValueConverter::create()); | 27 content::V8ValueConverter::create()); |
32 args.GetReturnValue().Set( | 28 args.GetReturnValue().Set( |
33 converter->ToV8Value(&source.dictionary(), context()->v8_context())); | 29 converter->ToV8Value(&source->dictionary(), context()->v8_context())); |
34 } | 30 } |
35 | 31 |
36 } // namespace extensions | 32 } // namespace extensions |
OLD | NEW |