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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 std::unique_ptr<CategoryRanker> category_ranker); | 93 std::unique_ptr<CategoryRanker> category_ranker); |
| 94 ~ContentSuggestionsService() override; | 94 ~ContentSuggestionsService() override; |
| 95 | 95 |
| 96 // Inherited from KeyedService. | 96 // Inherited from KeyedService. |
| 97 void Shutdown() override; | 97 void Shutdown() override; |
| 98 | 98 |
| 99 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 99 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
| 100 | 100 |
| 101 State state() { return state_; } | 101 State state() { return state_; } |
| 102 | 102 |
| 103 // Gets all categories for which a provider is registered. The categories | 103 // Gets all categories for which a provider is registered. The categories may |
| 104 // may or may not be available, see |GetCategoryStatus()|. | 104 // or may not be available, see |GetCategoryStatus()|. The order is obtained |
| 105 const std::vector<Category>& GetCategories() const { return categories_; } | 105 // from |category_ranker_| immediately. |
|
tschumann
2016/12/19 09:06:38
IMO, this comment is exposing too many implementat
vitaliii
2016/12/19 11:31:39
Done.
| |
| 106 const std::vector<Category>& GetCategories(); | |
| 106 | 107 |
| 107 // Gets the status of a category. | 108 // Gets the status of a category. |
| 108 CategoryStatus GetCategoryStatus(Category category) const; | 109 CategoryStatus GetCategoryStatus(Category category) const; |
| 109 | 110 |
| 110 // Gets the meta information of a category. | 111 // Gets the meta information of a category. |
| 111 base::Optional<CategoryInfo> GetCategoryInfo(Category category) const; | 112 base::Optional<CategoryInfo> GetCategoryInfo(Category category) const; |
| 112 | 113 |
| 113 // Gets the available suggestions for a category. The result is empty if the | 114 // Gets the available suggestions for a category. The result is empty if the |
| 114 // category is available and empty, but also if the category is unavailable | 115 // category is available and empty, but also if the category is unavailable |
| 115 // for any reason, see |GetCategoryStatus()|. | 116 // for any reason, see |GetCategoryStatus()|. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 providers_by_category_; | 279 providers_by_category_; |
| 279 | 280 |
| 280 // All dismissed categories and their providers. These may be restored by | 281 // All dismissed categories and their providers. These may be restored by |
| 281 // RestoreDismissedCategories(). The provider can be null if the dismissed | 282 // RestoreDismissedCategories(). The provider can be null if the dismissed |
| 282 // category has received no updates since initialisation. | 283 // category has received no updates since initialisation. |
| 283 // (see RestoreDismissedCategoriesFromPrefs()) | 284 // (see RestoreDismissedCategoriesFromPrefs()) |
| 284 std::map<Category, ContentSuggestionsProvider*, Category::CompareByID> | 285 std::map<Category, ContentSuggestionsProvider*, Category::CompareByID> |
| 285 dismissed_providers_by_category_; | 286 dismissed_providers_by_category_; |
| 286 | 287 |
| 287 // All current suggestion categories, in an order determined by the | 288 // All current suggestion categories, in an order determined by the |
| 288 // |category_factory_|. This vector contains exactly the same categories as | 289 // |category_ranker_|. The order here may be stale, i.e. changes in the ranker |
|
tschumann
2016/12/19 09:06:38
nit: let's phrase this a bit clearer:
The order in
vitaliii
2016/12/19 11:31:39
Done.
| |
| 289 // |providers_by_category_|. | 290 // are not immediately propagated here (use SortCategories() to refresh). This |
| 291 // vector contains exactly the same categories as |providers_by_category_|. | |
| 290 std::vector<Category> categories_; | 292 std::vector<Category> categories_; |
| 291 | 293 |
| 292 // All current suggestions grouped by category. This contains an entry for | 294 // All current suggestions grouped by category. This contains an entry for |
| 293 // every category in |categories_| whose status is an available status. It may | 295 // every category in |categories_| whose status is an available status. It may |
| 294 // contain an empty vector if the category is available but empty (or still | 296 // contain an empty vector if the category is available but empty (or still |
| 295 // loading). | 297 // loading). |
| 296 std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID> | 298 std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID> |
| 297 suggestions_by_category_; | 299 suggestions_by_category_; |
| 298 | 300 |
| 299 // Observer for the SigninManager. All observers are notified when the signin | 301 // Observer for the SigninManager. All observers are notified when the signin |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 322 | 324 |
| 323 // Provides order for categories. | 325 // Provides order for categories. |
| 324 std::unique_ptr<CategoryRanker> category_ranker_; | 326 std::unique_ptr<CategoryRanker> category_ranker_; |
| 325 | 327 |
| 326 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); | 328 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); |
| 327 }; | 329 }; |
| 328 | 330 |
| 329 } // namespace ntp_snippets | 331 } // namespace ntp_snippets |
| 330 | 332 |
| 331 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ | 333 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ |
| OLD | NEW |