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

Unified Diff: chrome/browser/android/most_visited_sites.cc

Issue 1314493013: Popular sites on the NTP: add thumbnails! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android_clang_dbg_recipe build Created 5 years, 3 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 | « no previous file | chrome/browser/android/popular_sites.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/most_visited_sites.cc
diff --git a/chrome/browser/android/most_visited_sites.cc b/chrome/browser/android/most_visited_sites.cc
index f41b6e287c0d51de5fdba019a3e6c365e86f4aba..19216b2f77645e81a81ca1f85053ef599fd7042c 100644
--- a/chrome/browser/android/most_visited_sites.cc
+++ b/chrome/browser/android/most_visited_sites.cc
@@ -230,15 +230,31 @@ void MostVisitedSites::OnLocalThumbnailFetched(
scoped_refptr<TopSites> top_sites(TopSitesFactory::GetForProfile(profile_));
if (top_sites)
top_sites->AddForcedURL(url, base::Time::Now());
+ // Also fetch a remote thumbnail if possible. PopularSites or the
+ // SuggestionsService can supply a thumbnail download URL.
SuggestionsService* suggestions_service =
- (mv_source_ == SUGGESTIONS_SERVICE)
- ? SuggestionsServiceFactory::GetForProfile(profile_)
- : nullptr;
+ SuggestionsServiceFactory::GetForProfile(profile_);
if (suggestions_service) {
- return suggestions_service->GetPageThumbnail(
- url, base::Bind(&MostVisitedSites::OnObtainedThumbnail,
- weak_ptr_factory_.GetWeakPtr(), false,
- base::Passed(&j_callback)));
+ if (popular_sites_) {
+ const std::vector<PopularSites::Site>& sites = popular_sites_->sites();
+ auto it = std::find_if(sites.begin(), sites.end(),
+ [&url](const PopularSites::Site& site) {
+ return site.url == url;
+ });
+ if (it != sites.end() && it->thumbnail_url.is_valid()) {
+ return suggestions_service->GetPageThumbnailWithURL(
+ url, it->thumbnail_url,
+ base::Bind(&MostVisitedSites::OnObtainedThumbnail,
+ weak_ptr_factory_.GetWeakPtr(), false,
+ base::Passed(&j_callback)));
+ }
+ }
+ if (mv_source_ == SUGGESTIONS_SERVICE) {
+ return suggestions_service->GetPageThumbnail(
+ url, base::Bind(&MostVisitedSites::OnObtainedThumbnail,
+ weak_ptr_factory_.GetWeakPtr(), false,
+ base::Passed(&j_callback)));
+ }
}
}
OnObtainedThumbnail(true, j_callback.Pass(), url, bitmap.get());
« no previous file with comments | « no previous file | chrome/browser/android/popular_sites.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698