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

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

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.h
diff --git a/net/base/registry_controlled_domains/registry_controlled_domain.h b/net/base/registry_controlled_domains/registry_controlled_domain.h
index f1d9a1185ce6f88d0134ea34782447eb67d075df..51f905df34d8e58f205782c620c6cc3cec301a2f 100644
--- a/net/base/registry_controlled_domains/registry_controlled_domain.h
+++ b/net/base/registry_controlled_domains/registry_controlled_domain.h
@@ -124,8 +124,39 @@ struct DomainRule;
namespace net {
+class RegistryControlledDomainService;
+typedef RegistryControlledDomainService RCDS;
Ryan Sleevi 2013/04/26 19:39:59 So I realize pam@ made the suggestion that this is
Pam (message me for reviews) 2013/04/29 09:25:56 Any intrinsic considerations aside, I wouldn't cha
nyquist 2013/05/06 22:30:56 Changed to namespace, but used the same name as th
+
class NET_EXPORT RegistryControlledDomainService {
public:
+ // This enum is a required parameter to all public methods declared for this
+ // service. The Public Suffix List (http://publicsuffix.org/) this service
+ // uses as a data source splits all effective-TLDs into two groups. The main
+ // group describes registries that are acknowledged by ICANN. The second group
+ // contains a list of private additions for domains that enable external users
+ // to create subdomains, such as appspot.com.
+ // The RegistryFilter enum lets you choose whether you want to include the
+ // private additions in your lookup.
+ // See this for example use cases:
+ // https://wiki.mozilla.org/Public_Suffix_List/Use_Cases
+ enum PrivateRegistryFilter {
+ EXCLUDE_PRIVATE_REGISTRIES = 0,
+ INCLUDE_PRIVATE_REGISTRIES
+ };
+
+ // This enum is a required parameter to the GetRegistryLength functions
+ // declared for this service. Whenever there is no matching rule in the
+ // effective-TLD data (or in the default data, if the resource failed to
+ // load), the result will be dependent on which enum value was passed in.
+ // If EXCLUDE_UNKNOWN_REGISTRIES was passed in, the resulting registry length
+ // will be 0. If INCLUDE_UNKNOWN_REGISTRIES was passed in, the resulting
+ // registry length will be the length of the last subcomponent (eg. 3 for
+ // foobar.baz).
+ enum UnknownRegistryFilter {
+ EXCLUDE_UNKNOWN_REGISTRIES = 0,
+ INCLUDE_UNKNOWN_REGISTRIES
+ };
+
// Returns the registered, organization-identifying host and all its registry
// information, but no subdomains, from the given GURL. Returns an empty
// string if the GURL is invalid, has no host (e.g. a file: URL), has multiple
@@ -146,11 +177,13 @@ class NET_EXPORT RegistryControlledDomainService {
// http://bar/file.html -> "" (no subcomponents)
// http://co.uk/file.html -> "" (host is a registry)
// http://foo.bar/file.html -> "foo.bar" (no rule; assume bar)
- static std::string GetDomainAndRegistry(const GURL& gurl);
+ static std::string GetDomainAndRegistry(const GURL& gurl,
+ PrivateRegistryFilter filter);
// Like the GURL version, but takes a host (which is canonicalized internally)
// instead of a full GURL.
- static std::string GetDomainAndRegistry(const std::string& host);
+ static std::string GetDomainAndRegistry(const std::string& host,
+ PrivateRegistryFilter filter);
// This convenience function returns true if the two GURLs both have hosts
// and one of the following is true:
@@ -159,16 +192,18 @@ class NET_EXPORT RegistryControlledDomainService {
// * They don't have known domains/registries, but the hosts are identical.
// Effectively, callers can use this function to check whether the input URLs
// represent hosts "on the same site".
- static bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2);
+ static bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2,
+ PrivateRegistryFilter filter);
// Finds the length in bytes of the registrar portion of the host in the
// given GURL. Returns std::string::npos if the GURL is invalid or has no
// host (e.g. a file: URL). Returns 0 if the GURL has multiple trailing dots,
// is an IP address, has no subcomponents, or is itself a recognized registry
- // identifier. If no matching rule is found in the effective-TLD data (or in
+ // identifier. The result is also dependent on the UnknownRegistryFilter.
+ // If no matching rule is found in the effective-TLD data (or in
// the default data, if the resource failed to load), returns 0 if
- // |allow_unknown_registries| is false, or the length of the last subcomponent
- // if |allow_unknown_registries| is true.
+ // |unknown_filter| is EXCLUDE_UNKNOWN_REGISTRIES, or the length of the last
+ // subcomponent if |unknown_filter| is INCLUDE_UNKNOWN_REGISTRIES.
//
// Examples:
// http://www.google.com/file.html -> 3 (com)
@@ -184,20 +219,24 @@ class NET_EXPORT RegistryControlledDomainService {
// http://foo.bar/file.html -> 0 or 3, depending (no rule; assume
// bar)
static size_t GetRegistryLength(const GURL& gurl,
- bool allow_unknown_registries);
+ UnknownRegistryFilter unknown_filter,
+ PrivateRegistryFilter private_filter);
// Like the GURL version, but takes a host (which is canonicalized internally)
// instead of a full GURL.
static size_t GetRegistryLength(const std::string& host,
- bool allow_unknown_registries);
+ UnknownRegistryFilter unknown_filter,
+ PrivateRegistryFilter private_filter);
private:
friend class RegistryControlledDomainTest;
// Internal workings of the static public methods. See above.
- static std::string GetDomainAndRegistryImpl(const std::string& host);
+ static std::string GetDomainAndRegistryImpl(const std::string& host,
+ PrivateRegistryFilter filter);
static size_t GetRegistryLengthImpl(const std::string& host,
- bool allow_unknown_registries);
+ UnknownRegistryFilter unknown_filter,
+ PrivateRegistryFilter filter);
typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int);

Powered by Google App Engine
This is Rietveld 408576698