Clean up TestFeaturesNativeHandler to use the ExtensionsClient's JSON feature sources.

This makes TestFeaturesNativeHandler less Chrome-specific.
Also add more const to FeatureProvider.

Remove common_resources.h from extensions DEPS.

BUG=368334
[email protected]

Review URL: https://codereview.chromium.org/293943002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272097 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/extensions/renderer/api_definitions_natives.cc b/extensions/renderer/api_definitions_natives.cc
index c0dc699..61ea7109 100644
--- a/extensions/renderer/api_definitions_natives.cc
+++ b/extensions/renderer/api_definitions_natives.cc
@@ -23,7 +23,7 @@
 void ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest(
     const v8::FunctionCallbackInfo<v8::Value>& args) {
   std::vector<std::string> apis;
-  FeatureProvider* feature_provider = FeatureProvider::GetAPIFeatures();
+  const FeatureProvider* feature_provider = FeatureProvider::GetAPIFeatures();
   const std::vector<std::string>& feature_names =
       feature_provider->GetAllFeatureNames();
   for (std::vector<std::string>::const_iterator i = feature_names.begin();
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index a3014ed..bba20872 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -73,7 +73,6 @@
 #include "extensions/renderer/user_script_slave.h"
 #include "extensions/renderer/utils_native_handler.h"
 #include "extensions/renderer/v8_context_native_handler.h"
-#include "grit/common_resources.h"
 #include "grit/renderer_resources.h"
 #include "third_party/WebKit/public/platform/WebString.h"
 #include "third_party/WebKit/public/platform/WebURLRequest.h"
@@ -867,7 +866,8 @@
     case Feature::CONTENT_SCRIPT_CONTEXT: {
       // Extension context; iterate through all the APIs and bind the available
       // ones.
-      FeatureProvider* api_feature_provider = FeatureProvider::GetAPIFeatures();
+      const FeatureProvider* api_feature_provider =
+          FeatureProvider::GetAPIFeatures();
       const std::vector<std::string>& apis =
           api_feature_provider->GetAllFeatureNames();
       for (std::vector<std::string>::const_iterator it = apis.begin();
@@ -1187,7 +1187,8 @@
   //  If app is available and app.window is not, just install app.
   //  If app.window is available and app is not, delete app and install
   //  app.window on a new object so app does not have to be loaded.
-  FeatureProvider* api_feature_provider = FeatureProvider::GetAPIFeatures();
+  const FeatureProvider* api_feature_provider =
+      FeatureProvider::GetAPIFeatures();
   std::string ancestor_name;
   bool only_ancestor_available = false;
 
diff --git a/extensions/renderer/test_features_native_handler.cc b/extensions/renderer/test_features_native_handler.cc
index 6e0423d..c27575c 100644
--- a/extensions/renderer/test_features_native_handler.cc
+++ b/extensions/renderer/test_features_native_handler.cc
@@ -6,10 +6,9 @@
 
 #include "base/bind.h"
 #include "content/public/renderer/v8_value_converter.h"
+#include "extensions/common/extensions_client.h"
 #include "extensions/common/features/json_feature_provider_source.h"
 #include "extensions/renderer/script_context.h"
-#include "grit/common_resources.h"
-#include "grit/extensions_resources.h"
 
 namespace extensions {
 
@@ -22,15 +21,12 @@
 
 void TestFeaturesNativeHandler::GetAPIFeatures(
     const v8::FunctionCallbackInfo<v8::Value>& args) {
-  JSONFeatureProviderSource source("api");
-  // TODO(rockot): Only inlcude extensions features here. Chrome should add
-  // its own native handler for Chrome features.
-  source.LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES);
-  source.LoadJSON(IDR_EXTENSION_API_FEATURES);
+  scoped_ptr<JSONFeatureProviderSource> source(
+      ExtensionsClient::Get()->CreateFeatureProviderSource("api"));
   scoped_ptr<content::V8ValueConverter> converter(
       content::V8ValueConverter::create());
   args.GetReturnValue().Set(
-      converter->ToV8Value(&source.dictionary(), context()->v8_context()));
+      converter->ToV8Value(&source->dictionary(), context()->v8_context()));
 }
 
 }  // namespace extensions