OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_ |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/sha1.h" |
| 16 |
| 17 namespace base { |
| 18 class FilePath; |
| 19 } |
| 20 |
| 21 class GURL; |
| 22 |
| 23 // Compact list of (SHA1 hashes of) blocked hosts. |
| 24 // Checking for URLs is thread-safe, loading is not. |
| 25 class SupervisedUserBlacklist { |
| 26 public: |
| 27 struct Hash { |
| 28 Hash() {} |
| 29 explicit Hash(const std::string& host); |
| 30 bool operator<(const Hash& rhs) const; |
| 31 |
| 32 unsigned char data[base::kSHA1Length]; |
| 33 }; |
| 34 |
| 35 SupervisedUserBlacklist(); |
| 36 ~SupervisedUserBlacklist(); |
| 37 |
| 38 // Asynchronously read a blacklist from the given file, replacing any previous |
| 39 // entries. |done_callback| will be run after reading finishes (successfully |
| 40 // or not), but not if the SupervisedUserBlacklist is destroyed before that. |
| 41 void ReadFromFile(const base::FilePath& path, |
| 42 const base::Closure& done_callback); |
| 43 |
| 44 bool HasURL(const GURL& url) const; |
| 45 |
| 46 size_t GetEntryCount() const; |
| 47 |
| 48 private: |
| 49 void OnReadFromFileCompleted(const base::Closure& done_callback, |
| 50 scoped_ptr<std::vector<Hash> > host_hashes); |
| 51 |
| 52 std::vector<Hash> host_hashes_; |
| 53 |
| 54 base::WeakPtrFactory<SupervisedUserBlacklist> weak_ptr_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(SupervisedUserBlacklist); |
| 57 }; |
| 58 |
| 59 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST
_H_ |
OLD | NEW |