Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4143)

Unified Diff: chrome/common/extensions/chrome_extensions_client.cc

Issue 293943002: Clean up TestFeaturesNativeHandler to use the ExtensionsClient's JSON feature sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/chrome_extensions_client.h ('k') | extensions/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/chrome_extensions_client.cc
diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc
index b1cf2ebbaca9e2dfdfaef8ef5f49faafc6c09ea7..7e0f0eb4ac6f3f12c03baa43803118c87407f1ed 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(
« no previous file with comments | « chrome/common/extensions/chrome_extensions_client.h ('k') | extensions/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698