| 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 ".googlevideo.com", | 794 ".googlevideo.com", |
| 795 ".googleusercontent.com", | 795 ".googleusercontent.com", |
| 796 ".googlesyndication.com", | 796 ".googlesyndication.com", |
| 797 ".google-analytics.com", | 797 ".google-analytics.com", |
| 798 ".googleadservices.com", | 798 ".googleadservices.com", |
| 799 ".googleapis.com", | 799 ".googleapis.com", |
| 800 ".ytimg.com", | 800 ".ytimg.com", |
| 801 }; | 801 }; |
| 802 const std::string& host = url.host(); | 802 const std::string& host = url.host(); |
| 803 for (const char* suffix : kGoogleHostSuffixes) { | 803 for (const char* suffix : kGoogleHostSuffixes) { |
| 804 if (base::EndsWith(host, suffix, false)) | 804 if (base::EndsWith(host, suffix, base::CompareCase::INSENSITIVE_ASCII)) |
| 805 return true; | 805 return true; |
| 806 } | 806 } |
| 807 return false; | 807 return false; |
| 808 } | 808 } |
| 809 | 809 |
| 810 } // namespace net | 810 } // namespace net |
| OLD | NEW |