summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/chrome_extensions_client.cc
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 04:27:37 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 04:27:37 +0000
commitbc495a181abbd42debc3067b48d3092feec7ccee (patch)
treeb079b740643102b0ebce090b69811cb925c9f2a7 /chrome/common/extensions/chrome_extensions_client.cc
parentf39efb923be05f39f300e2b4aa04afd3d4c0e532 (diff)
downloadchromium_src-bc495a181abbd42debc3067b48d3092feec7ccee.zip
chromium_src-bc495a181abbd42debc3067b48d3092feec7ccee.tar.gz
chromium_src-bc495a181abbd42debc3067b48d3092feec7ccee.tar.bz2
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 TBR=sky@chromium.org Review URL: https://codereview.chromium.org/293943002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/chrome_extensions_client.cc')
-rw-r--r--chrome/common/extensions/chrome_extensions_client.cc46
1 files changed, 32 insertions, 14 deletions
diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc
index b1cf2eb..7e0f0eb 100644
--- a/chrome/common/extensions/chrome_extensions_client.cc
+++ b/chrome/common/extensions/chrome_extensions_client.cc
@@ -19,6 +19,7 @@
#include "extensions/common/extension.h"
#include "extensions/common/features/api_feature.h"
#include "extensions/common/features/base_feature_provider.h"
+#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/json_feature_provider_source.h"
#include "extensions/common/features/manifest_feature.h"
#include "extensions/common/features/permission_feature.h"
@@ -99,26 +100,43 @@ ChromeExtensionsClient::GetPermissionMessageProvider() const {
scoped_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider(
const std::string& name) const {
- JSONFeatureProviderSource source(name);
+ scoped_ptr<FeatureProvider> provider;
+ scoped_ptr<JSONFeatureProviderSource> source(
+ CreateFeatureProviderSource(name));
if (name == "api") {
- source.LoadJSON(IDR_EXTENSION_API_FEATURES);
- source.LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES);
- return scoped_ptr<FeatureProvider>(new BaseFeatureProvider(
- source.dictionary(), CreateFeature<APIFeature>));
+ provider.reset(new BaseFeatureProvider(source->dictionary(),
+ CreateFeature<APIFeature>));
} else if (name == "manifest") {
- source.LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES);
- source.LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES);
- return scoped_ptr<FeatureProvider>(new BaseFeatureProvider(
- source.dictionary(), CreateFeature<ManifestFeature>));
+ provider.reset(new BaseFeatureProvider(source->dictionary(),
+ CreateFeature<ManifestFeature>));
} else if (name == "permission") {
- source.LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES);
- source.LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES);
- return scoped_ptr<FeatureProvider>(new BaseFeatureProvider(
- source.dictionary(), CreateFeature<PermissionFeature>));
+ provider.reset(new BaseFeatureProvider(source->dictionary(),
+ CreateFeature<PermissionFeature>));
} else {
NOTREACHED();
}
- return scoped_ptr<FeatureProvider>();
+ return provider.Pass();
+}
+
+scoped_ptr<JSONFeatureProviderSource>
+ChromeExtensionsClient::CreateFeatureProviderSource(
+ const std::string& name) const {
+ scoped_ptr<JSONFeatureProviderSource> source(
+ new JSONFeatureProviderSource(name));
+ if (name == "api") {
+ source->LoadJSON(IDR_EXTENSION_API_FEATURES);
+ source->LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES);
+ } else if (name == "manifest") {
+ source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES);
+ source->LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES);
+ } else if (name == "permission") {
+ source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES);
+ source->LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES);
+ } else {
+ NOTREACHED();
+ source.reset();
+ }
+ return source.Pass();
}
void ChromeExtensionsClient::FilterHostPermissions(