Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2596)

Unified Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2581163004: [NTP::SectionOrder] Propagate new order through ContentSuggestionsService. (Closed)
Patch Set: treib@ comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/content_suggestions_service.cc
diff --git a/components/ntp_snippets/content_suggestions_service.cc b/components/ntp_snippets/content_suggestions_service.cc
index 62bb459dfcfb6ae8757f869409de1b999b586d1c..fbfa26715ce5bd97f7bebc56664d7de8575dfee1 100644
--- a/components/ntp_snippets/content_suggestions_service.cc
+++ b/components/ntp_snippets/content_suggestions_service.cc
@@ -66,6 +66,15 @@ void ContentSuggestionsService::RegisterProfilePrefs(
registry->RegisterListPref(prefs::kDismissedCategories);
}
+std::vector<Category> ContentSuggestionsService::GetCategories() const {
+ std::vector<Category> sorted_categories = categories_;
+ std::sort(sorted_categories.begin(), sorted_categories.end(),
+ [this](const Category& left, const Category& right) {
+ return category_ranker_->Compare(left, right);
+ });
+ return sorted_categories;
+}
+
CategoryStatus ContentSuggestionsService::GetCategoryStatus(
Category category) const {
if (state_ == State::DISABLED) {
@@ -389,7 +398,6 @@ void ContentSuggestionsService::RegisterCategory(
providers_by_category_[category] = provider;
categories_.push_back(category);
- SortCategories();
if (IsCategoryStatusAvailable(provider->GetCategoryStatus(category))) {
suggestions_by_category_.insert(
std::make_pair(category, std::vector<ContentSuggestion>()));
@@ -448,13 +456,6 @@ void ContentSuggestionsService::OnSignInStateChanged() {
}
}
-void ContentSuggestionsService::SortCategories() {
- std::sort(categories_.begin(), categories_.end(),
- [this](const Category& left, const Category& right) {
- return category_ranker_->Compare(left, right);
- });
-}
-
bool ContentSuggestionsService::IsCategoryDismissed(Category category) const {
return base::ContainsKey(dismissed_providers_by_category_, category);
}

Powered by Google App Engine
This is Rietveld 408576698