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

Unified Diff: ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc

Issue 2595883002: [NTP::SectionOrder] Add a flag to choose category ranker. (Closed)
Patch Set: jkrcal@ nit. 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: ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
diff --git a/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc b/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
index 232edcbd2c8c6658bae5de951e370b85f95ae812..354a69a7cd711cab4e0a8696fcc1b84b4b256f18 100644
--- a/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
+++ b/ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc
@@ -19,6 +19,7 @@
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h"
#include "components/ntp_snippets/category_rankers/category_ranker.h"
+#include "components/ntp_snippets/category_rankers/click_based_category_ranker.h"
#include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
#include "components/ntp_snippets/content_suggestions_service.h"
#include "components/ntp_snippets/features.h"
@@ -75,6 +76,23 @@ void ParseJson(const std::string& json,
}
}
+std::unique_ptr<ntp_snippets::CategoryRanker> BuildCategoryRanker(
+ PrefService* pref_service) {
noyau (Ping after 24h) 2016/12/22 14:06:52 Instead of duplicating this code in chrome/ and io
vitaliii 2016/12/23 13:12:51 Done.
+ ntp_snippets::CategoryRankerChoice choice =
+ ntp_snippets::GetSelectedCategoryRanker();
+ switch (choice) {
+ case ntp_snippets::CategoryRankerChoice::CONSTANT:
+ return base::MakeUnique<ntp_snippets::ConstantCategoryRanker>();
+ case ntp_snippets::CategoryRankerChoice::CLICK_BASED:
+ return base::MakeUnique<ntp_snippets::ClickBasedCategoryRanker>(
+ pref_service);
+ default:
+ NOTREACHED() << "The category ranker choice value is "
+ << static_cast<int>(choice);
+ }
+ return nullptr;
+}
+
} // namespace
// static
@@ -126,7 +144,7 @@ IOSChromeContentSuggestionsServiceFactory::BuildServiceInstanceFor(
ios::HistoryServiceFactory::GetForBrowserState(
chrome_browser_state, ServiceAccessType::EXPLICIT_ACCESS);
std::unique_ptr<ntp_snippets::CategoryRanker> category_ranker =
- base::MakeUnique<ntp_snippets::ConstantCategoryRanker>();
+ BuildCategoryRanker(prefs);
std::unique_ptr<ContentSuggestionsService> service =
base::MakeUnique<ContentSuggestionsService>(state, signin_manager,
history_service, prefs,

Powered by Google App Engine
This is Rietveld 408576698