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.
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_
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"
23 // Compact list of (SHA1 hashes of) blocked hosts.
24 // Checking for URLs is thread-safe, loading is not.
25 class SupervisedUserBlacklist
{
29 explicit Hash(const std::string
& host
);
30 bool operator<(const Hash
& rhs
) const;
32 unsigned char data
[base::kSHA1Length
];
35 SupervisedUserBlacklist();
36 ~SupervisedUserBlacklist();
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
);
44 bool HasURL(const GURL
& url
) const;
46 size_t GetEntryCount() const;
49 void OnReadFromFileCompleted(const base::Closure
& done_callback
,
50 scoped_ptr
<std::vector
<Hash
> > host_hashes
);
52 std::vector
<Hash
> host_hashes_
;
54 base::WeakPtrFactory
<SupervisedUserBlacklist
> weak_ptr_factory_
;
56 DISALLOW_COPY_AND_ASSIGN(SupervisedUserBlacklist
);
59 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_