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

Unified Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2388783004: Ensure PopularSite icon availability in ntp_tiles. (Closed)
Patch Set: Merge branch 'master' into icons Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/popular_sites.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/most_visited_sites.cc
diff --git a/components/ntp_tiles/most_visited_sites.cc b/components/ntp_tiles/most_visited_sites.cc
index a3ecc9b5e27079e2b7b810e78ea5276d945d2988..3eb145841396fa2d400fbcc5a256f117a1dc7bec 100644
--- a/components/ntp_tiles/most_visited_sites.cc
+++ b/components/ntp_tiles/most_visited_sites.cc
@@ -21,6 +21,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/history/core/browser/top_sites.h"
#include "components/ntp_tiles/constants.h"
+#include "components/ntp_tiles/icon_cacher.h"
#include "components/ntp_tiles/metrics.h"
#include "components/ntp_tiles/pref_names.h"
#include "components/ntp_tiles/switches.h"
@@ -84,11 +85,13 @@ MostVisitedSites::MostVisitedSites(PrefService* prefs,
scoped_refptr<history::TopSites> top_sites,
SuggestionsService* suggestions,
std::unique_ptr<PopularSites> popular_sites,
+ std::unique_ptr<IconCacher> icon_cacher,
MostVisitedSitesSupervisor* supervisor)
: prefs_(prefs),
top_sites_(top_sites),
suggestions_service_(suggestions),
popular_sites_(std::move(popular_sites)),
+ icon_cacher_(std::move(icon_cacher)),
supervisor_(supervisor),
observer_(nullptr),
num_sites_(0),
@@ -345,6 +348,9 @@ NTPTilesVector MostVisitedSites::CreatePopularSitesTiles(
tile.source = NTPTileSource::POPULAR;
popular_sites_tiles.push_back(std::move(tile));
+ icon_cacher_->StartFetch(
+ popular_site, base::Bind(&MostVisitedSites::OnIconMadeAvailable,
+ base::Unretained(this), popular_site.url));
if (popular_sites_tiles.size() >= num_popular_sites_tiles)
break;
}
@@ -410,14 +416,16 @@ void MostVisitedSites::OnPopularSitesAvailable(bool success) {
return;
}
- // Pass the popular sites to the observer. This will cause it to fetch any
- // missing icons, but will *not* cause it to display the popular sites.
- observer_->OnPopularURLsAvailable(popular_sites_->sites());
-
// Re-build the tile list. Once done, this will notify the observer.
BuildCurrentTiles();
}
+void MostVisitedSites::OnIconMadeAvailable(const GURL& site_url,
+ bool newly_available) {
+ if (newly_available)
+ observer_->OnIconMadeAvailable(site_url);
+}
+
void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {}
void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/popular_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698