Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/url_formatter/elide_url.h" | 5 #include "components/url_formatter/elide_url.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 71 |
| 72 return base::string16(); | 72 return base::string16(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Splits the hostname in the |url| into sub-strings for the full hostname, | 75 // Splits the hostname in the |url| into sub-strings for the full hostname, |
| 76 // the domain (TLD+1), and the subdomain (everything leading the domain). | 76 // the domain (TLD+1), and the subdomain (everything leading the domain). |
| 77 void SplitHost(const GURL& url, | 77 void SplitHost(const GURL& url, |
| 78 base::string16* url_host, | 78 base::string16* url_host, |
| 79 base::string16* url_domain, | 79 base::string16* url_domain, |
| 80 base::string16* url_subdomain) { | 80 base::string16* url_subdomain) { |
| 81 // Get Host. | 81 // Get Host in ACE(ASCII Compatible Encoding). |
|
Peter Kasting
2016/04/06 21:38:39
Since we don't use "ACE" most other places in Chro
jungshik at Google
2016/04/06 21:50:38
Ok. (I regret not having used ACE before :-)).
| |
| 82 *url_host = base::UTF8ToUTF16(url.host()); | 82 std::string host_ace = url.host(); |
| 83 | 83 |
| 84 // Get domain and registry information from the URL. | 84 // Get domain and registry information from the URL. |
| 85 *url_domain = | 85 std::string domain_ace = |
| 86 base::UTF8ToUTF16(net::registry_controlled_domains::GetDomainAndRegistry( | 86 net::registry_controlled_domains::GetDomainAndRegistry( |
| 87 url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)); | 87 url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 88 if (url_domain->empty()) | 88 if (domain_ace.empty()) |
| 89 *url_domain = *url_host; | 89 domain_ace = host_ace; |
| 90 | |
| 91 *url_host = url_formatter::IDNToUnicode(host_ace); | |
| 92 *url_domain = url_formatter::IDNToUnicode(domain_ace); | |
| 90 | 93 |
| 91 // Add port if required. | 94 // Add port if required. |
| 92 if (!url.port().empty()) { | 95 if (!url.port().empty()) { |
| 93 *url_host += base::UTF8ToUTF16(":" + url.port()); | 96 *url_host += base::UTF8ToUTF16(":" + url.port()); |
| 94 *url_domain += base::UTF8ToUTF16(":" + url.port()); | 97 *url_domain += base::UTF8ToUTF16(":" + url.port()); |
| 95 } | 98 } |
| 96 | 99 |
| 97 // Get sub domain. | 100 // Get sub domain. |
| 98 const size_t domain_start_index = url_host->find(*url_domain); | 101 const size_t domain_start_index = url_host->find(*url_domain); |
| 99 base::string16 kWwwPrefix = base::UTF8ToUTF16("www."); | 102 base::string16 kWwwPrefix = base::UTF8ToUTF16("www."); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 | 359 |
| 357 base::string16 FormatUrlForSecurityDisplay(const GURL& url) { | 360 base::string16 FormatUrlForSecurityDisplay(const GURL& url) { |
| 358 return FormatUrlForSecurityDisplayInternal(url, false); | 361 return FormatUrlForSecurityDisplayInternal(url, false); |
| 359 } | 362 } |
| 360 | 363 |
| 361 base::string16 FormatUrlForSecurityDisplayOmitScheme(const GURL& url) { | 364 base::string16 FormatUrlForSecurityDisplayOmitScheme(const GURL& url) { |
| 362 return FormatUrlForSecurityDisplayInternal(url, true); | 365 return FormatUrlForSecurityDisplayInternal(url, true); |
| 363 } | 366 } |
| 364 | 367 |
| 365 } // namespace url_formatter | 368 } // namespace url_formatter |
| OLD | NEW |