| Index: net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| diff --git a/net/base/registry_controlled_domains/registry_controlled_domain.cc b/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| index 513bbd7edaab7bc5c62bdbea04bc8e5992c6ab1f..4d29f882e334db85254e0059f9d9cc093a4da442 100644
|
| --- a/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| +++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc
|
| @@ -74,10 +74,9 @@ const char* const kDefaultStringPool = stringpool;
|
| FindDomainPtr g_find_domain_function = kDefaultFindDomainFunction;
|
| const char* g_stringpool = kDefaultStringPool;
|
|
|
| -size_t GetRegistryLengthImpl(
|
| - const std::string& host,
|
| - UnknownRegistryFilter unknown_filter,
|
| - PrivateRegistryFilter private_filter) {
|
| +size_t GetRegistryLengthImpl(const std::string& host,
|
| + UnknownRegistryFilter unknown_filter,
|
| + PrivateRegistryFilter private_filter) {
|
| DCHECK(!host.empty());
|
|
|
| // Skip leading dots.
|
| @@ -102,7 +101,7 @@ size_t GetRegistryLengthImpl(
|
| size_t curr_start = host_check_begin;
|
| size_t next_dot = host.find('.', curr_start);
|
| if (next_dot >= host_check_len) // Catches std::string::npos as well.
|
| - return 0; // This can't have a registry + domain.
|
| + return 0; // This can't have a registry + domain.
|
| while (1) {
|
| const char* domain_str = host.data() + curr_start;
|
| int domain_length = host_check_len - curr_start;
|
| @@ -116,16 +115,18 @@ size_t GetRegistryLengthImpl(
|
| if (rule) {
|
| bool do_check = !(rule->type & kPrivateRule) ||
|
| private_filter == INCLUDE_PRIVATE_REGISTRIES;
|
| - if (do_check && base::strncasecmp(domain_str,
|
| - g_stringpool + rule->name_offset,
|
| - domain_length) == 0) {
|
| + if (do_check &&
|
| + base::strncasecmp(domain_str,
|
| + g_stringpool + rule->name_offset,
|
| + domain_length) == 0) {
|
| // Exception rules override wildcard rules when the domain is an exact
|
| // match, but wildcards take precedence when there's a subdomain.
|
| if (rule->type & kWildcardRule && (prev_start != std::string::npos)) {
|
| // If prev_start == host_check_begin, then the host is the registry
|
| // itself, so return 0.
|
| - return (prev_start == host_check_begin) ?
|
| - 0 : (host.length() - prev_start);
|
| + return (prev_start == host_check_begin)
|
| + ? 0
|
| + : (host.length() - prev_start);
|
| }
|
|
|
| if (rule->type & kExceptionRule) {
|
| @@ -142,8 +143,8 @@ size_t GetRegistryLengthImpl(
|
|
|
| // If curr_start == host_check_begin, then the host is the registry
|
| // itself, so return 0.
|
| - return (curr_start == host_check_begin) ?
|
| - 0 : (host.length() - curr_start);
|
| + return (curr_start == host_check_begin) ? 0
|
| + : (host.length() - curr_start);
|
| }
|
| }
|
|
|
| @@ -158,12 +159,13 @@ size_t GetRegistryLengthImpl(
|
| // No rule found in the registry. curr_start now points to the first
|
| // character of the last subcomponent of the host, so if we allow unknown
|
| // registries, return the length of this subcomponent.
|
| - return unknown_filter == INCLUDE_UNKNOWN_REGISTRIES ?
|
| - (host.length() - curr_start) : 0;
|
| + return unknown_filter == INCLUDE_UNKNOWN_REGISTRIES
|
| + ? (host.length() - curr_start)
|
| + : 0;
|
| }
|
|
|
| -std::string GetDomainAndRegistryImpl(
|
| - const std::string& host, PrivateRegistryFilter private_filter) {
|
| +std::string GetDomainAndRegistryImpl(const std::string& host,
|
| + PrivateRegistryFilter private_filter) {
|
| DCHECK(!host.empty());
|
|
|
| // Find the length of the registry for this host.
|
| @@ -175,8 +177,8 @@ std::string GetDomainAndRegistryImpl(
|
| // subcomponent length.
|
| DCHECK(host.length() >= 2);
|
| if (registry_length > (host.length() - 2)) {
|
| - NOTREACHED() <<
|
| - "Host does not have at least one subcomponent before registry!";
|
| + NOTREACHED()
|
| + << "Host does not have at least one subcomponent before registry!";
|
| return std::string();
|
| }
|
|
|
| @@ -191,19 +193,18 @@ std::string GetDomainAndRegistryImpl(
|
|
|
| } // namespace
|
|
|
| -std::string GetDomainAndRegistry(
|
| - const GURL& gurl,
|
| - PrivateRegistryFilter filter) {
|
| +std::string GetDomainAndRegistry(const GURL& gurl,
|
| + PrivateRegistryFilter filter) {
|
| const url::Component host = gurl.parsed_for_possibly_invalid_spec().host;
|
| if ((host.len <= 0) || gurl.HostIsIPAddress())
|
| return std::string();
|
| - return GetDomainAndRegistryImpl(std::string(
|
| - gurl.possibly_invalid_spec().data() + host.begin, host.len), filter);
|
| + return GetDomainAndRegistryImpl(
|
| + std::string(gurl.possibly_invalid_spec().data() + host.begin, host.len),
|
| + filter);
|
| }
|
|
|
| -std::string GetDomainAndRegistry(
|
| - const std::string& host,
|
| - PrivateRegistryFilter filter) {
|
| +std::string GetDomainAndRegistry(const std::string& host,
|
| + PrivateRegistryFilter filter) {
|
| url::CanonHostInfo host_info;
|
| const std::string canon_host(CanonicalizeHost(host, &host_info));
|
| if (canon_host.empty() || host_info.IsIPAddress())
|
| @@ -211,10 +212,9 @@ std::string GetDomainAndRegistry(
|
| return GetDomainAndRegistryImpl(canon_host, filter);
|
| }
|
|
|
| -bool SameDomainOrHost(
|
| - const GURL& gurl1,
|
| - const GURL& gurl2,
|
| - PrivateRegistryFilter filter) {
|
| +bool SameDomainOrHost(const GURL& gurl1,
|
| + const GURL& gurl2,
|
| + PrivateRegistryFilter filter) {
|
| // See if both URLs have a known domain + registry, and those values are the
|
| // same.
|
| const std::string domain1(GetDomainAndRegistry(gurl1, filter));
|
| @@ -232,10 +232,9 @@ bool SameDomainOrHost(
|
| host1.len);
|
| }
|
|
|
| -size_t GetRegistryLength(
|
| - const GURL& gurl,
|
| - UnknownRegistryFilter unknown_filter,
|
| - PrivateRegistryFilter private_filter) {
|
| +size_t GetRegistryLength(const GURL& gurl,
|
| + UnknownRegistryFilter unknown_filter,
|
| + PrivateRegistryFilter private_filter) {
|
| const url::Component host = gurl.parsed_for_possibly_invalid_spec().host;
|
| if (host.len <= 0)
|
| return std::string::npos;
|
| @@ -247,10 +246,9 @@ size_t GetRegistryLength(
|
| private_filter);
|
| }
|
|
|
| -size_t GetRegistryLength(
|
| - const std::string& host,
|
| - UnknownRegistryFilter unknown_filter,
|
| - PrivateRegistryFilter private_filter) {
|
| +size_t GetRegistryLength(const std::string& host,
|
| + UnknownRegistryFilter unknown_filter,
|
| + PrivateRegistryFilter private_filter) {
|
| url::CanonHostInfo host_info;
|
| const std::string canon_host(CanonicalizeHost(host, &host_info));
|
| if (canon_host.empty())
|
|
|