Chromium Code Reviews| Index: chrome/browser/search/suggestions/blacklist_store.h |
| diff --git a/chrome/browser/search/suggestions/blacklist_store.h b/chrome/browser/search/suggestions/blacklist_store.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f513632f3222ea226077a46e5118a99cafeff682 |
| --- /dev/null |
| +++ b/chrome/browser/search/suggestions/blacklist_store.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SEARCH_SUGGESTIONS_BLACKLIST_STORE_H_ |
| +#define CHROME_BROWSER_SEARCH_SUGGESTIONS_BLACKLIST_STORE_H_ |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/search/suggestions/proto/suggestions.pb.h" |
| +#include "url/gurl.h" |
| + |
| +class PrefService; |
| + |
| +namespace user_prefs { |
| +class PrefRegistrySyncable; |
| +} // namespace user_prefs |
| + |
| +namespace suggestions { |
| + |
| +// A helper class for reading, writing and modifying a small blacklist stored |
| +// 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.
|
| +// filtering based on the stored blacklist. |
| +class BlacklistStore { |
| + public: |
| + explicit BlacklistStore(PrefService* profile_prefs); |
| + virtual ~BlacklistStore(); |
| + |
| + // 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.
|
| + // already in the blacklist. |
| + virtual bool BlacklistUrl(const GURL& url); |
| + |
| + // 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.
|
| + 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.
|
| + |
| + // Removes |url| from the stored blacklist. Returns false if |url| is not |
| + // 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.
|
| + virtual bool RemoveUrl(const GURL& url); |
| + |
| + // Applies the blacklist to |suggestions|. |
| + virtual void FilterSuggestions(SuggestionsProfile* suggestions); |
| + |
| + // Register BlacklistStore related prefs in the Profile prefs. |
| + static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| + |
| + protected: |
| + // Test seam. For simplicity of mock creation. |
| + BlacklistStore() {} |
| + |
| + // 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.
|
| + // |blacklist|. If there is a problem with loading, the pref value is |
| + // cleared, false is returned and |blacklist| is cleared. If successful, |
| + // |blacklist| will contain the loaded data and true is returned. |
| + bool LoadBlacklist(SuggestionsBlacklist* blacklist); |
| + |
| + // Stores the provided |blacklist| to the profile's preferences, using |
| + // a base64 encoding of its protobuf serialization. |
| + bool StoreBlacklist(const SuggestionsBlacklist& blacklist); |
| + |
| + // Clears any blacklist data from the profile's preferences. |
| + void ClearBlacklist(); |
| + |
| + private: |
| + // 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.
|
| + PrefService* pref_service_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BlacklistStore); |
| +}; |
| + |
| +} // namespace suggestions |
| + |
| +#endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_BLACKLIST_STORE_H_ |