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

Unified Diff: chrome/browser/browsing_data/browsing_data_remover_filter.h

Issue 1741123002: Add removal filter support for Cookies, Storage, and Content Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed class, comments Created 4 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: chrome/browser/browsing_data/browsing_data_remover_filter.h
diff --git a/chrome/browser/browsing_data/browsing_data_remover_filter.h b/chrome/browser/browsing_data/browsing_data_remover_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a9b6e677af4b1d18b8f40d523cd487d5a5624cd
--- /dev/null
+++ b/chrome/browser/browsing_data/browsing_data_remover_filter.h
@@ -0,0 +1,129 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_FILTER_H_
+#define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_FILTER_H_
+
+#include <ostream>
+#include <set>
+#include <vector>
+
+#include "base/callback.h"
+#include "net/cookies/canonical_cookie.h"
+#include "url/gurl.h"
+#include "url/origin.h"
+
+class ContentSettingsPattern;
+
+// A class that constructs URL deletion filters (represented as GURL->bool
+// predicates) that match origins or domains.
+//
+// Important note about cookies:
+// Cookies are domain-scoped, and websites often rely on cookies that are living
+// on various subdomains. For example, plus.google.com relies on google.com
+// cookies, which eventually talks to account.google.com cookies for GAIA
+// account auth. This means that when we save cookies for an origin, we need
+// to save all cookies for the TLD+1. This means blacklisting (or whitelisting)
+// https://plus.google.com will have us save (or delete) any cookies for
+// *.google.com (http://www.google.com, https://accounts.google.com, etc).
+//
+// See net/base/registry_controlled_domains/registry_controlled_domain.h for
+// more details on registrable domains and the current list of effective TLDs.
+class BrowsingDataRemoverFilter {
+ public:
+ enum Mode {
+ // This means that only the origins given will be deleted.
+ WHITELIST,
+ // Everyone EXCEPT the origins given will be deleted.
+ BLACKLIST
+ };
+
+ // Constructs a filter with the given |mode| - whitelist or blacklist.
+ explicit BrowsingDataRemoverFilter(Mode mode);
+
+ ~BrowsingDataRemoverFilter();
+
+ // Adds the |origin| to the (white- or black-) list.
+ void AddOrigin(const url::Origin& origin);
+
+ // Adds a registerable domain to the (white- or black-) list. This is expected
+ // to not include subdomains, so basically tld+1. Please see
+ // net/base/registry_controlled_domains/registry_controlled_domain.h
+ // for more details on registrable domains and the current list of effective
+ // TLDs. We expect a string that would be returned by
+ // net::registry_controlled_domains::GetDomainAndRegistry.
+ void AddRegisterableDomain(const std::string& domain);
+
+ // Sets the |mode| of the filter.
+ void SetMode(Mode mode);
+
+ // Returns true if we're an empty blacklist, where we delete everything.
+ bool IsEmptyBlacklist() const;
+
+ // Builds a filter that matches URLs whose origins or domains are in the
+ // whitelist, or aren't in the blacklist.
+ base::Callback<bool(const GURL&)> BuildSameOriginOrDomainFilter() const;
+
+ // Builds a filter that calls ContentSettingsPattern::Matches on the origins
+ // or domains in this filter.
+ base::Callback<bool(const ContentSettingsPattern& pattern)>
+ BuildWebsiteSettingsPatternMatchesFilter() const;
+
+ // If the filter contains origins, this builds a filter that compares the
+ // registerable domain of the filter's origins and the registrable domain of
+ // the cookie's domain. For domains in the filter, we just do a direct
+ // comparison to the registerable domain of the cookie's domain.
+ // A whitelist filter will return true if any of its origins or domains match
+ // the cookie. A blacklist filter will return true only if none of its origins
+ // or domains match the cookie.
+ // For na origin example, a whitelist which contains the origin
+ // "https://site.example.com/" will return true for a cookie whose domain is
+ // "site.example.com", but also for cookies whose domains are "example.com",
+ // ".example.com", "subdomain.example.com" and so on (with any scheme).
+ //
+ // See net/base/registry_controlled_domains/registry_controlled_domain.h for
+ // more details on registrable domains and the current list of effective TLDs.
+ base::Callback<bool(const net::CanonicalCookie& pattern)>
+ BuildDomainCookieFilter() const;
+
+ // A convenience method to produce an empty blacklist, a filter that matches
+ // everything.
+ static base::Callback<bool(const GURL&)> BuildNoopFilter();
+
+ private:
+ // True if the origin or domain of |url| is in the whitelist, or isn't in the
+ // blacklist.
+ // The whitelist or blacklist is represented as |origins| and |mode|.
+ static bool MatchesURL(std::set<url::Origin>* origins,
+ std::set<std::string>* registerable_domains,
+ Mode mode,
+ const GURL& url);
+
+ // True if the pattern something in the whitelist, or doesn't match something
+ // in the blacklist.
+ // The whitelist or blacklist is represented as |origins|, and |mode|.
+ static bool MatchesWebsiteSettingsPattern(
+ std::set<url::Origin>* origins,
+ std::vector<ContentSettingsPattern>* domain_patterns,
+ Mode mode,
+ const ContentSettingsPattern& pattern);
+
+ // True if no origins can see the given cookie and we're a blacklist, or any
+ // origins can see the cookie and we're a whitelist.
+ // The whitelist or blacklist is represented as |origins| and |mode|.
+ static bool MatchesCookieForRegisterableDomainsAndIPs(
+ std::set<std::string>* domains_and_ips,
+ Mode mode,
+ const net::CanonicalCookie& cookie);
+
+ // The list of origins & domains, and whether they should be interpreted as a
+ // whitelist or blacklist.
+ std::set<url::Origin> origin_list_;
+ std::set<std::string> domain_list_;
+ Mode mode_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverFilter);
+};
+
+#endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_FILTER_H_

Powered by Google App Engine
This is Rietveld 408576698