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

Side by Side Diff: extensions/common/extension_urls.cc

Issue 575113002: Move Webstore URL concepts to //extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dedupe constants, rename GetExtensionGalleryURL, cleanup comments. 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 "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/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "extensions/common/constants.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"
10 #include "url/gurl.h" 13 #include "url/gurl.h"
11 14
12 namespace extensions { 15 namespace extensions {
13 16
14 const char kEventBindings[] = "event_bindings"; 17 const char kEventBindings[] = "event_bindings";
15 18
16 const char kSchemaUtils[] = "schemaUtils"; 19 const char kSchemaUtils[] = "schemaUtils";
17 20
18 bool IsSourceFromAnExtension(const base::string16& source) { 21 bool IsSourceFromAnExtension(const base::string16& source) {
19 return GURL(source).SchemeIs(kExtensionScheme) || 22 return GURL(source).SchemeIs(kExtensionScheme) ||
20 StartsWith(source, 23 StartsWith(source,
21 base::ASCIIToUTF16("extensions::"), 24 base::ASCIIToUTF16("extensions::"),
22 true /* case-sensitive */); 25 true /* case-sensitive */);
23 } 26 }
24 27
25 } // namespace extensions 28 } // namespace extensions
29
30 namespace extension_urls {
31
32 std::string GetWebstoreLaunchURL() {
33 return extensions::ExtensionsClient::Get()->GetWebstoreBaseURL();
34 }
35
36 std::string GetWebstoreExtensionsCategoryURL() {
37 return GetWebstoreLaunchURL() + "/category/extensions";
38 }
39
40 std::string GetWebstoreItemDetailURLPrefix() {
41 return GetWebstoreLaunchURL() + "/detail/";
42 }
43
44 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
45 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
46 }
47
48 GURL GetWebstoreJsonSearchUrl(const std::string& query,
49 const std::string& host_language_code) {
50 GURL url(GetWebstoreLaunchURL() + "/jsonsearch");
51 url = net::AppendQueryParameter(url, "q", query);
52 url = net::AppendQueryParameter(url, "hl", host_language_code);
53 return url;
54 }
55
56 GURL GetWebstoreSearchPageUrl(const std::string& query) {
57 return GURL(GetWebstoreLaunchURL() + "/search/" +
58 net::EscapeQueryParamValue(query, false));
59 }
60
61 GURL GetWebstoreUpdateUrl() {
62 return GURL(extensions::ExtensionsClient::Get()->GetWebstoreUpdateURL());
63 }
64
65 bool IsWebstoreUpdateUrl(const GURL& update_url) {
66 GURL store_url = GetWebstoreUpdateUrl();
67 if (update_url == store_url) {
68 return true;
69 } else {
70 return (update_url.host() == store_url.host() &&
71 update_url.path() == store_url.path());
72 }
73 }
74
75 bool IsBlacklistUpdateUrl(const GURL& url) {
76 return extensions::ExtensionsClient::Get()->IsBlacklistUpdateURL(url);
77 }
78
79 } // namespace extension_urls
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698