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

Side by Side Diff: chrome/common/extensions/chrome_extensions_client.cc

Issue 582933003: Revert of Cleanup: Remove remaining generated extensions APIs on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extclean4
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/common/extensions/api/schemas.gypi ('k') | extensions/common/api/schemas.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/chrome_version_info.h" 10 #include "chrome/common/chrome_version_info.h"
11 #include "chrome/common/extensions/api/generated_schemas.h"
11 #include "chrome/common/extensions/chrome_manifest_handlers.h" 12 #include "chrome/common/extensions/chrome_manifest_handlers.h"
12 #include "chrome/common/extensions/extension_constants.h" 13 #include "chrome/common/extensions/extension_constants.h"
13 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h" 14 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h"
14 #include "chrome/common/extensions/features/feature_channel.h" 15 #include "chrome/common/extensions/features/feature_channel.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/grit/chromium_strings.h" 17 #include "chrome/grit/chromium_strings.h"
17 #include "chrome/grit/common_resources.h" 18 #include "chrome/grit/common_resources.h"
18 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
19 #include "content/public/common/url_constants.h" 20 #include "content/public/common/url_constants.h"
21 #include "extensions/common/api/generated_schemas.h"
20 #include "extensions/common/common_manifest_handlers.h" 22 #include "extensions/common/common_manifest_handlers.h"
21 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_api.h" 24 #include "extensions/common/extension_api.h"
23 #include "extensions/common/extension_urls.h" 25 #include "extensions/common/extension_urls.h"
24 #include "extensions/common/features/api_feature.h" 26 #include "extensions/common/features/api_feature.h"
25 #include "extensions/common/features/base_feature_provider.h" 27 #include "extensions/common/features/base_feature_provider.h"
26 #include "extensions/common/features/feature_provider.h" 28 #include "extensions/common/features/feature_provider.h"
27 #include "extensions/common/features/json_feature_provider_source.h" 29 #include "extensions/common/features/json_feature_provider_source.h"
28 #include "extensions/common/features/manifest_feature.h" 30 #include "extensions/common/features/manifest_feature.h"
29 #include "extensions/common/features/permission_feature.h" 31 #include "extensions/common/features/permission_feature.h"
30 #include "extensions/common/features/simple_feature.h" 32 #include "extensions/common/features/simple_feature.h"
31 #include "extensions/common/manifest_constants.h" 33 #include "extensions/common/manifest_constants.h"
32 #include "extensions/common/manifest_handler.h" 34 #include "extensions/common/manifest_handler.h"
33 #include "extensions/common/permissions/api_permission_set.h" 35 #include "extensions/common/permissions/api_permission_set.h"
34 #include "extensions/common/permissions/permission_message.h" 36 #include "extensions/common/permissions/permission_message.h"
35 #include "extensions/common/permissions/permissions_info.h" 37 #include "extensions/common/permissions/permissions_info.h"
36 #include "extensions/common/url_pattern.h" 38 #include "extensions/common/url_pattern.h"
37 #include "extensions/common/url_pattern_set.h" 39 #include "extensions/common/url_pattern_set.h"
38 #include "extensions/grit/extensions_resources.h" 40 #include "extensions/grit/extensions_resources.h"
39 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
40 #include "url/gurl.h" 42 #include "url/gurl.h"
41 43
42 // TODO(thestig): Remove these #defines. This file should not be built when
43 // extensions are disabled.
44 #if defined(ENABLE_EXTENSIONS) 44 #if defined(ENABLE_EXTENSIONS)
45 #include "chrome/common/extensions/api/generated_schemas.h"
46 #include "chrome/grit/extensions_api_resources.h" 45 #include "chrome/grit/extensions_api_resources.h"
47 #include "extensions/common/api/generated_schemas.h"
48 #endif 46 #endif
49 47
50 namespace extensions { 48 namespace extensions {
51 49
52 namespace { 50 namespace {
53 51
54 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS. 52 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
55 const char kExtensionBlocklistUrlPrefix[] = 53 const char kExtensionBlocklistUrlPrefix[] =
56 "http://www.gstatic.com/chrome/extensions/blacklist"; 54 "http://www.gstatic.com/chrome/extensions/blacklist";
57 const char kExtensionBlocklistHttpsUrlPrefix[] = 55 const char kExtensionBlocklistHttpsUrlPrefix[] =
(...skipping 20 matching lines...) Expand all
78 } 76 }
79 77
80 ChromeExtensionsClient::~ChromeExtensionsClient() { 78 ChromeExtensionsClient::~ChromeExtensionsClient() {
81 } 79 }
82 80
83 void ChromeExtensionsClient::Initialize() { 81 void ChromeExtensionsClient::Initialize() {
84 // Registration could already be finalized in unit tests, where the utility 82 // Registration could already be finalized in unit tests, where the utility
85 // thread runs in-process. 83 // thread runs in-process.
86 if (!ManifestHandler::IsRegistrationFinalized()) { 84 if (!ManifestHandler::IsRegistrationFinalized()) {
87 RegisterCommonManifestHandlers(); 85 RegisterCommonManifestHandlers();
88 #if defined(ENABLE_EXTENSIONS)
89 RegisterChromeManifestHandlers(); 86 RegisterChromeManifestHandlers();
90 #endif
91 ManifestHandler::FinalizeRegistration(); 87 ManifestHandler::FinalizeRegistration();
92 } 88 }
93 89
94 // Set up permissions. 90 // Set up permissions.
95 PermissionsInfo::GetInstance()->AddProvider(chrome_api_permissions_); 91 PermissionsInfo::GetInstance()->AddProvider(chrome_api_permissions_);
96 PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_); 92 PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_);
97 93
98 // Set up the scripting whitelist. 94 // Set up the scripting whitelist.
99 // Whitelist ChromeVox, an accessibility extension from Google that needs 95 // Whitelist ChromeVox, an accessibility extension from Google that needs
100 // the ability to script webui pages. This is temporary and is not 96 // the ability to script webui pages. This is temporary and is not
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (url.host() == store_url.host()) { 223 if (url.host() == store_url.host()) {
228 if (error) 224 if (error)
229 *error = manifest_errors::kCannotScriptGallery; 225 *error = manifest_errors::kCannotScriptGallery;
230 return false; 226 return false;
231 } 227 }
232 return true; 228 return true;
233 } 229 }
234 230
235 bool ChromeExtensionsClient::IsAPISchemaGenerated( 231 bool ChromeExtensionsClient::IsAPISchemaGenerated(
236 const std::string& name) const { 232 const std::string& name) const {
237 #if defined(ENABLE_EXTENSIONS)
238 // Test from most common to least common. 233 // Test from most common to least common.
239 return api::GeneratedSchemas::IsGenerated(name) || 234 return api::GeneratedSchemas::IsGenerated(name) ||
240 core_api::GeneratedSchemas::IsGenerated(name); 235 core_api::GeneratedSchemas::IsGenerated(name);
241 #else
242 return false;
243 #endif
244 } 236 }
245 237
246 base::StringPiece ChromeExtensionsClient::GetAPISchema( 238 base::StringPiece ChromeExtensionsClient::GetAPISchema(
247 const std::string& name) const { 239 const std::string& name) const {
248 #if defined(ENABLE_EXTENSIONS)
249 // Test from most common to least common. 240 // Test from most common to least common.
250 if (api::GeneratedSchemas::IsGenerated(name)) 241 if (api::GeneratedSchemas::IsGenerated(name))
251 return api::GeneratedSchemas::Get(name); 242 return api::GeneratedSchemas::Get(name);
252 243
253 return core_api::GeneratedSchemas::Get(name); 244 return core_api::GeneratedSchemas::Get(name);
254 #else
255 return base::StringPiece();
256 #endif
257 } 245 }
258 246
259 void ChromeExtensionsClient::RegisterAPISchemaResources( 247 void ChromeExtensionsClient::RegisterAPISchemaResources(
260 ExtensionAPI* api) const { 248 ExtensionAPI* api) const {
261 #if defined(ENABLE_EXTENSIONS) 249 #if defined(ENABLE_EXTENSIONS)
262 api->RegisterSchemaResource("accessibilityPrivate", 250 api->RegisterSchemaResource("accessibilityPrivate",
263 IDR_EXTENSION_API_JSON_ACCESSIBILITYPRIVATE); 251 IDR_EXTENSION_API_JSON_ACCESSIBILITYPRIVATE);
264 api->RegisterSchemaResource("app", IDR_EXTENSION_API_JSON_APP); 252 api->RegisterSchemaResource("app", IDR_EXTENSION_API_JSON_APP);
265 api->RegisterSchemaResource("browserAction", 253 api->RegisterSchemaResource("browserAction",
266 IDR_EXTENSION_API_JSON_BROWSERACTION); 254 IDR_EXTENSION_API_JSON_BROWSERACTION);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) || 311 return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) ||
324 StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true); 312 StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true);
325 } 313 }
326 314
327 // static 315 // static
328 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { 316 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() {
329 return g_client.Pointer(); 317 return g_client.Pointer();
330 } 318 }
331 319
332 } // namespace extensions 320 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/schemas.gypi ('k') | extensions/common/api/schemas.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698