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

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

Issue 2695713004: Add baked-in favicons for default popular sites on NTP (Closed)
Patch Set: Rebase. Created 3 years, 9 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
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // Skip tiles already present in personal or whitelists. 352 // Skip tiles already present in personal or whitelists.
353 if (hosts.find(host) != hosts.end()) 353 if (hosts.find(host) != hosts.end())
354 continue; 354 continue;
355 355
356 NTPTile tile; 356 NTPTile tile;
357 tile.title = popular_site.title; 357 tile.title = popular_site.title;
358 tile.url = GURL(popular_site.url); 358 tile.url = GURL(popular_site.url);
359 tile.source = NTPTileSource::POPULAR; 359 tile.source = NTPTileSource::POPULAR;
360 360
361 popular_sites_tiles.push_back(std::move(tile)); 361 popular_sites_tiles.push_back(std::move(tile));
362 icon_cacher_->StartFetch( 362 base::Closure icon_available =
363 popular_site, base::Bind(&MostVisitedSites::OnIconMadeAvailable, 363 base::Bind(&MostVisitedSites::OnIconMadeAvailable,
364 base::Unretained(this), popular_site.url)); 364 base::Unretained(this), popular_site.url);
365 icon_cacher_->StartFetch(popular_site, icon_available, icon_available);
365 if (popular_sites_tiles.size() >= num_popular_sites_tiles) 366 if (popular_sites_tiles.size() >= num_popular_sites_tiles)
366 break; 367 break;
367 } 368 }
368 } 369 }
369 return popular_sites_tiles; 370 return popular_sites_tiles;
370 } 371 }
371 372
372 void MostVisitedSites::SaveNewTiles(NTPTilesVector personal_tiles) { 373 void MostVisitedSites::SaveNewTiles(NTPTilesVector personal_tiles) {
373 NTPTilesVector whitelist_tiles = 374 NTPTilesVector whitelist_tiles =
374 CreateWhitelistEntryPointTiles(personal_tiles); 375 CreateWhitelistEntryPointTiles(personal_tiles);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 observer_->OnMostVisitedURLsAvailable(current_tiles_); 414 observer_->OnMostVisitedURLsAvailable(current_tiles_);
414 } 415 }
415 416
416 void MostVisitedSites::OnPopularSitesDownloaded(bool success) { 417 void MostVisitedSites::OnPopularSitesDownloaded(bool success) {
417 if (!success) { 418 if (!success) {
418 LOG(WARNING) << "Download of popular sites failed"; 419 LOG(WARNING) << "Download of popular sites failed";
419 return; 420 return;
420 } 421 }
421 } 422 }
422 423
423 void MostVisitedSites::OnIconMadeAvailable(const GURL& site_url, 424 void MostVisitedSites::OnIconMadeAvailable(const GURL& site_url) {
424 bool newly_available) { 425 observer_->OnIconMadeAvailable(site_url);
425 if (newly_available)
426 observer_->OnIconMadeAvailable(site_url);
427 } 426 }
428 427
429 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} 428 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {}
430 429
431 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 430 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
432 ChangeReason change_reason) { 431 ChangeReason change_reason) {
433 if (mv_source_ == NTPTileSource::TOP_SITES) { 432 if (mv_source_ == NTPTileSource::TOP_SITES) {
434 // The displayed tiles are invalidated. 433 // The displayed tiles are invalidated.
435 InitiateTopSitesQuery(); 434 InitiateTopSitesQuery();
436 } 435 }
437 } 436 }
438 437
439 } // namespace ntp_tiles 438 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/most_visited_sites_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698