| Index: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
|
| diff --git a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
|
| index 2b4a13be546b13a67961c9f27359965406e461e5..44ea2695af77895b9eaeca3fb927d001dad9f465 100644
|
| --- a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
|
| +++ b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
|
| @@ -29,6 +29,8 @@
|
| #include "components/keyed_service/content/browser_context_dependency_manager.h"
|
| #include "components/keyed_service/core/service_access_type.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"
|
| @@ -45,6 +47,7 @@
|
| #include "components/signin/core/browser/profile_oauth2_token_service.h"
|
| #include "components/signin/core/browser/signin_manager.h"
|
| #include "components/translate/core/browser/language_model.h"
|
| +#include "components/variations/variations_associated_data.h"
|
| #include "components/version_info/version_info.h"
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -75,6 +78,9 @@ using content::BrowserThread;
|
| using history::HistoryService;
|
| using image_fetcher::ImageFetcherImpl;
|
| using ntp_snippets::BookmarkSuggestionsProvider;
|
| +using ntp_snippets::CategoryRanker;
|
| +using ntp_snippets::ClickBasedCategoryRanker;
|
| +using ntp_snippets::ConstantCategoryRanker;
|
| using ntp_snippets::ContentSuggestionsService;
|
| using ntp_snippets::ForeignSessionsSuggestionsProvider;
|
| using ntp_snippets::NTPSnippetsFetcher;
|
| @@ -189,6 +195,26 @@ void RegisterForeignSessionsProvider(SyncService* sync_service,
|
| service->RegisterProvider(std::move(provider));
|
| }
|
|
|
| +std::unique_ptr<CategoryRanker> BuildCategoryRanker(PrefService* pref_service) {
|
| + std::string category_ranker_parameter = variations::GetVariationParamValue(
|
| + ntp_snippets::kStudyName, "category_ranker");
|
| +
|
| + if (category_ranker_parameter.empty()) {
|
| + // Default, Enabled or Disabled.
|
| + return base::MakeUnique<ConstantCategoryRanker>();
|
| + }
|
| + if (category_ranker_parameter == "constant") {
|
| + return base::MakeUnique<ConstantCategoryRanker>();
|
| + }
|
| + if (category_ranker_parameter == "click_based") {
|
| + return base::MakeUnique<ClickBasedCategoryRanker>(pref_service);
|
| + }
|
| +
|
| + NOTREACHED() << "The category_ranker parameter value is "
|
| + << category_ranker_parameter;
|
| + return nullptr;
|
| +}
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -243,8 +269,8 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor(
|
| HistoryService* history_service = HistoryServiceFactory::GetForProfile(
|
| profile, ServiceAccessType::EXPLICIT_ACCESS);
|
| PrefService* pref_service = profile->GetPrefs();
|
| - auto category_ranker =
|
| - base::MakeUnique<ntp_snippets::ConstantCategoryRanker>();
|
| + std::unique_ptr<CategoryRanker> category_ranker =
|
| + BuildCategoryRanker(pref_service);
|
| auto* service =
|
| new ContentSuggestionsService(state, signin_manager, history_service,
|
| pref_service, std::move(category_ranker));
|
|
|