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

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

Issue 2647683002: Consolidate Origin- and RegistrableDomain- FilterBuilder into one class (Closed)
Patch Set: Rebase. Created 3 years, 11 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_filter_builder.h
diff --git a/chrome/browser/browsing_data/browsing_data_filter_builder.h b/chrome/browser/browsing_data/browsing_data_filter_builder.h
index 878df03ae2873a2a921f0c3f7f6ed1a3fa816a17..835721f8774cd8fc10ad7222f655bb96a844cd0d 100644
--- a/chrome/browser/browsing_data/browsing_data_filter_builder.h
+++ b/chrome/browser/browsing_data/browsing_data_filter_builder.h
@@ -5,11 +5,13 @@
#ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILTER_BUILDER_H_
#define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILTER_BUILDER_H_
+#include <memory>
#include <ostream>
#include <set>
+#include <string>
#include <vector>
-#include "base/callback.h"
+#include "base/callback_forward.h"
class GURL;
@@ -17,10 +19,13 @@ namespace net {
class CanonicalCookie;
}
-// An abstract class that builds GURL->bool predicates to filter browsing data.
-// These filters can be of two modes - a whitelist or a blacklist. Different
-// subclasses can have different ways of defining the set of URLs - for example,
-// as domains or origins.
+namespace url {
+class Origin;
+}
+
+// An class that builds GURL->bool predicates to filter browsing data.
+// These filters can be of two modes - a whitelist or a blacklist. The filter
+// entries can be origins or registrable domains.
//
// This class defines interface to build filters for various kinds of browsing
// data. |BuildGeneralFilter()| is useful for most browsing data storage
@@ -36,32 +41,43 @@ class BrowsingDataFilterBuilder {
};
// Constructs a filter with the given |mode| - whitelist or blacklist.
- explicit BrowsingDataFilterBuilder(Mode mode);
+ static std::unique_ptr<BrowsingDataFilterBuilder> Create(Mode mode);
- virtual ~BrowsingDataFilterBuilder();
+ virtual ~BrowsingDataFilterBuilder() = default;
- // Sets the |mode| of the filter.
- void SetMode(Mode mode);
+ // Adds an origin to the filter. Note that this makes it impossible to
+ // create cookie, channel ID, or plugin filters, as those datatypes are
+ // scoped more broadly than an origin.
+ virtual void AddOrigin(const url::Origin& origin) = 0;
+
+ // Adds a registrable domain (e.g. google.com), an internal hostname
+ // (e.g. localhost), or an IP address (e.g. 127.0.0.1). Other domains, such
+ // as third and lower level domains (e.g. www.google.com) are not accepted.
+ // Formally, it must hold that GetDomainAndRegistry(|registrable_domain|, _)
+ // is |registrable_domain| itself or an empty string for this method
+ // to accept it.
+ virtual void AddRegisterableDomain(const std::string& registrable_domain) = 0;
// Returns true if we're an empty blacklist, where we delete everything.
- bool IsEmptyBlacklist() const;
+ virtual bool IsEmptyBlacklist() const = 0;
// Builds a filter that matches URLs that are in the whitelist,
// or aren't in the blacklist.
- virtual base::Callback<bool(const GURL&)> BuildGeneralFilter() const = 0;
+ virtual base::RepeatingCallback<bool(const GURL&)>
+ BuildGeneralFilter() const = 0;
// Builds a filter that matches cookies whose sources are in the whitelist,
// or aren't in the blacklist.
- virtual base::Callback<bool(const net::CanonicalCookie& pattern)>
+ virtual base::RepeatingCallback<bool(const net::CanonicalCookie& pattern)>
BuildCookieFilter() const = 0;
// Builds a filter that matches channel IDs whose server identifiers are in
// the whitelist, or aren't in the blacklist.
- virtual base::Callback<bool(const std::string& server_id)>
+ virtual base::RepeatingCallback<bool(const std::string& server_id)>
BuildChannelIDFilter() const = 0;
// Builds a filter that matches the |site| of a plugin.
- virtual base::Callback<bool(const std::string& site)>
+ virtual base::RepeatingCallback<bool(const std::string& site)>
BuildPluginFilter() const = 0;
// A convenience method to produce an empty blacklist, a filter that matches
@@ -69,16 +85,14 @@ class BrowsingDataFilterBuilder {
static base::Callback<bool(const GURL&)> BuildNoopFilter();
// The mode of the filter.
- Mode mode() const { return mode_; }
-
- protected:
- // Whether or not any URLs have been added to this builder.
- virtual bool IsEmpty() const = 0;
+ virtual Mode GetMode() const = 0;
- private:
- Mode mode_;
+ // Create a new filter builder with the same set of origins, set of domains,
+ // and mode.
+ virtual std::unique_ptr<BrowsingDataFilterBuilder> Copy() const = 0;
- DISALLOW_COPY_AND_ASSIGN(BrowsingDataFilterBuilder);
+ // Comparison.
+ virtual bool operator==(const BrowsingDataFilterBuilder& other) const = 0;
};
#endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILTER_BUILDER_H_

Powered by Google App Engine
This is Rietveld 408576698