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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // All registered providers, owned by the service. | 234 // All registered providers, owned by the service. |
231 std::vector<std::unique_ptr<ContentSuggestionsProvider>> providers_; | 235 std::vector<std::unique_ptr<ContentSuggestionsProvider>> providers_; |
232 | 236 |
233 // All registered categories and their providers. A provider may be contained | 237 // All registered categories and their providers. A provider may be contained |
234 // multiple times, if it provides multiple categories. The keys of this map | 238 // multiple times, if it provides multiple categories. The keys of this map |
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 |
| 244 // All dismissed categories and their providers. These may be restored by |
| 245 // RestoreDismissedCategories(). |
| 246 std::map<Category, ContentSuggestionsProvider*, Category::CompareByID> |
| 247 dismissed_providers_by_category_; |
| 248 |
240 // All current suggestion categories, in an order determined by the | 249 // All current suggestion categories, in an order determined by the |
241 // |category_factory_|. This vector contains exactly the same categories as | 250 // |category_factory_|. This vector contains exactly the same categories as |
242 // |providers_by_category_|. | 251 // |providers_by_category_|. |
243 std::vector<Category> categories_; | 252 std::vector<Category> categories_; |
244 | 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> |
(...skipping 14 matching lines...) Expand all Loading... |
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 |