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

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

Issue 575113002: Move Webstore URL concepts to //extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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"
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 const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
53
54 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
55 const char kExtensionBlocklistUrlPrefix[] =
56 "http://www.gstatic.com/chrome/extensions/blacklist";
57 const char kExtensionBlocklistHttpsUrlPrefix[] =
58 "https://www.gstatic.com/chrome/extensions/blacklist";
59
48 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; 60 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh";
49 61
50 template <class FeatureClass> 62 template <class FeatureClass>
51 SimpleFeature* CreateFeature() { 63 SimpleFeature* CreateFeature() {
52 SimpleFeature* feature = new FeatureClass; 64 SimpleFeature* feature = new FeatureClass;
53 feature->AddFilter( 65 feature->AddFilter(
54 scoped_ptr<SimpleFeatureFilter>(new ChromeChannelFeatureFilter(feature))); 66 scoped_ptr<SimpleFeatureFilter>(new ChromeChannelFeatureFilter(feature)));
55 return feature; 67 return feature;
56 } 68 }
57 69
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 api->RegisterSchemaResource("webViewRequest", 278 api->RegisterSchemaResource("webViewRequest",
267 IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST); 279 IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST);
268 #endif // defined(ENABLE_EXTENSIONS) 280 #endif // defined(ENABLE_EXTENSIONS)
269 } 281 }
270 282
271 bool ChromeExtensionsClient::ShouldSuppressFatalErrors() const { 283 bool ChromeExtensionsClient::ShouldSuppressFatalErrors() const {
272 // Suppress fatal errors only on beta and stable channels. 284 // Suppress fatal errors only on beta and stable channels.
273 return GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV; 285 return GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV;
274 } 286 }
275 287
288 std::string ChromeExtensionsClient::GetWebstoreBaseURL() const {
289 std::string gallery_prefix = kGalleryBrowsePrefix;
290 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
291 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
292 switches::kAppsGalleryURL);
293 if (EndsWith(gallery_prefix, "/", true))
294 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
295 return gallery_prefix;
296 }
297
298 std::string ChromeExtensionsClient::GetWebstoreUpdateURL() const {
299 CommandLine* cmdline = CommandLine::ForCurrentProcess();
300 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
301 return cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL);
302 else
303 return extension_urls::GetDefaultWebstoreUpdateUrl().spec();
304 }
305
306 bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const {
307 // The extension blacklist URL is returned from the update service and
308 // therefore not determined by Chromium. If the location of the blacklist file
309 // ever changes, we need to update this function. A DCHECK in the
310 // ExtensionUpdater ensures that we notice a change. This is the full URL
311 // of a blacklist:
312 // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt
313 return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) ||
314 StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true);
315 }
316
276 // static 317 // static
277 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { 318 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() {
278 return g_client.Pointer(); 319 return g_client.Pointer();
279 } 320 }
280 321
281 } // namespace extensions 322 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698