Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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_) { |
|
Marc Treib
2016/05/17 15:23:58
Should we (in another CL) make UseHostRestriction
jkrcal
2016/05/18 08:30:39
I agree, in a separate CL.
Heh, I've forgotten to
| |
| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 if (snippet->expiry_date() < next_expiry) | 498 if (snippet->expiry_date() < next_expiry) |
| 499 next_expiry = snippet->expiry_date(); | 499 next_expiry = snippet->expiry_date(); |
| 500 } | 500 } |
| 501 DCHECK_GT(next_expiry, expiry); | 501 DCHECK_GT(next_expiry, expiry); |
| 502 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, | 502 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, |
| 503 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, | 503 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, |
| 504 base::Unretained(this))); | 504 base::Unretained(this))); |
| 505 } | 505 } |
| 506 | 506 |
| 507 } // namespace ntp_snippets | 507 } // namespace ntp_snippets |
| OLD | NEW |