OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_tiles/most_visited_sites.h" | 5 #include "components/ntp_tiles/most_visited_sites.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // static | 154 // static |
155 void MostVisitedSites::RegisterProfilePrefs( | 155 void MostVisitedSites::RegisterProfilePrefs( |
156 user_prefs::PrefRegistrySyncable* registry) { | 156 user_prefs::PrefRegistrySyncable* registry) { |
157 registry->RegisterIntegerPref(prefs::kNumPersonalTiles, 0); | 157 registry->RegisterIntegerPref(prefs::kNumPersonalTiles, 0); |
158 } | 158 } |
159 | 159 |
160 void MostVisitedSites::BuildCurrentTiles() { | 160 void MostVisitedSites::BuildCurrentTiles() { |
161 // Get the current suggestions from cache. If the cache is empty, this will | 161 // Get the current suggestions from cache. If the cache is empty, this will |
162 // fall back to TopSites. | 162 // fall back to TopSites. |
163 OnSuggestionsProfileAvailable( | 163 OnSuggestionsProfileAvailable( |
164 suggestions_service_->GetSuggestionsDataFromCache()); | 164 suggestions_service_->GetSuggestionsDataFromCache().value_or( |
| 165 SuggestionsProfile())); |
165 } | 166 } |
166 | 167 |
167 void MostVisitedSites::InitiateTopSitesQuery() { | 168 void MostVisitedSites::InitiateTopSitesQuery() { |
168 if (!top_sites_) | 169 if (!top_sites_) |
169 return; | 170 return; |
170 top_sites_->GetMostVisitedURLs( | 171 top_sites_->GetMostVisitedURLs( |
171 base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable, | 172 base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable, |
172 weak_ptr_factory_.GetWeakPtr()), | 173 weak_ptr_factory_.GetWeakPtr()), |
173 false); | 174 false); |
174 } | 175 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 401 |
401 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, | 402 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, |
402 ChangeReason change_reason) { | 403 ChangeReason change_reason) { |
403 if (mv_source_ == NTPTileSource::TOP_SITES) { | 404 if (mv_source_ == NTPTileSource::TOP_SITES) { |
404 // The displayed tiles are invalidated. | 405 // The displayed tiles are invalidated. |
405 InitiateTopSitesQuery(); | 406 InitiateTopSitesQuery(); |
406 } | 407 } |
407 } | 408 } |
408 | 409 |
409 } // namespace ntp_tiles | 410 } // namespace ntp_tiles |
OLD | NEW |