OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_BROWSING_DATA_ORIGIN_FILTER_BUILDER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_ORIGIN_FILTER_BUILDER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_ORIGIN_FILTER_BUILDER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_ORIGIN_FILTER_BUILDER_H_ |
7 | 7 |
8 #include <ostream> | 8 #include <ostream> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 14 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 #include "url/origin.h" | 16 #include "url/origin.h" |
17 | 17 |
18 // A class that constructs URL deletion filters (represented as GURL->bool | 18 // A class that constructs URL deletion filters (represented as GURL->bool |
19 // predicates) that match certain origins. | 19 // predicates) that match certain origins. |
20 // | 20 // |
21 // IMPORTANT NOTE: While this class does define cookie and channel IDs filtering | 21 // IMPORTANT NOTE: While this class does define cookie, channel ID, and plugin |
22 // methods, as required by the BrowsingDataFilterBuilder interface, it is not | 22 // filtering methods, as required by the BrowsingDataFilterBuilder interface, |
23 // suitable for deletion of those data types, as they are scoped to eTLD+1. | 23 // it is not suitable for deletion of those data types, as they are scoped |
24 // Instead, use RegistrableDomainFilterBuilder and see its documenation for | 24 // to eTLD+1. Instead, use RegistrableDomainFilterBuilder and see its |
25 // more details. | 25 // documenation for more details. |
26 class OriginFilterBuilder : public BrowsingDataFilterBuilder { | 26 class OriginFilterBuilder : public BrowsingDataFilterBuilder { |
27 public: | 27 public: |
28 // Constructs a filter with the given |mode| - whitelist or blacklist. | 28 // Constructs a filter with the given |mode| - whitelist or blacklist. |
29 explicit OriginFilterBuilder(Mode mode); | 29 explicit OriginFilterBuilder(Mode mode); |
30 | 30 |
31 ~OriginFilterBuilder() override; | 31 ~OriginFilterBuilder() override; |
32 | 32 |
33 // Adds the |origin| to the (white- or black-) list. | 33 // Adds the |origin| to the (white- or black-) list. |
34 void AddOrigin(const url::Origin& origin); | 34 void AddOrigin(const url::Origin& origin); |
35 | 35 |
(...skipping 16 matching lines...) Expand all Loading... |
52 // such as RegistrableDomainFilterBuilder. | 52 // such as RegistrableDomainFilterBuilder. |
53 base::Callback<bool(const net::CanonicalCookie& cookie)> | 53 base::Callback<bool(const net::CanonicalCookie& cookie)> |
54 BuildCookieFilter() const override; | 54 BuildCookieFilter() const override; |
55 | 55 |
56 // Channel ID filter is not implemented in this subclasss. Please use | 56 // Channel ID filter is not implemented in this subclasss. Please use |
57 // a BrowsingDataFilterBuilder with different scoping, | 57 // a BrowsingDataFilterBuilder with different scoping, |
58 // such as RegistrableDomainFilterBuilder. | 58 // such as RegistrableDomainFilterBuilder. |
59 base::Callback<bool(const std::string& channel_id_server_id)> | 59 base::Callback<bool(const std::string& channel_id_server_id)> |
60 BuildChannelIDFilter() const override; | 60 BuildChannelIDFilter() const override; |
61 | 61 |
| 62 // Plugin site filter is not implemented in this subclass. Please use |
| 63 // a BrowsingDataFilterBuilder with different scoping, |
| 64 // such as RegistrableDomainFilterBuilder. |
| 65 base::Callback<bool(const std::string& site)> |
| 66 BuildPluginFilter() const override; |
| 67 |
62 bool operator==(const OriginFilterBuilder& other) const; | 68 bool operator==(const OriginFilterBuilder& other) const; |
63 | 69 |
64 protected: | 70 protected: |
65 bool IsEmpty() const override; | 71 bool IsEmpty() const override; |
66 | 72 |
67 private: | 73 private: |
68 // True if the origin of |url| is in the whitelist, or isn't in the blacklist. | 74 // True if the origin of |url| is in the whitelist, or isn't in the blacklist. |
69 // The whitelist or blacklist is represented as |origins| and |mode|. | 75 // The whitelist or blacklist is represented as |origins| and |mode|. |
70 static bool MatchesURL( | 76 static bool MatchesURL( |
71 std::set<url::Origin>* origins, Mode mode, const GURL& url); | 77 std::set<url::Origin>* origins, Mode mode, const GURL& url); |
72 | 78 |
73 // True if the |pattern| is identical to one of the |origin_patterns|. | 79 // True if the |pattern| is identical to one of the |origin_patterns|. |
74 static bool MatchesWebsiteSettingsPattern( | 80 static bool MatchesWebsiteSettingsPattern( |
75 std::vector<ContentSettingsPattern>* origin_patterns, | 81 std::vector<ContentSettingsPattern>* origin_patterns, |
76 Mode mode, | 82 Mode mode, |
77 const ContentSettingsPattern& pattern); | 83 const ContentSettingsPattern& pattern); |
78 | 84 |
79 // The list of origins and whether they should be interpreted as a whitelist | 85 // The list of origins and whether they should be interpreted as a whitelist |
80 // or blacklist. | 86 // or blacklist. |
81 std::set<url::Origin> origin_list_; | 87 std::set<url::Origin> origin_list_; |
82 | 88 |
83 DISALLOW_COPY_AND_ASSIGN(OriginFilterBuilder); | 89 DISALLOW_COPY_AND_ASSIGN(OriginFilterBuilder); |
84 }; | 90 }; |
85 | 91 |
86 #endif // CHROME_BROWSER_BROWSING_DATA_ORIGIN_FILTER_BUILDER_H_ | 92 #endif // CHROME_BROWSER_BROWSING_DATA_ORIGIN_FILTER_BUILDER_H_ |
OLD | NEW |