| Index: components/ntp_snippets/content_suggestions_service.h
|
| diff --git a/components/ntp_snippets/content_suggestions_service.h b/components/ntp_snippets/content_suggestions_service.h
|
| index 987a9fb4accd0cf0d623b1b970cb0195a24be638..766342997b870de66ffa91c3376a29e771d75d2a 100644
|
| --- a/components/ntp_snippets/content_suggestions_service.h
|
| +++ b/components/ntp_snippets/content_suggestions_service.h
|
| @@ -23,8 +23,10 @@
|
| #include "components/ntp_snippets/category_status.h"
|
| #include "components/ntp_snippets/content_suggestions_provider.h"
|
| #include "components/ntp_snippets/user_classifier.h"
|
| +#include "components/prefs/pref_service.h"
|
|
|
| class PrefService;
|
| +class PrefRegistrySimple;
|
|
|
| namespace gfx {
|
| class Image;
|
| @@ -92,6 +94,8 @@ class ContentSuggestionsService : public KeyedService,
|
| // Inherited from KeyedService.
|
| void Shutdown() override;
|
|
|
| + static void RegisterProfilePrefs(PrefRegistrySimple* registry);
|
| +
|
| State state() { return state_; }
|
|
|
| // Gets all categories for which a provider is registered. The categories
|
| @@ -190,6 +194,8 @@ class ContentSuggestionsService : public KeyedService,
|
| void OnNewSuggestions(ContentSuggestionsProvider* provider,
|
| Category category,
|
| std::vector<ContentSuggestion> suggestions) override;
|
| + void OnNewSuggestionBatch(ContentSuggestionsProvider* provider,
|
| + SuggestionBatch suggestion_batch) override;
|
| void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
|
| Category category,
|
| CategoryStatus new_status) override;
|
| @@ -212,6 +218,12 @@ class ContentSuggestionsService : public KeyedService,
|
| bool RegisterCategoryIfRequired(ContentSuggestionsProvider* provider,
|
| Category category);
|
|
|
| + // Notifies the observer of new suggestions if necessary. In particular,
|
| + // dismissed or unavailable categories will not trigger a notification.
|
| + void OnNewSuggestionsInternal(ContentSuggestionsProvider* provider,
|
| + Category category,
|
| + std::vector<ContentSuggestion> suggestions);
|
| +
|
| // Removes a suggestion from the local store |suggestions_by_category_|, if it
|
| // exists. Returns true if a suggestion was removed.
|
| bool RemoveSuggestionByID(const ContentSuggestion::ID& suggestion_id);
|
| @@ -219,8 +231,14 @@ class ContentSuggestionsService : public KeyedService,
|
| // Fires the OnCategoryStatusChanged event for the given |category|.
|
| void NotifyCategoryStatusChanged(Category category);
|
|
|
| + // Returns whether the provided |category| has been dismissed.
|
| + bool IsCategoryDismissed(Category category) const;
|
| +
|
| void SortCategories();
|
|
|
| + void RestoreDismissedCategoriesFromPrefs();
|
| + void StoreDismissedCategoriesToPrefs();
|
| +
|
| // Whether the content suggestions feature is enabled.
|
| State state_;
|
|
|
| @@ -249,6 +267,9 @@ class ContentSuggestionsService : public KeyedService,
|
| std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID>
|
| suggestions_by_category_;
|
|
|
| + // All the currently dismissed categories.
|
| + std::set<Category, Category::CompareByID> dismissed_categories_;
|
| +
|
| // Observer for the HistoryService. All providers are notified when history is
|
| // deleted.
|
| ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
|
| @@ -263,6 +284,8 @@ class ContentSuggestionsService : public KeyedService,
|
| // loaded, it is also present in |providers_|, otherwise this is a nullptr.
|
| NTPSnippetsService* ntp_snippets_service_;
|
|
|
| + PrefService* pref_service_;
|
| +
|
| UserClassifier user_classifier_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService);
|
|
|