Chromium Code Reviews| Index: components/ssl_errors/error_classification.cc |
| diff --git a/components/ssl_errors/error_classification.cc b/components/ssl_errors/error_classification.cc |
| index c61b3262aca91ceeb9df8e5f83ba5a1fa6e209a4..9f6c1db0d1877a763d39bcd0b2d9377aa44897ee 100644 |
| --- a/components/ssl_errors/error_classification.cc |
| +++ b/components/ssl_errors/error_classification.cc |
| @@ -73,7 +73,7 @@ std::vector<HostnameTokens> GetTokenizedDNSNames( |
| for (const auto& dns_name : dns_names) { |
| HostnameTokens dns_name_token_single; |
| if (dns_name.empty() || dns_name.find('\0') != std::string::npos || |
| - !(IsHostNameKnownTLD(dns_name))) { |
| + !(HostNameHasKnownTLD(dns_name))) { |
|
Peter Kasting
2016/10/25 01:33:32
Nit: Remove extra parens
|
| dns_name_token_single.push_back(std::string()); |
| } else { |
| dns_name_token_single = Tokenize(dns_name); |
| @@ -148,7 +148,7 @@ void RecordUMAStatistics(bool overridable, |
| } |
| case ssl_errors::ErrorInfo::CERT_COMMON_NAME_INVALID: { |
| std::string host_name = request_url.host(); |
| - if (IsHostNameKnownTLD(host_name)) { |
| + if (HostNameHasKnownTLD(host_name)) { |
| HostnameTokens host_name_tokens = Tokenize(host_name); |
| if (IsWWWSubDomainMatch(request_url, cert)) |
| RecordSSLInterstitialCause(overridable, WWW_SUBDOMAIN_MATCH); |
| @@ -278,13 +278,11 @@ void SetBuildTimeForTesting(const base::Time& testing_time) { |
| g_testing_build_time.Get() = testing_time; |
| } |
| -bool IsHostNameKnownTLD(const std::string& host_name) { |
| - size_t tld_length = net::registry_controlled_domains::GetRegistryLength( |
| - host_name, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| +bool HostNameHasKnownTLD(const std::string& host_name) { |
| + return net::registry_controlled_domains::HostHasRegistryControlledDomain( |
| + host_name, |
| + net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| - if (tld_length == 0 || tld_length == std::string::npos) |
| - return false; |
| - return true; |
| } |
| HostnameTokens Tokenize(const std::string& name) { |
| @@ -297,12 +295,12 @@ bool GetWWWSubDomainMatch(const GURL& request_url, |
| std::string* www_match_host_name) { |
| const std::string& host_name = request_url.host(); |
| - if (IsHostNameKnownTLD(host_name)) { |
| + if (HostNameHasKnownTLD(host_name)) { |
| // Need to account for all possible domains given in the SSL certificate. |
| for (const auto& dns_name : dns_names) { |
| if (dns_name.empty() || dns_name.find('\0') != std::string::npos || |
| dns_name.length() == host_name.length() || |
| - !IsHostNameKnownTLD(dns_name)) { |
| + !HostNameHasKnownTLD(dns_name)) { |
| continue; |
| } else if (dns_name.length() > host_name.length()) { |
| if (url_formatter::StripWWW(base::ASCIIToUTF16(dns_name)) == |
| @@ -393,7 +391,7 @@ bool IsSubDomainOutsideWildcard(const GURL& request_url, |
| for (const auto& dns_name : dns_names) { |
| if (dns_name.length() < 2 || dns_name.length() >= host_name.length() || |
| dns_name.find('\0') != std::string::npos || |
| - !IsHostNameKnownTLD(dns_name) || dns_name[0] != '*' || |
| + !HostNameHasKnownTLD(dns_name) || dns_name[0] != '*' || |
| dns_name[1] != '.') { |
| continue; |
| } |