| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 std::string NormalizeHostname(const std::string& host) { | 150 std::string NormalizeHostname(const std::string& host) { |
| 151 std::string result = base::StringToLowerASCII(host); | 151 std::string result = base::StringToLowerASCII(host); |
| 152 if (!result.empty() && *result.rbegin() == '.') | 152 if (!result.empty() && *result.rbegin() == '.') |
| 153 result.resize(result.size() - 1); | 153 result.resize(result.size() - 1); |
| 154 return result; | 154 return result; |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool IsNormalizedLocalhostTLD(const std::string& host) { | 157 bool IsNormalizedLocalhostTLD(const std::string& host) { |
| 158 return base::EndsWith(host, ".localhost", true); | 158 return base::EndsWith(host, ".localhost", base::CompareCase::SENSITIVE); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // |host| should be normalized. | 161 // |host| should be normalized. |
| 162 bool IsLocalHostname(const std::string& host) { | 162 bool IsLocalHostname(const std::string& host) { |
| 163 return host == "localhost" || host == "localhost.localdomain" || | 163 return host == "localhost" || host == "localhost.localdomain" || |
| 164 IsNormalizedLocalhostTLD(host); | 164 IsNormalizedLocalhostTLD(host); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // |host| should be normalized. | 167 // |host| should be normalized. |
| 168 bool IsLocal6Hostname(const std::string& host) { | 168 bool IsLocal6Hostname(const std::string& host) { |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 ".googlevideo.com", | 825 ".googlevideo.com", |
| 826 ".googleusercontent.com", | 826 ".googleusercontent.com", |
| 827 ".googlesyndication.com", | 827 ".googlesyndication.com", |
| 828 ".google-analytics.com", | 828 ".google-analytics.com", |
| 829 ".googleadservices.com", | 829 ".googleadservices.com", |
| 830 ".googleapis.com", | 830 ".googleapis.com", |
| 831 ".ytimg.com", | 831 ".ytimg.com", |
| 832 }; | 832 }; |
| 833 const std::string& host = url.host(); | 833 const std::string& host = url.host(); |
| 834 for (const char* suffix : kGoogleHostSuffixes) { | 834 for (const char* suffix : kGoogleHostSuffixes) { |
| 835 if (base::EndsWith(host, suffix, false)) | 835 if (base::EndsWith(host, suffix, base::CompareCase::INSENSITIVE_ASCII)) |
| 836 return true; | 836 return true; |
| 837 } | 837 } |
| 838 return false; | 838 return false; |
| 839 } | 839 } |
| 840 | 840 |
| 841 } // namespace net | 841 } // namespace net |
| OLD | NEW |