Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: net/base/registry_controlled_domains/registry_controlled_domain.cc

Issue 13979002: Add support for split PSL list distinctions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed chrome_frame compilation issue Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a20af0805a4c9dd58f49016e8ff0cbdfc4d2f613..d9bf58e544c1bc458a0291004a989da8822951ef 100644
--- a/net/base/registry_controlled_domains/registry_controlled_domain.cc
+++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc
@@ -70,32 +70,32 @@ RegistryControlledDomainService::find_domain_function_ =
// static
std::string RegistryControlledDomainService::GetDomainAndRegistry(
- const GURL& gurl) {
+ const GURL& gurl, PrivateRegistryFilter filter) {
Ryan Sleevi 2013/04/26 19:39:59 According to clang-format & chromium style, this s
nyquist 2013/05/06 22:30:56 Done.
const url_parse::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));
+ gurl.possibly_invalid_spec().data() + host.begin, host.len), filter);
}
// static
std::string RegistryControlledDomainService::GetDomainAndRegistry(
- const std::string& host) {
+ const std::string& host, PrivateRegistryFilter filter) {
Ryan Sleevi 2013/04/26 19:39:59 same
nyquist 2013/05/06 22:30:56 Done.
url_canon::CanonHostInfo host_info;
const std::string canon_host(CanonicalizeHost(host, &host_info));
if (canon_host.empty() || host_info.IsIPAddress())
return std::string();
- return GetDomainAndRegistryImpl(canon_host);
+ return GetDomainAndRegistryImpl(canon_host, filter);
}
// static
-bool RegistryControlledDomainService::SameDomainOrHost(const GURL& gurl1,
- const GURL& gurl2) {
+bool RegistryControlledDomainService::SameDomainOrHost(
+ const GURL& gurl1, const GURL& gurl2, PrivateRegistryFilter filter) {
Ryan Sleevi 2013/04/26 19:39:59 rinse repeat one param per line throughout.
nyquist 2013/05/06 22:30:56 Done.
// See if both URLs have a known domain + registry, and those values are the
// same.
- const std::string domain1(GetDomainAndRegistry(gurl1));
- const std::string domain2(GetDomainAndRegistry(gurl2));
+ const std::string domain1(GetDomainAndRegistry(gurl1, filter));
+ const std::string domain2(GetDomainAndRegistry(gurl2, filter));
if (!domain1.empty() || !domain2.empty())
return domain1 == domain2;
@@ -114,7 +114,8 @@ bool RegistryControlledDomainService::SameDomainOrHost(const GURL& gurl1,
// static
size_t RegistryControlledDomainService::GetRegistryLength(
const GURL& gurl,
- bool allow_unknown_registries) {
+ UnknownRegistryFilter unknown_filter,
+ PrivateRegistryFilter private_filter) {
const url_parse::Component host =
gurl.parsed_for_possibly_invalid_spec().host;
if (host.len <= 0)
@@ -123,20 +124,22 @@ size_t RegistryControlledDomainService::GetRegistryLength(
return 0;
return GetRegistryLengthImpl(
std::string(gurl.possibly_invalid_spec().data() + host.begin, host.len),
- allow_unknown_registries);
+ unknown_filter,
+ private_filter);
}
// static
size_t RegistryControlledDomainService::GetRegistryLength(
const std::string& host,
- bool allow_unknown_registries) {
+ UnknownRegistryFilter unknown_filter,
+ PrivateRegistryFilter private_filter) {
url_canon::CanonHostInfo host_info;
const std::string canon_host(CanonicalizeHost(host, &host_info));
if (canon_host.empty())
return std::string::npos;
if (host_info.IsIPAddress())
return 0;
- return GetRegistryLengthImpl(canon_host, allow_unknown_registries);
+ return GetRegistryLengthImpl(canon_host, unknown_filter, private_filter);
}
// static
@@ -147,11 +150,12 @@ void RegistryControlledDomainService::UseFindDomainFunction(
// static
std::string RegistryControlledDomainService::GetDomainAndRegistryImpl(
- const std::string& host) {
+ const std::string& host, PrivateRegistryFilter private_filter) {
DCHECK(!host.empty());
// Find the length of the registry for this host.
- const size_t registry_length = GetRegistryLengthImpl(host, true);
+ const size_t registry_length =
+ GetRegistryLengthImpl(host, INCLUDE_UNKNOWN_REGISTRIES, private_filter);
if ((registry_length == std::string::npos) || (registry_length == 0))
return std::string(); // No registry.
// The "2" in this next line is 1 for the dot, plus a 1-char minimum preceding
@@ -174,7 +178,8 @@ std::string RegistryControlledDomainService::GetDomainAndRegistryImpl(
size_t RegistryControlledDomainService::GetRegistryLengthImpl(
const std::string& host,
- bool allow_unknown_registries) {
+ UnknownRegistryFilter unknown_filter,
+ PrivateRegistryFilter private_filter) {
DCHECK(!host.empty());
// Skip leading dots.
@@ -208,7 +213,10 @@ size_t RegistryControlledDomainService::GetRegistryLengthImpl(
// We need to compare the string after finding a match because the
// no-collisions of perfect hashing only refers to items in the set. Since
// we're searching for arbitrary domains, there could be collisions.
+ // Furthermore, if the apparent match is a private registry and we're not
+ // including those, it can't be an actual match.
if (rule &&
+ (private_filter == INCLUDE_PRIVATE_REGISTRIES || !rule->is_private) &&
base::strncasecmp(domain_str, rule->name, domain_length) == 0) {
// Exception rules override wildcard rules when the domain is an exact
// match, but wildcards take precedence when there's a subdomain.
@@ -248,7 +256,8 @@ size_t RegistryControlledDomainService::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 allow_unknown_registries ? (host.length() - curr_start) : 0;
+ return unknown_filter == INCLUDE_UNKNOWN_REGISTRIES ?
+ (host.length() - curr_start) : 0;
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698