| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // url_formatter contains routines for formatting URLs in a way that can be | 5 // url_formatter contains routines for formatting URLs in a way that can be |
| 6 // safely and securely displayed to users. For example, it is responsible | 6 // safely and securely displayed to users. For example, it is responsible |
| 7 // for determining when to convert an IDN A-Label (e.g. "xn--[something]") | 7 // for determining when to convert an IDN A-Label (e.g. "xn--[something]") |
| 8 // into the IDN U-Label. | 8 // into the IDN U-Label. |
| 9 // | 9 // |
| 10 // Note that this formatting is only intended for display purposes; it would | 10 // Note that this formatting is only intended for display purposes; it would |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 // Converts the given host name to unicode characters. This can be called for | 131 // Converts the given host name to unicode characters. This can be called for |
| 132 // any host name, if the input is not IDN or is invalid in some way, we'll just | 132 // any host name, if the input is not IDN or is invalid in some way, we'll just |
| 133 // return the ASCII source so it is still usable. | 133 // return the ASCII source so it is still usable. |
| 134 // | 134 // |
| 135 // The input should be the canonicalized ASCII host name from GURL. This | 135 // The input should be the canonicalized ASCII host name from GURL. This |
| 136 // function does NOT accept UTF-8! | 136 // function does NOT accept UTF-8! |
| 137 base::string16 IDNToUnicode(base::StringPiece host); | 137 base::string16 IDNToUnicode(base::StringPiece host); |
| 138 | 138 |
| 139 // If |text| starts with "www." it is removed, otherwise |text| is returned | 139 // If |text| starts with "www." it is removed, otherwise |text| is returned |
| 140 // unmodified. | 140 // unmodified. Both |text| and the returned value are arbitrary strings and |
| 141 // are not guaranteed to be navigable hostnames. |
| 141 base::string16 StripWWW(const base::string16& text); | 142 base::string16 StripWWW(const base::string16& text); |
| 142 | 143 |
| 143 // Runs |url|'s host through StripWWW(). |url| must be valid. | 144 // Returns the host of |url| with subdomains specified by |subdomains| |
| 144 base::string16 StripWWWFromHost(const GURL& url); | 145 // removed. |url| must be valid. If the |url| host is already an eTLD+1, |
| 146 // the host is returned unmodified. |
| 147 typedef uint32_t StripSubdomainType; |
| 148 typedef uint32_t StripSubdomainTypes; |
| 149 constexpr StripSubdomainType kStripWWW = 1 << 0; |
| 150 constexpr StripSubdomainType kStripM = 1 << 1; |
| 151 std::string StripSubdomains(const GURL& url, StripSubdomainTypes subdomains); |
| 145 | 152 |
| 146 } // namespace url_formatter | 153 } // namespace url_formatter |
| 147 | 154 |
| 148 #endif // COMPONENTS_URL_FORMATTER_URL_FORMATTER_H_ | 155 #endif // COMPONENTS_URL_FORMATTER_URL_FORMATTER_H_ |
| OLD | NEW |