summaryrefslogtreecommitdiffstats
path: root/extensions/common/extension_urls.cc
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2014-09-18 12:31:52 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-18 19:32:14 +0000
commit9065985da2ce2a4f73150ac5eabab29c5d67505d (patch)
treea7e5407965a7b5e6905210344c2352ff2ce4adb5 /extensions/common/extension_urls.cc
parentd4a62b87d28f0bda1c9453f02d9ea22fccaf700c (diff)
downloadchromium_src-9065985da2ce2a4f73150ac5eabab29c5d67505d.zip
chromium_src-9065985da2ce2a4f73150ac5eabab29c5d67505d.tar.gz
chromium_src-9065985da2ce2a4f73150ac5eabab29c5d67505d.tar.bz2
Move Webstore URL concepts to //extensions and out
of Chrome-specific "constants." These URLs can be overridden by extensions embedders now and are no longer incorrectly classified as "constants." BUG=398671 TBR=xiyuan@chromium.org,sky@chromium.org for various files with header updates Review URL: https://codereview.chromium.org/575113002 Cr-Commit-Position: refs/heads/master@{#295523}
Diffstat (limited to 'extensions/common/extension_urls.cc')
-rw-r--r--extensions/common/extension_urls.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/extensions/common/extension_urls.cc b/extensions/common/extension_urls.cc
index ba72a63..c58a2d6 100644
--- a/extensions/common/extension_urls.cc
+++ b/extensions/common/extension_urls.cc
@@ -7,6 +7,9 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/constants.h"
+#include "extensions/common/extensions_client.h"
+#include "net/base/escape.h"
+#include "net/base/url_util.h"
#include "url/gurl.h"
namespace extensions {
@@ -23,3 +26,67 @@ bool IsSourceFromAnExtension(const base::string16& source) {
}
} // namespace extensions
+
+namespace extension_urls {
+
+const char kChromeWebstoreBaseURL[] = "https://chrome.google.com/webstore";
+const char kChromeWebstoreUpdateURL[] =
+ "https://clients2.google.com/service/update2/crx";
+
+std::string GetWebstoreLaunchURL() {
+ extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get();
+ if (client)
+ return client->GetWebstoreBaseURL();
+ return kChromeWebstoreBaseURL;
+}
+
+std::string GetWebstoreExtensionsCategoryURL() {
+ return GetWebstoreLaunchURL() + "/category/extensions";
+}
+
+std::string GetWebstoreItemDetailURLPrefix() {
+ return GetWebstoreLaunchURL() + "/detail/";
+}
+
+GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
+ return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
+}
+
+GURL GetWebstoreJsonSearchUrl(const std::string& query,
+ const std::string& host_language_code) {
+ GURL url(GetWebstoreLaunchURL() + "/jsonsearch");
+ url = net::AppendQueryParameter(url, "q", query);
+ url = net::AppendQueryParameter(url, "hl", host_language_code);
+ return url;
+}
+
+GURL GetWebstoreSearchPageUrl(const std::string& query) {
+ return GURL(GetWebstoreLaunchURL() + "/search/" +
+ net::EscapeQueryParamValue(query, false));
+}
+
+GURL GetWebstoreUpdateUrl() {
+ extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get();
+ if (client)
+ return GURL(client->GetWebstoreUpdateURL());
+ return GURL(kChromeWebstoreUpdateURL);
+}
+
+bool IsWebstoreUpdateUrl(const GURL& update_url) {
+ GURL store_url = GetWebstoreUpdateUrl();
+ if (update_url == store_url) {
+ return true;
+ } else {
+ return (update_url.host() == store_url.host() &&
+ update_url.path() == store_url.path());
+ }
+}
+
+bool IsBlacklistUpdateUrl(const GURL& url) {
+ extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get();
+ if (client)
+ return client->IsBlacklistUpdateURL(url);
+ return false;
+}
+
+} // namespace extension_urls