Chromium Code Reviews| 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 "extensions/common/extension_urls.h" | 5 #include "extensions/common/extension_urls.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace extensions | 28 } // namespace extensions |
| 29 | 29 |
| 30 namespace extension_urls { | 30 namespace extension_urls { |
| 31 | 31 |
| 32 const char kChromeWebstoreBaseURL[] = "https://chrome.google.com/webstore"; | 32 const char kChromeWebstoreBaseURL[] = "https://chrome.google.com/webstore"; |
| 33 const char kChromeWebstoreUpdateURL[] = | 33 const char kChromeWebstoreUpdateURL[] = |
| 34 "https://clients2.google.com/service/update2/crx"; | 34 "https://clients2.google.com/service/update2/crx"; |
| 35 | 35 |
| 36 std::string GetWebstoreLaunchURL() { | 36 GURL GetWebstoreLaunchURL() { |
| 37 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get(); | 37 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get(); |
| 38 if (client) | 38 if (client) |
| 39 return client->GetWebstoreBaseURL(); | 39 return client->GetWebstoreBaseURL(); |
| 40 return kChromeWebstoreBaseURL; | 40 return GURL(kChromeWebstoreBaseURL); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // TODO(csharrison,rdevlin.cronin): Migrate the following methods to return | |
|
Devlin
2016/11/21 22:10:53
optional nit: It's more common for my TODOs to jus
| |
| 44 // GURLs. | |
| 45 // TODO(rdevlin.cronin): Try to use GURL methods like Resolve instead of string | |
| 46 // concatenation. | |
| 43 std::string GetWebstoreExtensionsCategoryURL() { | 47 std::string GetWebstoreExtensionsCategoryURL() { |
| 44 return GetWebstoreLaunchURL() + "/category/extensions"; | 48 return GetWebstoreLaunchURL().spec() + "/category/extensions"; |
| 45 } | 49 } |
| 46 | 50 |
| 47 std::string GetWebstoreItemDetailURLPrefix() { | 51 std::string GetWebstoreItemDetailURLPrefix() { |
| 48 return GetWebstoreLaunchURL() + "/detail/"; | 52 return GetWebstoreLaunchURL().spec() + "/detail/"; |
| 49 } | 53 } |
| 50 | 54 |
| 51 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) { | 55 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) { |
| 52 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id); | 56 return GURL(GetWebstoreLaunchURL().spec() + "/inlineinstall/detail/" + |
| 57 extension_id); | |
| 53 } | 58 } |
| 54 | 59 |
| 55 GURL GetWebstoreJsonSearchUrl(const std::string& query, | 60 GURL GetWebstoreJsonSearchUrl(const std::string& query, |
| 56 const std::string& host_language_code) { | 61 const std::string& host_language_code) { |
| 57 GURL url(GetWebstoreLaunchURL() + "/jsonsearch"); | 62 GURL url(GetWebstoreLaunchURL().spec() + "/jsonsearch"); |
| 58 url = net::AppendQueryParameter(url, "q", query); | 63 url = net::AppendQueryParameter(url, "q", query); |
| 59 url = net::AppendQueryParameter(url, "hl", host_language_code); | 64 url = net::AppendQueryParameter(url, "hl", host_language_code); |
| 60 return url; | 65 return url; |
| 61 } | 66 } |
| 62 | 67 |
| 63 GURL GetWebstoreSearchPageUrl(const std::string& query) { | 68 GURL GetWebstoreSearchPageUrl(const std::string& query) { |
| 64 return GURL(GetWebstoreLaunchURL() + "/search/" + | 69 return GURL(GetWebstoreLaunchURL().spec() + "/search/" + |
| 65 net::EscapeQueryParamValue(query, false)); | 70 net::EscapeQueryParamValue(query, false)); |
| 66 } | 71 } |
| 67 | 72 |
| 68 GURL GetWebstoreUpdateUrl() { | 73 GURL GetWebstoreUpdateUrl() { |
| 69 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get(); | 74 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get(); |
| 70 if (client) | 75 if (client) |
| 71 return client->GetWebstoreUpdateURL(); | 76 return client->GetWebstoreUpdateURL(); |
| 72 return GURL(kChromeWebstoreUpdateURL); | 77 return GURL(kChromeWebstoreUpdateURL); |
| 73 } | 78 } |
| 74 | 79 |
| 75 GURL GetWebstoreReportAbuseUrl(const std::string& extension_id, | 80 GURL GetWebstoreReportAbuseUrl(const std::string& extension_id, |
| 76 const std::string& referrer_id) { | 81 const std::string& referrer_id) { |
| 77 return GURL(base::StringPrintf("%s/report/%s?utm_source=%s", | 82 return GURL(base::StringPrintf("%s/report/%s?utm_source=%s", |
| 78 GetWebstoreLaunchURL().c_str(), | 83 GetWebstoreLaunchURL().spec().c_str(), |
| 79 extension_id.c_str(), referrer_id.c_str())); | 84 extension_id.c_str(), referrer_id.c_str())); |
| 80 } | 85 } |
| 81 | 86 |
| 82 bool IsWebstoreUpdateUrl(const GURL& update_url) { | 87 bool IsWebstoreUpdateUrl(const GURL& update_url) { |
| 83 GURL store_url = GetWebstoreUpdateUrl(); | 88 GURL store_url = GetWebstoreUpdateUrl(); |
| 84 return (update_url.host_piece() == store_url.host_piece() && | 89 return (update_url.host_piece() == store_url.host_piece() && |
| 85 update_url.path_piece() == store_url.path_piece()); | 90 update_url.path_piece() == store_url.path_piece()); |
| 86 } | 91 } |
| 87 | 92 |
| 88 bool IsBlacklistUpdateUrl(const GURL& url) { | 93 bool IsBlacklistUpdateUrl(const GURL& url) { |
| 89 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get(); | 94 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get(); |
| 90 if (client) | 95 if (client) |
| 91 return client->IsBlacklistUpdateURL(url); | 96 return client->IsBlacklistUpdateURL(url); |
| 92 return false; | 97 return false; |
| 93 } | 98 } |
| 94 | 99 |
| 95 } // namespace extension_urls | 100 } // namespace extension_urls |
| OLD | NEW |