Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef URL_ORIGIN_FILTER_H_ | |
| 6 #define URL_ORIGIN_FILTER_H_ | |
| 7 | |
| 8 #include <ostream> | |
| 9 #include <set> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "url/gurl.h" | |
| 13 #include "url/origin.h" | |
| 14 | |
| 15 namespace url { | |
| 16 | |
| 17 // A utility class to filter browsing data over origins. | |
| 18 // Unique origins are ignored. | |
| 19 class URL_EXPORT OriginFilter { | |
| 20 public: | |
| 21 // A filter that only matches |origins|. | |
| 22 static scoped_ptr<OriginFilter> AsWhitelist( | |
| 23 const std::vector<Origin>& origins); | |
| 24 | |
| 25 // A filter that matches everything except |origins|. | |
| 26 static scoped_ptr<OriginFilter> AsBlacklist( | |
| 27 const std::vector<Origin>& origins); | |
| 28 | |
| 29 // An empty filter that matches everything. Equivalent to an empty blacklist. | |
| 30 static scoped_ptr<OriginFilter> Empty(); | |
| 31 | |
| 32 ~OriginFilter(); | |
| 33 | |
| 34 // True if the origin of |url| is in the whitelist, or isn't in the blacklist. | |
| 35 bool MatchesURL(const GURL& url) const; | |
| 36 | |
| 37 // True if any origin [scheme, host, port], such that |url| has the same | |
| 38 // scheme and port, and |url|'s host is the same or a subdomain of that host, | |
| 39 // is in the whitelist, or isn't in the blacklist. | |
| 40 bool MatchesURLWithSubdomains(const GURL& url) const; | |
| 41 | |
| 42 // Whether two filters match the same origins. | |
| 43 bool operator==(const OriginFilter& other) const; | |
|
brettw
2016/02/01 22:48:25
Why do we need to do this comparison?
msramek
2016/02/05 17:16:35
It was used in a gmock matcher. The test that used
| |
| 44 bool operator!=(const OriginFilter& other) const; | |
| 45 | |
| 46 private: | |
| 47 URL_EXPORT friend std::ostream& operator<<(std::ostream& out, | |
| 48 const OriginFilter& filter); | |
| 49 | |
| 50 OriginFilter(const std::vector<Origin>& origins, bool whitelist_mode); | |
| 51 | |
| 52 // The list of origins and whether they should be interpreted as a whitelist | |
| 53 // or blacklist. | |
| 54 std::set<Origin> origin_list_; | |
| 55 bool whitelist_mode_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(OriginFilter); | |
| 58 }; | |
| 59 | |
| 60 URL_EXPORT std::ostream& operator<<( | |
| 61 std::ostream& out, const OriginFilter& filter); | |
| 62 | |
| 63 } // namespace url | |
| 64 | |
| 65 #endif // URL_ORIGIN_FILTER_H_ | |
| OLD | NEW |