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

Side by Side Diff: chrome/common/extensions/extension_constants.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extension_constants.h" 5 #include "chrome/common/extensions/extension_constants.h"
6 6
7 #include <vector>
8
9 #include "base/command_line.h"
10 #include "base/strings/string_util.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "net/base/escape.h"
13 #include "net/base/url_util.h"
14
15 namespace extension_urls { 7 namespace extension_urls {
16 8
17 std::string GetWebstoreLaunchURL() { 9 namespace {
18 std::string gallery_prefix = kGalleryBrowsePrefix;
19 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
20 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
21 switches::kAppsGalleryURL);
22 if (EndsWith(gallery_prefix, "/", true))
23 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
24 return gallery_prefix;
25 }
26
27 std::string GetExtensionGalleryURL() {
28 return GetWebstoreLaunchURL() + "/category/extensions";
29 }
30
31 std::string GetWebstoreItemDetailURLPrefix() {
32 return GetWebstoreLaunchURL() + "/detail/";
33 }
34
35 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
36 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
37 }
38
39 GURL GetWebstoreJsonSearchUrl(const std::string& query, const std::string& hl) {
40 GURL url(GetWebstoreLaunchURL() + "/jsonsearch");
41 url = net::AppendQueryParameter(url, "q", query);
42 url = net::AppendQueryParameter(url, "hl", hl);
43 return url;
44 }
45
46 GURL GetWebstoreSearchPageUrl(const std::string& query) {
47 return GURL(GetWebstoreLaunchURL() + "/search/" +
48 net::EscapeQueryParamValue(query, false));
49 }
50 10
51 const char kGalleryUpdateHttpsUrl[] = 11 const char kGalleryUpdateHttpsUrl[] =
52 "https://clients2.google.com/service/update2/crx"; 12 "https://clients2.google.com/service/update2/crx";
53 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
54 const char kExtensionBlocklistUrlPrefix[] =
55 "http://www.gstatic.com/chrome/extensions/blacklist";
56 const char kExtensionBlocklistHttpsUrlPrefix[] =
57 "https://www.gstatic.com/chrome/extensions/blacklist";
58 13
59 GURL GetWebstoreUpdateUrl() { 14 } // namespace
60 CommandLine* cmdline = CommandLine::ForCurrentProcess();
61 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
62 return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL));
63 else
64 return GetDefaultWebstoreUpdateUrl();
65 }
66 15
67 GURL GetDefaultWebstoreUpdateUrl() { 16 GURL GetDefaultWebstoreUpdateUrl() {
68 return GURL(kGalleryUpdateHttpsUrl); 17 return GURL(kGalleryUpdateHttpsUrl);
69 } 18 }
70 19
71 bool IsWebstoreUpdateUrl(const GURL& update_url) {
72 GURL store_url = GetWebstoreUpdateUrl();
73 if (update_url == store_url) {
74 return true;
75 } else {
76 return (update_url.host() == store_url.host() &&
77 update_url.path() == store_url.path());
78 }
79 }
80
81 bool IsBlacklistUpdateUrl(const GURL& url) {
82 // The extension blacklist URL is returned from the update service and
83 // therefore not determined by Chromium. If the location of the blacklist file
84 // ever changes, we need to update this function. A DCHECK in the
85 // ExtensionUpdater ensures that we notice a change. This is the full URL
86 // of a blacklist:
87 // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt
88 return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) ||
89 StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true);
90 }
91
92 const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
93
94 const char kWebstoreSourceField[] = "utm_source"; 20 const char kWebstoreSourceField[] = "utm_source";
95 21
96 const char kLaunchSourceAppList[] = "chrome-app-launcher"; 22 const char kLaunchSourceAppList[] = "chrome-app-launcher";
97 const char kLaunchSourceAppListSearch[] = "chrome-app-launcher-search"; 23 const char kLaunchSourceAppListSearch[] = "chrome-app-launcher-search";
98 const char kLaunchSourceAppListInfoDialog[] = "chrome-app-launcher-info-dialog"; 24 const char kLaunchSourceAppListInfoDialog[] = "chrome-app-launcher-info-dialog";
99 25
100 } // namespace extension_urls 26 } // namespace extension_urls
101 27
102 namespace extension_misc { 28 namespace extension_misc {
103 29
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 0xfc, 0xf3, 0x08, 0x12, 0xff, 0x93, 0xbd, 0x62, 0x31, 0xd8, 0x1c, 0xea, 123 0xfc, 0xf3, 0x08, 0x12, 0xff, 0x93, 0xbd, 0x62, 0x31, 0xd8, 0x1c, 0xea,
198 0x1a, 0x9e, 0xf5, 0x81, 0x28, 0x7f, 0x75, 0x5e, 0xd2, 0x27, 0x7a, 0xc2, 124 0x1a, 0x9e, 0xf5, 0x81, 0x28, 0x7f, 0x75, 0x5e, 0xd2, 0x27, 0x7a, 0xc2,
199 0x96, 0xf5, 0x9d, 0xdb, 0x18, 0xfc, 0x76, 0xdc, 0x46, 0xf0, 0x57, 0xc0, 125 0x96, 0xf5, 0x9d, 0xdb, 0x18, 0xfc, 0x76, 0xdc, 0x46, 0xf0, 0x57, 0xc0,
200 0x58, 0x34, 0xc8, 0x22, 0x2d, 0x2a, 0x65, 0x75, 0xa7, 0xd9, 0x08, 0x62, 126 0x58, 0x34, 0xc8, 0x22, 0x2d, 0x2a, 0x65, 0x75, 0xa7, 0xd9, 0x08, 0x62,
201 0xcd, 0x02, 0x03, 0x01, 0x00, 0x01}; 127 0xcd, 0x02, 0x03, 0x01, 0x00, 0x01};
202 128
203 const int kWebstoreSignaturesPublicKeySize = 129 const int kWebstoreSignaturesPublicKeySize =
204 arraysize(kWebstoreSignaturesPublicKey); 130 arraysize(kWebstoreSignaturesPublicKey);
205 131
206 } // namespace extension_misc 132 } // namespace extension_misc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698