Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/search/suggestions/blacklist_store.h

Issue 330473003: Offline blacklisting for SuggestionsService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/search/suggestions/blacklist_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 preferences. It also handles SuggestionsProfile
22 // filtering based on the stored blacklist.
23 class BlacklistStore {
24 public:
25 explicit BlacklistStore(PrefService* profile_prefs);
26 virtual ~BlacklistStore();
27
28 // Returns true if successful or |url| was already in the blacklist.
29 virtual bool BlacklistUrl(const GURL& url);
30
31 // Sets |url| to the first URL from the blacklist. Returns false if the
32 // blacklist is empty.
33 virtual bool GetFirstUrlFromBlacklist(GURL* url);
34
35 // Removes |url| from the stored blacklist. Returns true if successful or if
36 // |url| is not in the blacklist.
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 preferences into
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 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 blacklist.
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_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search/suggestions/blacklist_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698