Update V8 to version 4.5.80.
[chromium-blink-merge.git] / extensions / common / extension_urls.cc
blob2b34178be59a16528a98063e771a4fcaaa8f9d1b
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
3 // found in the LICENSE file.
5 #include "extensions/common/extension_urls.h"
7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "extensions/common/constants.h"
10 #include "extensions/common/extensions_client.h"
11 #include "net/base/escape.h"
12 #include "net/base/url_util.h"
13 #include "url/gurl.h"
15 namespace extensions {
17 const char kEventBindings[] = "event_bindings";
19 const char kSchemaUtils[] = "schemaUtils";
21 bool IsSourceFromAnExtension(const base::string16& source) {
22 return GURL(source).SchemeIs(kExtensionScheme) ||
23 base::StartsWith(source, base::ASCIIToUTF16("extensions::"),
24 true /* case-sensitive */);
27 } // namespace extensions
29 namespace extension_urls {
31 const char kChromeWebstoreBaseURL[] = "https://chrome.google.com/webstore";
32 const char kChromeWebstoreUpdateURL[] =
33 "https://clients2.google.com/service/update2/crx";
35 std::string GetWebstoreLaunchURL() {
36 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get();
37 if (client)
38 return client->GetWebstoreBaseURL();
39 return kChromeWebstoreBaseURL;
42 std::string GetWebstoreExtensionsCategoryURL() {
43 return GetWebstoreLaunchURL() + "/category/extensions";
46 std::string GetWebstoreItemDetailURLPrefix() {
47 return GetWebstoreLaunchURL() + "/detail/";
50 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
51 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
54 GURL GetWebstoreJsonSearchUrl(const std::string& query,
55 const std::string& host_language_code) {
56 GURL url(GetWebstoreLaunchURL() + "/jsonsearch");
57 url = net::AppendQueryParameter(url, "q", query);
58 url = net::AppendQueryParameter(url, "hl", host_language_code);
59 return url;
62 GURL GetWebstoreSearchPageUrl(const std::string& query) {
63 return GURL(GetWebstoreLaunchURL() + "/search/" +
64 net::EscapeQueryParamValue(query, false));
67 GURL GetWebstoreUpdateUrl() {
68 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get();
69 if (client)
70 return GURL(client->GetWebstoreUpdateURL());
71 return GURL(kChromeWebstoreUpdateURL);
74 GURL GetWebstoreReportAbuseUrl(const std::string& extension_id) {
75 return GURL(GetWebstoreLaunchURL() + "/report/" + extension_id);
78 bool IsWebstoreUpdateUrl(const GURL& update_url) {
79 GURL store_url = GetWebstoreUpdateUrl();
80 if (update_url == store_url) {
81 return true;
82 } else {
83 return (update_url.host() == store_url.host() &&
84 update_url.path() == store_url.path());
88 bool IsBlacklistUpdateUrl(const GURL& url) {
89 extensions::ExtensionsClient* client = extensions::ExtensionsClient::Get();
90 if (client)
91 return client->IsBlacklistUpdateURL(url);
92 return false;
95 } // namespace extension_urls