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 #include "components/ntp_snippets/content_suggestions_service.h" | 5 #include "components/ntp_snippets/content_suggestions_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 observer.ContentSuggestionsServiceShutdown(); | 59 observer.ContentSuggestionsServiceShutdown(); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 // static | 63 // static |
64 void ContentSuggestionsService::RegisterProfilePrefs( | 64 void ContentSuggestionsService::RegisterProfilePrefs( |
65 PrefRegistrySimple* registry) { | 65 PrefRegistrySimple* registry) { |
66 registry->RegisterListPref(prefs::kDismissedCategories); | 66 registry->RegisterListPref(prefs::kDismissedCategories); |
67 } | 67 } |
68 | 68 |
| 69 const std::vector<Category>& ContentSuggestionsService::GetCategories() { |
| 70 SortCategories(); |
| 71 return categories_; |
| 72 } |
| 73 |
69 CategoryStatus ContentSuggestionsService::GetCategoryStatus( | 74 CategoryStatus ContentSuggestionsService::GetCategoryStatus( |
70 Category category) const { | 75 Category category) const { |
71 if (state_ == State::DISABLED) { | 76 if (state_ == State::DISABLED) { |
72 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; | 77 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; |
73 } | 78 } |
74 | 79 |
75 auto iterator = providers_by_category_.find(category); | 80 auto iterator = providers_by_category_.find(category); |
76 if (iterator == providers_by_category_.end()) { | 81 if (iterator == providers_by_category_.end()) { |
77 return CategoryStatus::NOT_PROVIDED; | 82 return CategoryStatus::NOT_PROVIDED; |
78 } | 83 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 500 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
496 base::ListValue list; | 501 base::ListValue list; |
497 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 502 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
498 list.AppendInteger(category_provider_pair.first.id()); | 503 list.AppendInteger(category_provider_pair.first.id()); |
499 } | 504 } |
500 | 505 |
501 pref_service_->Set(prefs::kDismissedCategories, list); | 506 pref_service_->Set(prefs::kDismissedCategories, list); |
502 } | 507 } |
503 | 508 |
504 } // namespace ntp_snippets | 509 } // namespace ntp_snippets |
OLD | NEW |