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