OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/url_util.h" | 5 #include "net/base/url_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <netinet/in.h> | 10 #include <netinet/in.h> |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 335 |
336 // Check for a registry controlled portion of |hostname|, ignoring private | 336 // Check for a registry controlled portion of |hostname|, ignoring private |
337 // registries, as they already chain to ICANN-administered registries, | 337 // registries, as they already chain to ICANN-administered registries, |
338 // and explicitly ignoring unknown registries. | 338 // and explicitly ignoring unknown registries. |
339 // | 339 // |
340 // Note: This means that as new gTLDs are introduced on the Internet, they | 340 // Note: This means that as new gTLDs are introduced on the Internet, they |
341 // will be treated as non-unique until the registry controlled domain list | 341 // will be treated as non-unique until the registry controlled domain list |
342 // is updated. However, because gTLDs are expected to provide significant | 342 // is updated. However, because gTLDs are expected to provide significant |
343 // advance notice to deprecate older versions of this code, this an | 343 // advance notice to deprecate older versions of this code, this an |
344 // acceptable tradeoff. | 344 // acceptable tradeoff. |
345 return 0 == registry_controlled_domains::GetRegistryLength( | 345 return !registry_controlled_domains::HostHasRegistryControlledDomain( |
346 canonical_name, | 346 canonical_name, registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
347 registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 347 registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
348 registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | |
349 } | 348 } |
350 | 349 |
351 bool IsLocalhost(base::StringPiece host) { | 350 bool IsLocalhost(base::StringPiece host) { |
352 if (IsLocalHostname(host, nullptr)) | 351 if (IsLocalHostname(host, nullptr)) |
353 return true; | 352 return true; |
354 | 353 |
355 IPAddress ip_address; | 354 IPAddress ip_address; |
356 if (ip_address.AssignFromIPLiteral(host)) { | 355 if (ip_address.AssignFromIPLiteral(host)) { |
357 size_t size = ip_address.size(); | 356 size_t size = ip_address.size(); |
358 switch (size) { | 357 switch (size) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 430 } |
432 | 431 |
433 if (is_local6) | 432 if (is_local6) |
434 *is_local6 = false; | 433 *is_local6 = false; |
435 return normalized_host == "localhost" || | 434 return normalized_host == "localhost" || |
436 normalized_host == "localhost.localdomain" || | 435 normalized_host == "localhost.localdomain" || |
437 IsNormalizedLocalhostTLD(normalized_host); | 436 IsNormalizedLocalhostTLD(normalized_host); |
438 } | 437 } |
439 | 438 |
440 } // namespace net | 439 } // namespace net |
OLD | NEW |