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 !registry_controlled_domains::HostHasRegistryControlledDomain( | 345 return 0 == registry_controlled_domains::GetRegistryLength( |
346 canonical_name, registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, | 346 canonical_name, |
347 registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 347 registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, |
| 348 registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
348 } | 349 } |
349 | 350 |
350 bool IsLocalhost(base::StringPiece host) { | 351 bool IsLocalhost(base::StringPiece host) { |
351 if (IsLocalHostname(host, nullptr)) | 352 if (IsLocalHostname(host, nullptr)) |
352 return true; | 353 return true; |
353 | 354 |
354 IPAddress ip_address; | 355 IPAddress ip_address; |
355 if (ip_address.AssignFromIPLiteral(host)) { | 356 if (ip_address.AssignFromIPLiteral(host)) { |
356 size_t size = ip_address.size(); | 357 size_t size = ip_address.size(); |
357 switch (size) { | 358 switch (size) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 431 } |
431 | 432 |
432 if (is_local6) | 433 if (is_local6) |
433 *is_local6 = false; | 434 *is_local6 = false; |
434 return normalized_host == "localhost" || | 435 return normalized_host == "localhost" || |
435 normalized_host == "localhost.localdomain" || | 436 normalized_host == "localhost.localdomain" || |
436 IsNormalizedLocalhostTLD(normalized_host); | 437 IsNormalizedLocalhostTLD(normalized_host); |
437 } | 438 } |
438 | 439 |
439 } // namespace net | 440 } // namespace net |
OLD | NEW |