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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/common/extensions/chrome_extensions_client.h" 5 #include "chrome/common/extensions/chrome_extensions_client.h"
6 6
7 #include "apps/common/api/generated_schemas.h" 7 #include "apps/common/api/generated_schemas.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/common/chrome_version_info.h" 9 #include "chrome/common/chrome_version_info.h"
10 #include "chrome/common/extensions/api/generated_schemas.h" 10 #include "chrome/common/extensions/api/generated_schemas.h"
11 #include "chrome/common/extensions/chrome_manifest_handlers.h" 11 #include "chrome/common/extensions/chrome_manifest_handlers.h"
12 #include "chrome/common/extensions/extension_constants.h" 12 #include "chrome/common/extensions/extension_constants.h"
13 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h" 13 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h"
14 #include "chrome/common/extensions/features/feature_channel.h" 14 #include "chrome/common/extensions/features/feature_channel.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
17 #include "extensions/common/api/generated_schemas.h" 17 #include "extensions/common/api/generated_schemas.h"
18 #include "extensions/common/common_manifest_handlers.h" 18 #include "extensions/common/common_manifest_handlers.h"
19 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
20 #include "extensions/common/features/api_feature.h" 20 #include "extensions/common/features/api_feature.h"
21 #include "extensions/common/features/base_feature_provider.h" 21 #include "extensions/common/features/base_feature_provider.h"
22 #include "extensions/common/features/feature_provider.h"
22 #include "extensions/common/features/json_feature_provider_source.h" 23 #include "extensions/common/features/json_feature_provider_source.h"
23 #include "extensions/common/features/manifest_feature.h" 24 #include "extensions/common/features/manifest_feature.h"
24 #include "extensions/common/features/permission_feature.h" 25 #include "extensions/common/features/permission_feature.h"
25 #include "extensions/common/features/simple_feature.h" 26 #include "extensions/common/features/simple_feature.h"
26 #include "extensions/common/manifest_constants.h" 27 #include "extensions/common/manifest_constants.h"
27 #include "extensions/common/manifest_handler.h" 28 #include "extensions/common/manifest_handler.h"
28 #include "extensions/common/permissions/api_permission_set.h" 29 #include "extensions/common/permissions/api_permission_set.h"
29 #include "extensions/common/permissions/permission_message.h" 30 #include "extensions/common/permissions/permission_message.h"
30 #include "extensions/common/permissions/permissions_info.h" 31 #include "extensions/common/permissions/permissions_info.h"
31 #include "extensions/common/switches.h" 32 #include "extensions/common/switches.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 scripting_whitelist_.push_back("angkfkebojeancgemegoedelbnjgcgme"); 93 scripting_whitelist_.push_back("angkfkebojeancgemegoedelbnjgcgme");
93 } 94 }
94 95
95 const PermissionMessageProvider& 96 const PermissionMessageProvider&
96 ChromeExtensionsClient::GetPermissionMessageProvider() const { 97 ChromeExtensionsClient::GetPermissionMessageProvider() const {
97 return permission_message_provider_; 98 return permission_message_provider_;
98 } 99 }
99 100
100 scoped_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider( 101 scoped_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider(
101 const std::string& name) const { 102 const std::string& name) const {
102 JSONFeatureProviderSource source(name); 103 scoped_ptr<FeatureProvider> provider;
104 scoped_ptr<JSONFeatureProviderSource> source(
105 CreateFeatureProviderSource(name));
103 if (name == "api") { 106 if (name == "api") {
104 source.LoadJSON(IDR_EXTENSION_API_FEATURES); 107 provider.reset(new BaseFeatureProvider(source->dictionary(),
105 source.LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); 108 CreateFeature<APIFeature>));
106 return scoped_ptr<FeatureProvider>(new BaseFeatureProvider(
107 source.dictionary(), CreateFeature<APIFeature>));
108 } else if (name == "manifest") { 109 } else if (name == "manifest") {
109 source.LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); 110 provider.reset(new BaseFeatureProvider(source->dictionary(),
110 source.LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES); 111 CreateFeature<ManifestFeature>));
111 return scoped_ptr<FeatureProvider>(new BaseFeatureProvider(
112 source.dictionary(), CreateFeature<ManifestFeature>));
113 } else if (name == "permission") { 112 } else if (name == "permission") {
114 source.LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); 113 provider.reset(new BaseFeatureProvider(source->dictionary(),
115 source.LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES); 114 CreateFeature<PermissionFeature>));
116 return scoped_ptr<FeatureProvider>(new BaseFeatureProvider(
117 source.dictionary(), CreateFeature<PermissionFeature>));
118 } else { 115 } else {
119 NOTREACHED(); 116 NOTREACHED();
120 } 117 }
121 return scoped_ptr<FeatureProvider>(); 118 return provider.Pass();
119 }
120
121 scoped_ptr<JSONFeatureProviderSource>
122 ChromeExtensionsClient::CreateFeatureProviderSource(
James Cook 2014/05/20 18:15:47 btw, I like how you've introduced this API - nice
123 const std::string& name) const {
124 scoped_ptr<JSONFeatureProviderSource> source(
125 new JSONFeatureProviderSource(name));
126 if (name == "api") {
127 source->LoadJSON(IDR_EXTENSION_API_FEATURES);
128 source->LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES);
129 } else if (name == "manifest") {
130 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES);
131 source->LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES);
132 } else if (name == "permission") {
133 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES);
134 source->LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES);
135 } else {
136 NOTREACHED();
137 source.reset();
138 }
139 return source.Pass();
122 } 140 }
123 141
124 void ChromeExtensionsClient::FilterHostPermissions( 142 void ChromeExtensionsClient::FilterHostPermissions(
125 const URLPatternSet& hosts, 143 const URLPatternSet& hosts,
126 URLPatternSet* new_hosts, 144 URLPatternSet* new_hosts,
127 std::set<PermissionMessage>* messages) const { 145 std::set<PermissionMessage>* messages) const {
128 for (URLPatternSet::const_iterator i = hosts.begin(); 146 for (URLPatternSet::const_iterator i = hosts.begin();
129 i != hosts.end(); ++i) { 147 i != hosts.end(); ++i) {
130 // Filters out every URL pattern that matches chrome:// scheme. 148 // Filters out every URL pattern that matches chrome:// scheme.
131 if (i->scheme() == content::kChromeUIScheme) { 149 if (i->scheme() == content::kChromeUIScheme) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // <= dev means dev, canary, and trunk. 235 // <= dev means dev, canary, and trunk.
218 return GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV; 236 return GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV;
219 } 237 }
220 238
221 // static 239 // static
222 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { 240 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() {
223 return g_client.Pointer(); 241 return g_client.Pointer();
224 } 242 }
225 243
226 } // namespace extensions 244 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698