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 "components/history/core/browser/url_utils.h" | 5 #include "components/history/core/browser/url_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/strings/string_util.h" |
9 #include "url/gurl.h" | 10 #include "url/gurl.h" |
10 | 11 |
11 namespace history { | 12 namespace history { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // Comparator to enforce '\0' < '?' < '#' < '/' < other characters. | 16 // Comparator to enforce '\0' < '?' < '#' < '/' < other characters. |
16 int GetURLCharPriority(char ch) { | 17 int GetURLCharPriority(char ch) { |
17 switch (ch) { | 18 switch (ch) { |
18 case '\0': return 0; | 19 case '\0': return 0; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 new_scheme = "http"; | 79 new_scheme = "http"; |
79 else | 80 else |
80 return GURL::EmptyGURL(); | 81 return GURL::EmptyGURL(); |
81 url::Component comp; | 82 url::Component comp; |
82 comp.len = static_cast<int>(new_scheme.length()); | 83 comp.len = static_cast<int>(new_scheme.length()); |
83 GURL::Replacements replacement; | 84 GURL::Replacements replacement; |
84 replacement.SetScheme(new_scheme.c_str(), comp); | 85 replacement.SetScheme(new_scheme.c_str(), comp); |
85 return url.ReplaceComponents(replacement); | 86 return url.ReplaceComponents(replacement); |
86 } | 87 } |
87 | 88 |
| 89 std::string HostForTopHosts(const GURL& url) { |
| 90 std::string host = url.host(); |
| 91 if (base::StartsWithASCII(host, "www.", true)) |
| 92 host.assign(host, 4, std::string::npos); |
| 93 return host; |
| 94 } |
| 95 |
88 } // namespace history | 96 } // namespace history |
OLD | NEW |