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

Unified Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2227953002: [NTP Snippets] Add kArticleSuggestionsFeature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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
« no previous file with comments | « no previous file | components/ntp_snippets/features.h » ('j') | components/ntp_snippets/features.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0dc8e0a2b728aaddf1ec4533f158b34ebdfeee9b..1a448f5919aac6b33baa7d328162f24f5c450a4c 100644
--- a/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
+++ b/chrome/browser/ntp_snippets/content_suggestions_service_factory.cc
@@ -136,44 +136,48 @@ KeyedService* ContentSuggestionsServiceFactory::BuildServiceInstanceFor(
service->RegisterProvider(std::move(bookmark_suggestions_provider));
}
- // Create the NTPSnippetsService (articles provider).
- SigninManagerBase* signin_manager =
- SigninManagerFactory::GetForProfile(profile);
- OAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- scoped_refptr<net::URLRequestContextGetter> request_context =
- content::BrowserContext::GetDefaultStoragePartition(context)
- ->GetURLRequestContext();
- SuggestionsService* suggestions_service =
- SuggestionsServiceFactory::GetForProfile(profile);
- NTPSnippetsScheduler* scheduler = nullptr;
+ if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) {
+ // Create the NTPSnippetsService (articles provider).
+ SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfile(profile);
+ OAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
+ scoped_refptr<net::URLRequestContextGetter> request_context =
+ content::BrowserContext::GetDefaultStoragePartition(context)
+ ->GetURLRequestContext();
+ SuggestionsService* suggestions_service =
+ SuggestionsServiceFactory::GetForProfile(profile);
+ NTPSnippetsScheduler* scheduler = nullptr;
#if defined(OS_ANDROID)
- scheduler = NTPSnippetsLauncher::Get();
+ scheduler = NTPSnippetsLauncher::Get();
#endif // OS_ANDROID
- base::FilePath database_dir(
- profile->GetPath().Append(ntp_snippets::kDatabaseFolder));
- scoped_refptr<base::SequencedTaskRunner> task_runner =
- BrowserThread::GetBlockingPool()
- ->GetSequencedTaskRunnerWithShutdownBehavior(
- base::SequencedWorkerPool::GetSequenceToken(),
- base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
- std::unique_ptr<NTPSnippetsService> ntp_snippets_service =
- base::MakeUnique<NTPSnippetsService>(
- service, service->category_factory(), profile->GetPrefs(),
- suggestions_service, g_browser_process->GetApplicationLocale(),
- scheduler, base::MakeUnique<NTPSnippetsFetcher>(
- signin_manager, token_service, request_context,
- profile->GetPrefs(),
- base::Bind(&safe_json::SafeJsonParser::Parse),
- chrome::GetChannel() == version_info::Channel::STABLE),
- base::MakeUnique<ImageFetcherImpl>(
- base::MakeUnique<ImageDecoderImpl>(), request_context.get()),
- base::MakeUnique<ImageDecoderImpl>(),
- base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner),
- base::MakeUnique<NTPSnippetsStatusService>(signin_manager,
- profile->GetPrefs()));
- service->set_ntp_snippets_service(ntp_snippets_service.get());
- service->RegisterProvider(std::move(ntp_snippets_service));
+ base::FilePath database_dir(
+ profile->GetPath().Append(ntp_snippets::kDatabaseFolder));
+ scoped_refptr<base::SequencedTaskRunner> task_runner =
+ BrowserThread::GetBlockingPool()
+ ->GetSequencedTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::GetSequenceToken(),
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
+ bool is_stable_channel =
+ chrome::GetChannel() == version_info::Channel::STABLE;
+ std::unique_ptr<NTPSnippetsService> ntp_snippets_service =
+ base::MakeUnique<NTPSnippetsService>(
+ service, service->category_factory(), profile->GetPrefs(),
+ suggestions_service, g_browser_process->GetApplicationLocale(),
+ scheduler, base::MakeUnique<NTPSnippetsFetcher>(
+ signin_manager, token_service, request_context,
+ profile->GetPrefs(),
+ base::Bind(&safe_json::SafeJsonParser::Parse),
+ is_stable_channel),
+ base::MakeUnique<ImageFetcherImpl>(
+ base::MakeUnique<ImageDecoderImpl>(), request_context.get()),
+ base::MakeUnique<ImageDecoderImpl>(),
+ base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner),
+ base::MakeUnique<NTPSnippetsStatusService>(signin_manager,
+ profile->GetPrefs()));
+ service->set_ntp_snippets_service(ntp_snippets_service.get());
+ service->RegisterProvider(std::move(ntp_snippets_service));
+ }
return service;
}
« no previous file with comments | « no previous file | components/ntp_snippets/features.h » ('j') | components/ntp_snippets/features.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698