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" |
| 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/common/chrome_switches.h" |
7 #include "chrome/common/chrome_version_info.h" | 10 #include "chrome/common/chrome_version_info.h" |
8 #include "chrome/common/extensions/api/generated_schemas.h" | 11 #include "chrome/common/extensions/api/generated_schemas.h" |
9 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 12 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
10 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
11 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h" | 14 #include "chrome/common/extensions/features/chrome_channel_feature_filter.h" |
12 #include "chrome/common/extensions/features/feature_channel.h" | 15 #include "chrome/common/extensions/features/feature_channel.h" |
13 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
14 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
15 #include "chrome/grit/common_resources.h" | 18 #include "chrome/grit/common_resources.h" |
16 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
17 #include "content/public/common/url_constants.h" | 20 #include "content/public/common/url_constants.h" |
18 #include "extensions/common/api/generated_schemas.h" | 21 #include "extensions/common/api/generated_schemas.h" |
19 #include "extensions/common/common_manifest_handlers.h" | 22 #include "extensions/common/common_manifest_handlers.h" |
20 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
21 #include "extensions/common/extension_api.h" | 24 #include "extensions/common/extension_api.h" |
| 25 #include "extensions/common/extension_urls.h" |
22 #include "extensions/common/features/api_feature.h" | 26 #include "extensions/common/features/api_feature.h" |
23 #include "extensions/common/features/base_feature_provider.h" | 27 #include "extensions/common/features/base_feature_provider.h" |
24 #include "extensions/common/features/feature_provider.h" | 28 #include "extensions/common/features/feature_provider.h" |
25 #include "extensions/common/features/json_feature_provider_source.h" | 29 #include "extensions/common/features/json_feature_provider_source.h" |
26 #include "extensions/common/features/manifest_feature.h" | 30 #include "extensions/common/features/manifest_feature.h" |
27 #include "extensions/common/features/permission_feature.h" | 31 #include "extensions/common/features/permission_feature.h" |
28 #include "extensions/common/features/simple_feature.h" | 32 #include "extensions/common/features/simple_feature.h" |
29 #include "extensions/common/manifest_constants.h" | 33 #include "extensions/common/manifest_constants.h" |
30 #include "extensions/common/manifest_handler.h" | 34 #include "extensions/common/manifest_handler.h" |
31 #include "extensions/common/permissions/api_permission_set.h" | 35 #include "extensions/common/permissions/api_permission_set.h" |
32 #include "extensions/common/permissions/permission_message.h" | 36 #include "extensions/common/permissions/permission_message.h" |
33 #include "extensions/common/permissions/permissions_info.h" | 37 #include "extensions/common/permissions/permissions_info.h" |
34 #include "extensions/common/url_pattern.h" | 38 #include "extensions/common/url_pattern.h" |
35 #include "extensions/common/url_pattern_set.h" | 39 #include "extensions/common/url_pattern_set.h" |
36 #include "extensions/grit/extensions_resources.h" | 40 #include "extensions/grit/extensions_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
38 #include "url/gurl.h" | 42 #include "url/gurl.h" |
39 | 43 |
40 #if defined(ENABLE_EXTENSIONS) | 44 #if defined(ENABLE_EXTENSIONS) |
41 #include "chrome/grit/extensions_api_resources.h" | 45 #include "chrome/grit/extensions_api_resources.h" |
42 #endif | 46 #endif |
43 | 47 |
44 namespace extensions { | 48 namespace extensions { |
45 | 49 |
46 namespace { | 50 namespace { |
47 | 51 |
| 52 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS. |
| 53 const char kExtensionBlocklistUrlPrefix[] = |
| 54 "http://www.gstatic.com/chrome/extensions/blacklist"; |
| 55 const char kExtensionBlocklistHttpsUrlPrefix[] = |
| 56 "https://www.gstatic.com/chrome/extensions/blacklist"; |
| 57 |
48 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; | 58 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; |
49 | 59 |
50 template <class FeatureClass> | 60 template <class FeatureClass> |
51 SimpleFeature* CreateFeature() { | 61 SimpleFeature* CreateFeature() { |
52 SimpleFeature* feature = new FeatureClass; | 62 SimpleFeature* feature = new FeatureClass; |
53 feature->AddFilter( | 63 feature->AddFilter( |
54 scoped_ptr<SimpleFeatureFilter>(new ChromeChannelFeatureFilter(feature))); | 64 scoped_ptr<SimpleFeatureFilter>(new ChromeChannelFeatureFilter(feature))); |
55 return feature; | 65 return feature; |
56 } | 66 } |
57 | 67 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 api->RegisterSchemaResource("webViewRequest", | 276 api->RegisterSchemaResource("webViewRequest", |
267 IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST); | 277 IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST); |
268 #endif // defined(ENABLE_EXTENSIONS) | 278 #endif // defined(ENABLE_EXTENSIONS) |
269 } | 279 } |
270 | 280 |
271 bool ChromeExtensionsClient::ShouldSuppressFatalErrors() const { | 281 bool ChromeExtensionsClient::ShouldSuppressFatalErrors() const { |
272 // Suppress fatal errors only on beta and stable channels. | 282 // Suppress fatal errors only on beta and stable channels. |
273 return GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; | 283 return GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; |
274 } | 284 } |
275 | 285 |
| 286 std::string ChromeExtensionsClient::GetWebstoreBaseURL() const { |
| 287 std::string gallery_prefix = extension_urls::kChromeWebstoreBaseURL; |
| 288 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL)) |
| 289 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 290 switches::kAppsGalleryURL); |
| 291 if (EndsWith(gallery_prefix, "/", true)) |
| 292 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); |
| 293 return gallery_prefix; |
| 294 } |
| 295 |
| 296 std::string ChromeExtensionsClient::GetWebstoreUpdateURL() const { |
| 297 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 298 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) |
| 299 return cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL); |
| 300 else |
| 301 return extension_urls::GetDefaultWebstoreUpdateUrl().spec(); |
| 302 } |
| 303 |
| 304 bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { |
| 305 // The extension blacklist URL is returned from the update service and |
| 306 // therefore not determined by Chromium. If the location of the blacklist file |
| 307 // ever changes, we need to update this function. A DCHECK in the |
| 308 // ExtensionUpdater ensures that we notice a change. This is the full URL |
| 309 // of a blacklist: |
| 310 // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt |
| 311 return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) || |
| 312 StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true); |
| 313 } |
| 314 |
276 // static | 315 // static |
277 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 316 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
278 return g_client.Pointer(); | 317 return g_client.Pointer(); |
279 } | 318 } |
280 | 319 |
281 } // namespace extensions | 320 } // namespace extensions |
OLD | NEW |