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

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

Issue 1997473004: Snippets are enabled when search suggestions are enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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 | « chrome/android/java_sources.gni ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
diff --git a/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc b/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
index 17dbfc27177760cb259731f356b7922c19a899d0..6ae606b8b7ee3d8182220ea5a61fc9561755a554 100644
--- a/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
+++ b/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h"
+#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include "chrome/browser/browser_process.h"
@@ -14,12 +15,14 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/channel_info.h"
+#include "chrome/common/pref_names.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/image_fetcher/image_fetcher.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/ntp_snippets/ntp_snippets_fetcher.h"
#include "components/ntp_snippets/ntp_snippets_scheduler.h"
#include "components/ntp_snippets/ntp_snippets_service.h"
+#include "components/prefs/pref_service.h"
#include "components/safe_json/safe_json_parser.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -30,6 +33,7 @@
#include "net/url_request/url_request_context_getter.h"
#if defined(OS_ANDROID)
+#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/android/ntp/ntp_snippets_launcher.h"
#endif // OS_ANDROID
@@ -66,6 +70,15 @@ NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {}
KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
+
+ // TODO(mvanouwerkerk): Move the enable logic into the service once we start
+ // observing pref changes.
+ bool enabled = profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled);
+#if defined(OS_ANDROID)
+ enabled = enabled &&
+ base::FeatureList::IsEnabled(chrome::android::kNTPSnippetsFeature);
+#endif // OS_ANDROID
+
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile);
OAuth2TokenService* token_service =
@@ -90,8 +103,8 @@ KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor(
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
return new ntp_snippets::NTPSnippetsService(
- profile->GetPrefs(), sync_service, suggestions_service, task_runner,
- g_browser_process->GetApplicationLocale(), scheduler,
+ enabled, profile->GetPrefs(), sync_service, suggestions_service,
+ task_runner, g_browser_process->GetApplicationLocale(), scheduler,
base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher(
signin_manager, token_service, request_context,
base::Bind(&safe_json::SafeJsonParser::Parse),
« no previous file with comments | « chrome/android/java_sources.gni ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698