| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_PRIVACY_BLACKLIST_BLACKLIST_H_ | 5 #ifndef CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_ |
| 6 #define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_ | 6 #define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // | 25 // |
| 26 // TODO(idanan): Implement this efficiently. | 26 // TODO(idanan): Implement this efficiently. |
| 27 // To get things started, the initial implementation is as simple as | 27 // To get things started, the initial implementation is as simple as |
| 28 // it gets and cannot scale to large blacklists but it should be enough | 28 // it gets and cannot scale to large blacklists but it should be enough |
| 29 // for testing on the order of a hundred or so entries. | 29 // for testing on the order of a hundred or so entries. |
| 30 // | 30 // |
| 31 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
| 32 class Blacklist { | 32 class Blacklist { |
| 33 public: | 33 public: |
| 34 // Filter attributes (more to come): | 34 // Filter attributes (more to come): |
| 35 static const unsigned int kBlockAll = 1; | 35 static const unsigned int kBlockAll; |
| 36 static const unsigned int kDontSendCookies = 1 << 1; | 36 static const unsigned int kDontSendCookies; |
| 37 static const unsigned int kDontStoreCookies = 1 << 2; | 37 static const unsigned int kDontStoreCookies; |
| 38 static const unsigned int kDontPersistCookies = 1 << 3; | 38 static const unsigned int kDontPersistCookies; |
| 39 static const unsigned int kDontSendReferrer = 1 << 4; | 39 static const unsigned int kDontSendReferrer; |
| 40 static const unsigned int kDontSendUserAgent = 1 << 5; | 40 static const unsigned int kDontSendUserAgent; |
| 41 static const unsigned int kBlockByType = 1 << 6; | 41 static const unsigned int kBlockByType; |
| 42 static const unsigned int kBlockUnsecure = 1 << 7; | 42 static const unsigned int kBlockUnsecure; |
| 43 | 43 |
| 44 // Aggregate filter types: | 44 // Aggregate filter types: |
| 45 static const unsigned int kBlockRequest = kBlockAll | kBlockUnsecure; | 45 static const unsigned int kBlockRequest; |
| 46 static const unsigned int kBlockResponse = kBlockByType; | 46 static const unsigned int kBlockResponse; |
| 47 static const unsigned int kModifySentHeaders = | 47 static const unsigned int kModifySentHeaders; |
| 48 kDontSendCookies | kDontSendUserAgent | kDontSendReferrer; | 48 static const unsigned int kModifyReceivedHeaders; |
| 49 static const unsigned int kModifyReceivedHeaders = | 49 static const unsigned int kFilterByHeaders; |
| 50 kDontPersistCookies | kDontStoreCookies; | |
| 51 static const unsigned int kFilterByHeaders = kModifyReceivedHeaders | | |
| 52 kBlockByType; | |
| 53 | 50 |
| 54 // Key used to access data attached to URLRequest objects. | 51 // Key used to access data attached to URLRequest objects. |
| 55 static const void* const kRequestDataKey; | 52 static const void* const kRequestDataKey; |
| 56 | 53 |
| 57 // Takes a string an returns the matching attribute, 0 if none matches. | 54 // Takes a string an returns the matching attribute, 0 if none matches. |
| 58 static unsigned int String2Attribute(const std::string&); | 55 static unsigned int String2Attribute(const std::string&); |
| 59 | 56 |
| 60 // Blacklist entries come from a provider, defined by a name and source URL. | 57 // Blacklist entries come from a provider, defined by a name and source URL. |
| 61 class Provider { | 58 class Provider { |
| 62 public: | 59 public: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 172 |
| 176 std::vector<Entry*> blacklist_; | 173 std::vector<Entry*> blacklist_; |
| 177 std::vector<Provider*> providers_; | 174 std::vector<Provider*> providers_; |
| 178 | 175 |
| 179 FRIEND_TEST(BlacklistTest, Generic); | 176 FRIEND_TEST(BlacklistTest, Generic); |
| 180 FRIEND_TEST(BlacklistTest, PatternMatch); | 177 FRIEND_TEST(BlacklistTest, PatternMatch); |
| 181 DISALLOW_COPY_AND_ASSIGN(Blacklist); | 178 DISALLOW_COPY_AND_ASSIGN(Blacklist); |
| 182 }; | 179 }; |
| 183 | 180 |
| 184 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_ | 181 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_ |
| OLD | NEW |