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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1986173003: Fixes that host restriction was sometimes applied even when switched off. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes 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 unified diff | Download patch
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/ntp_snippets_service.h" 5 #include "components/ntp_snippets/ntp_snippets_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 void NTPSnippetsService::RegisterProfilePrefs(PrefRegistrySimple* registry) { 179 void NTPSnippetsService::RegisterProfilePrefs(PrefRegistrySimple* registry) {
180 registry->RegisterListPref(prefs::kSnippets); 180 registry->RegisterListPref(prefs::kSnippets);
181 registry->RegisterListPref(prefs::kDiscardedSnippets); 181 registry->RegisterListPref(prefs::kDiscardedSnippets);
182 registry->RegisterListPref(prefs::kSnippetHosts); 182 registry->RegisterListPref(prefs::kSnippetHosts);
183 } 183 }
184 184
185 void NTPSnippetsService::Init(bool enabled) { 185 void NTPSnippetsService::Init(bool enabled) {
186 enabled_ = enabled; 186 enabled_ = enabled;
187 if (enabled_) { 187 if (enabled_) {
188 // |suggestions_service_| can be null in tests. 188 // |suggestions_service_| can be null in tests.
189 if (suggestions_service_) { 189 if (snippets_fetcher_->UseHostRestriction() && suggestions_service_) {
190 suggestions_service_subscription_ = suggestions_service_->AddCallback( 190 suggestions_service_subscription_ = suggestions_service_->AddCallback(
191 base::Bind(&NTPSnippetsService::OnSuggestionsChanged, 191 base::Bind(&NTPSnippetsService::OnSuggestionsChanged,
192 base::Unretained(this))); 192 base::Unretained(this)));
193 } 193 }
194 194
195 // Get any existing snippets immediately from prefs. 195 // Get any existing snippets immediately from prefs.
196 LoadDiscardedSnippetsFromPrefs(); 196 LoadDiscardedSnippetsFromPrefs();
197 LoadSnippetsFromPrefs(); 197 LoadSnippetsFromPrefs();
198 198
199 // If we don't have any snippets yet, start a fetch. 199 // If we don't have any snippets yet, start a fetch.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (snippet->expiry_date() < next_expiry) 493 if (snippet->expiry_date() < next_expiry)
494 next_expiry = snippet->expiry_date(); 494 next_expiry = snippet->expiry_date();
495 } 495 }
496 DCHECK_GT(next_expiry, expiry); 496 DCHECK_GT(next_expiry, expiry);
497 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 497 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
498 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, 498 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished,
499 base::Unretained(this))); 499 base::Unretained(this)));
500 } 500 }
501 501
502 } // namespace ntp_snippets 502 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698