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

Unified Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2568033005: [NTP::SectionOrder] Replace CategoryFactory with a category ranker. (Closed)
Patch Set: rebase. 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 5cd19fd2c70fd03eee9b33759ee80ec3a1c7c29f..62bb459dfcfb6ae8757f869409de1b999b586d1c 100644
--- a/components/ntp_snippets/content_suggestions_service.cc
+++ b/components/ntp_snippets/content_suggestions_service.cc
@@ -25,13 +25,15 @@ ContentSuggestionsService::ContentSuggestionsService(
State state,
SigninManagerBase* signin_manager,
history::HistoryService* history_service,
- PrefService* pref_service)
+ PrefService* pref_service,
+ std::unique_ptr<CategoryRanker> category_ranker)
: state_(state),
signin_observer_(this),
history_service_observer_(this),
ntp_snippets_service_(nullptr),
pref_service_(pref_service),
- user_classifier_(pref_service) {
+ user_classifier_(pref_service),
+ category_ranker_(std::move(category_ranker)) {
// Can be null in tests.
if (signin_manager) {
signin_observer_.Add(signin_manager);
@@ -449,7 +451,7 @@ void ContentSuggestionsService::OnSignInStateChanged() {
void ContentSuggestionsService::SortCategories() {
std::sort(categories_.begin(), categories_.end(),
[this](const Category& left, const Category& right) {
- return category_factory_.CompareCategories(left, right);
+ return category_ranker_->Compare(left, right);
});
}
@@ -486,8 +488,7 @@ void ContentSuggestionsService::RestoreDismissedCategoriesFromPrefs() {
}
// When the provider is registered, it will be stored in this map.
- dismissed_providers_by_category_[category_factory()->FromIDValue(id)] =
- nullptr;
+ dismissed_providers_by_category_[Category::FromIDValue(id)] = nullptr;
}
}
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.h ('k') | components/ntp_snippets/content_suggestions_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698