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

Unified Diff: components/ntp_snippets/ntp_snippets_service.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
Index: components/ntp_snippets/ntp_snippets_service.cc
diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
index 4da4e50a3ddeb8950cafb65e3d8ba89a28e7d58b..b269c42e41576dc69b377ca41d2c69d029affe3f 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -186,6 +186,7 @@ void WrapImageFetchedCallback(
} // namespace
NTPSnippetsService::NTPSnippetsService(
+ bool enabled,
PrefService* pref_service,
sync_driver::SyncService* sync_service,
SuggestionsService* suggestions_service,
@@ -194,8 +195,8 @@ NTPSnippetsService::NTPSnippetsService(
NTPSnippetsScheduler* scheduler,
std::unique_ptr<NTPSnippetsFetcher> snippets_fetcher,
std::unique_ptr<ImageFetcher> image_fetcher)
- : state_(State::NOT_INITED),
- enabled_(false),
+ : state_(State::INITED),
+ enabled_(enabled),
pref_service_(pref_service),
sync_service_(sync_service),
sync_service_observer_(this),
@@ -211,24 +212,7 @@ NTPSnippetsService::NTPSnippetsService(
// |sync_service_| can be null in tests or if sync is disabled.
if (sync_service_)
sync_service_observer_.Add(sync_service_);
-}
-
-NTPSnippetsService::~NTPSnippetsService() {
- DCHECK(state_ == State::NOT_INITED || state_ == State::SHUT_DOWN);
-}
-
-// static
-void NTPSnippetsService::RegisterProfilePrefs(PrefRegistrySimple* registry) {
- registry->RegisterListPref(prefs::kSnippets);
- registry->RegisterListPref(prefs::kDiscardedSnippets);
- registry->RegisterListPref(prefs::kSnippetHosts);
-}
-void NTPSnippetsService::Init(bool enabled) {
- DCHECK(state_ == State::NOT_INITED);
- state_ = State::INITED;
-
- enabled_ = enabled;
if (enabled_) {
// |suggestions_service_| can be null in tests.
if (snippets_fetcher_->UsesHostRestrictions() && suggestions_service_) {
@@ -249,6 +233,17 @@ void NTPSnippetsService::Init(bool enabled) {
RescheduleFetching();
}
+NTPSnippetsService::~NTPSnippetsService() {
+ DCHECK(state_ == State::SHUT_DOWN);
+}
+
+// static
+void NTPSnippetsService::RegisterProfilePrefs(PrefRegistrySimple* registry) {
+ registry->RegisterListPref(prefs::kSnippets);
+ registry->RegisterListPref(prefs::kDiscardedSnippets);
+ registry->RegisterListPref(prefs::kSnippetHosts);
+}
+
void NTPSnippetsService::Shutdown() {
DCHECK(state_ == State::INITED);
state_ = State::SHUT_DOWN;
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.h ('k') | components/ntp_snippets/ntp_snippets_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698