| 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) {
|
| + 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,
|
|
|