Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 const ImageFetchedCallback& callback); | 118 const ImageFetchedCallback& callback); |
| 119 | 119 |
| 120 // Dismisses the suggestion with the given |suggestion_id|, if it exists. | 120 // Dismisses the suggestion with the given |suggestion_id|, if it exists. |
| 121 // This will not trigger an update through the observers. | 121 // This will not trigger an update through the observers. |
| 122 void DismissSuggestion(const ContentSuggestion::ID& suggestion_id); | 122 void DismissSuggestion(const ContentSuggestion::ID& suggestion_id); |
| 123 | 123 |
| 124 // Dismisses the given |category|, if it exists. | 124 // Dismisses the given |category|, if it exists. |
| 125 // This will not trigger an update through the observers. | 125 // This will not trigger an update through the observers. |
| 126 void DismissCategory(Category category); | 126 void DismissCategory(Category category); |
| 127 | 127 |
| 128 // Restores all dismissed categories. | |
| 129 // This will not trigger an update through the observers. | |
| 130 void RestoreDismissedCategories(); | |
| 131 | |
| 128 // Observer accessors. | 132 // Observer accessors. |
| 129 void AddObserver(Observer* observer); | 133 void AddObserver(Observer* observer); |
| 130 void RemoveObserver(Observer* observer); | 134 void RemoveObserver(Observer* observer); |
| 131 | 135 |
| 132 // Registers a new ContentSuggestionsProvider. It must be ensured that at most | 136 // Registers a new ContentSuggestionsProvider. It must be ensured that at most |
| 133 // one provider is registered for every category and that this method is | 137 // one provider is registered for every category and that this method is |
| 134 // called only once per provider. | 138 // called only once per provider. |
| 135 void RegisterProvider(std::unique_ptr<ContentSuggestionsProvider> provider); | 139 void RegisterProvider(std::unique_ptr<ContentSuggestionsProvider> provider); |
| 136 | 140 |
| 137 // Removes history from the specified time range where the URL matches the | 141 // Removes history from the specified time range where the URL matches the |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 // are exactly the entries of |categories_| and the values are a subset of | 239 // are exactly the entries of |categories_| and the values are a subset of |
| 236 // |providers_|. | 240 // |providers_|. |
| 237 std::map<Category, ContentSuggestionsProvider*, Category::CompareByID> | 241 std::map<Category, ContentSuggestionsProvider*, Category::CompareByID> |
| 238 providers_by_category_; | 242 providers_by_category_; |
| 239 | 243 |
| 240 // All current suggestion categories, in an order determined by the | 244 // All current suggestion categories, in an order determined by the |
| 241 // |category_factory_|. This vector contains exactly the same categories as | 245 // |category_factory_|. This vector contains exactly the same categories as |
| 242 // |providers_by_category_|. | 246 // |providers_by_category_|. |
| 243 std::vector<Category> categories_; | 247 std::vector<Category> categories_; |
| 244 | 248 |
| 249 // All dismissed categories and their providers. These may be restored by | |
| 250 // RestoreDismissedCategories(). | |
| 251 std::map<Category, ContentSuggestionsProvider*, Category::CompareByID> | |
| 252 dismissed_providers_by_category_; | |
|
Marc Treib
2016/10/07 11:40:13
What's the status of persisting dismissals? Seems
Michael van Ouwerkerk
2016/10/10 16:19:32
Nicolas is working on persisting section dismissal
| |
| 253 | |
| 245 // All current suggestions grouped by category. This contains an entry for | 254 // All current suggestions grouped by category. This contains an entry for |
| 246 // every category in |categories_| whose status is an available status. It may | 255 // every category in |categories_| whose status is an available status. It may |
| 247 // contain an empty vector if the category is available but empty (or still | 256 // contain an empty vector if the category is available but empty (or still |
| 248 // loading). | 257 // loading). |
| 249 std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID> | 258 std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID> |
| 250 suggestions_by_category_; | 259 suggestions_by_category_; |
| 251 | 260 |
| 252 // Observer for the HistoryService. All providers are notified when history is | 261 // Observer for the HistoryService. All providers are notified when history is |
| 253 // deleted. | 262 // deleted. |
| 254 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 263 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 255 history_service_observer_; | 264 history_service_observer_; |
| 256 | 265 |
| 257 base::ObserverList<Observer> observers_; | 266 base::ObserverList<Observer> observers_; |
| 258 | 267 |
| 259 const std::vector<ContentSuggestion> no_suggestions_; | 268 const std::vector<ContentSuggestion> no_suggestions_; |
| 260 | 269 |
| 261 // Keep a direct reference to this special provider to redirect scheduling, | 270 // Keep a direct reference to this special provider to redirect scheduling, |
| 262 // background fetching and debugging calls to it. If the NTPSnippetsService is | 271 // background fetching and debugging calls to it. If the NTPSnippetsService is |
| 263 // loaded, it is also present in |providers_|, otherwise this is a nullptr. | 272 // loaded, it is also present in |providers_|, otherwise this is a nullptr. |
| 264 NTPSnippetsService* ntp_snippets_service_; | 273 NTPSnippetsService* ntp_snippets_service_; |
| 265 | 274 |
| 266 UserClassifier user_classifier_; | 275 UserClassifier user_classifier_; |
| 267 | 276 |
| 268 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); | 277 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); |
| 269 }; | 278 }; |
| 270 | 279 |
| 271 } // namespace ntp_snippets | 280 } // namespace ntp_snippets |
| 272 | 281 |
| 273 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 282 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
| OLD | NEW |