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

Side by Side Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2926023003: Rename SupervisorBridge::whitelists() to GetWhiteLists(). (Closed)
Patch Set: Created 3 years, 6 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_tiles/most_visited_sites.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 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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (top_sites_weak_ptr_factory_.HasWeakPtrs()) 193 if (top_sites_weak_ptr_factory_.HasWeakPtrs())
194 return; // Ongoing query. 194 return; // Ongoing query.
195 top_sites_->GetMostVisitedURLs( 195 top_sites_->GetMostVisitedURLs(
196 base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable, 196 base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable,
197 top_sites_weak_ptr_factory_.GetWeakPtr()), 197 top_sites_weak_ptr_factory_.GetWeakPtr()),
198 false); 198 false);
199 } 199 }
200 200
201 base::FilePath MostVisitedSites::GetWhitelistLargeIconPath(const GURL& url) { 201 base::FilePath MostVisitedSites::GetWhitelistLargeIconPath(const GURL& url) {
202 if (supervisor_) { 202 if (supervisor_) {
203 for (const auto& whitelist : supervisor_->whitelists()) { 203 for (const auto& whitelist : supervisor_->GetWhitelists()) {
204 if (AreURLsEquivalent(whitelist.entry_point, url)) 204 if (AreURLsEquivalent(whitelist.entry_point, url))
205 return whitelist.large_icon_path; 205 return whitelist.large_icon_path;
206 } 206 }
207 } 207 }
208 return base::FilePath(); 208 return base::FilePath();
209 } 209 }
210 210
211 void MostVisitedSites::OnMostVisitedURLsAvailable( 211 void MostVisitedSites::OnMostVisitedURLsAvailable(
212 const history::MostVisitedURLList& visited_list) { 212 const history::MostVisitedURLList& visited_list) {
213 // Ignore the event if tiles provided by the Suggestions Service, which take 213 // Ignore the event if tiles provided by the Suggestions Service, which take
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 295 }
296 296
297 NTPTilesVector MostVisitedSites::CreateWhitelistEntryPointTiles( 297 NTPTilesVector MostVisitedSites::CreateWhitelistEntryPointTiles(
298 const std::set<std::string>& used_hosts, 298 const std::set<std::string>& used_hosts,
299 size_t num_actual_tiles) { 299 size_t num_actual_tiles) {
300 if (!supervisor_) { 300 if (!supervisor_) {
301 return NTPTilesVector(); 301 return NTPTilesVector();
302 } 302 }
303 303
304 NTPTilesVector whitelist_tiles; 304 NTPTilesVector whitelist_tiles;
305 for (const auto& whitelist : supervisor_->whitelists()) { 305 for (const auto& whitelist : supervisor_->GetWhitelists()) {
306 if (whitelist_tiles.size() + num_actual_tiles >= num_sites_) 306 if (whitelist_tiles.size() + num_actual_tiles >= num_sites_)
307 break; 307 break;
308 308
309 // Skip blacklisted sites. 309 // Skip blacklisted sites.
310 if (top_sites_ && top_sites_->IsBlacklisted(whitelist.entry_point)) 310 if (top_sites_ && top_sites_->IsBlacklisted(whitelist.entry_point))
311 continue; 311 continue;
312 312
313 // Skip tiles already present. 313 // Skip tiles already present.
314 if (used_hosts.find(whitelist.entry_point.host()) != used_hosts.end()) 314 if (used_hosts.find(whitelist.entry_point.host()) != used_hosts.end())
315 continue; 315 continue;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 std::set<std::string>* hosts, 492 std::set<std::string>* hosts,
493 size_t* total_tile_count) const { 493 size_t* total_tile_count) const {
494 for (const auto& tile : new_tiles) { 494 for (const auto& tile : new_tiles) {
495 hosts->insert(tile.url.host()); 495 hosts->insert(tile.url.host());
496 } 496 }
497 *total_tile_count += new_tiles.size(); 497 *total_tile_count += new_tiles.size();
498 DCHECK_LE(*total_tile_count, num_sites_); 498 DCHECK_LE(*total_tile_count, num_sites_);
499 } 499 }
500 500
501 } // namespace ntp_tiles 501 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698