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_SEARCH_SUGGESTIONS_BLACKLIST_STORE_H_ | |
6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_BLACKLIST_STORE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "chrome/browser/search/suggestions/proto/suggestions.pb.h" | |
10 #include "url/gurl.h" | |
11 | |
12 class PrefService; | |
13 | |
14 namespace user_prefs { | |
15 class PrefRegistrySyncable; | |
16 } // namespace user_prefs | |
17 | |
18 namespace suggestions { | |
19 | |
20 // A helper class for reading, writing and modifying a small blacklist stored | |
21 // in the profile's preference file. It also handles SuggestionsProfile | |
Mathieu
2014/06/17 14:51:14
profile's preference file -> Profile preferences
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
22 // filtering based on the stored blacklist. | |
23 class BlacklistStore { | |
24 public: | |
25 explicit BlacklistStore(PrefService* profile_prefs); | |
26 virtual ~BlacklistStore(); | |
27 | |
28 // Appends |url| to the blacklist. Returns false otherwise, unless |url| is | |
Mathieu
2014/06/17 14:51:14
second sentence is confusing. What about
Returns
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
29 // already in the blacklist. | |
30 virtual bool BlacklistUrl(const GURL& url); | |
31 | |
32 // Sets |url| to a blacklisted url. Returns false if the blacklist is empty. | |
Mathieu
2014/06/17 14:51:14
url -> URL?
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
33 virtual bool GetSomeBlacklistedUrl(GURL* url); | |
Mathieu
2014/06/17 14:51:14
It's not clear from the name or the doc what this
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
34 | |
35 // Removes |url| from the stored blacklist. Returns false if |url| is not | |
36 // valid. It is not considered an error if |url| is not in the blacklist. | |
Mathieu
2014/06/17 14:51:14
Returns true if |url| was not in the blacklist?
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
37 virtual bool RemoveUrl(const GURL& url); | |
38 | |
39 // Applies the blacklist to |suggestions|. | |
40 virtual void FilterSuggestions(SuggestionsProfile* suggestions); | |
41 | |
42 // Register BlacklistStore related prefs in the Profile prefs. | |
43 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
44 | |
45 protected: | |
46 // Test seam. For simplicity of mock creation. | |
47 BlacklistStore() {} | |
48 | |
49 // Loads the blacklist data from the profile's preferences into | |
Mathieu
2014/06/17 14:51:14
profile preferences
here and below
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
50 // |blacklist|. If there is a problem with loading, the pref value is | |
51 // cleared, false is returned and |blacklist| is cleared. If successful, | |
52 // |blacklist| will contain the loaded data and true is returned. | |
53 bool LoadBlacklist(SuggestionsBlacklist* blacklist); | |
54 | |
55 // Stores the provided |blacklist| to the profile's preferences, using | |
56 // a base64 encoding of its protobuf serialization. | |
57 bool StoreBlacklist(const SuggestionsBlacklist& blacklist); | |
58 | |
59 // Clears any blacklist data from the profile's preferences. | |
60 void ClearBlacklist(); | |
61 | |
62 private: | |
63 // The pref service used to persist the suggestions data. | |
Mathieu
2014/06/17 14:51:14
*suggestions blacklist
manzagop (departed)
2014/06/17 15:42:23
Done.
| |
64 PrefService* pref_service_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(BlacklistStore); | |
67 }; | |
68 | |
69 } // namespace suggestions | |
70 | |
71 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_BLACKLIST_STORE_H_ | |
OLD | NEW |