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

Unified Diff: components/ntp_tiles/popular_sites_impl.cc

Issue 2695713004: Add baked-in favicons for default popular sites on NTP (Closed)
Patch Set: Fix iOS images and resize only if necessary. Created 3 years, 10 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/popular_sites.h ('k') | components/ntp_tiles/popular_sites_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/popular_sites_impl.cc
diff --git a/components/ntp_tiles/popular_sites_impl.cc b/components/ntp_tiles/popular_sites_impl.cc
index 566202b07d88c8cc228312ce4c98dbf0a5776b03..d951bd96ff4e680486f8f414bfed6279569fd8ab 100644
--- a/components/ntp_tiles/popular_sites_impl.cc
+++ b/components/ntp_tiles/popular_sites_impl.cc
@@ -129,10 +129,23 @@ PopularSites::SitesVector ParseSiteList(const base::ListValue& list) {
sites.emplace_back(title, GURL(url), GURL(favicon_url),
GURL(large_icon_url), GURL(thumbnail_url));
+ item->GetInteger("default_resource_id", &sites.back().default_resource_id);
}
return sites;
}
+#if defined(OS_ANDROID) || defined(OS_IOS)
+void SetDefaultResourceForSite(base::ListValue* sites,
+ int index,
+ int resource_id) {
+ base::DictionaryValue* site;
+ if (!sites->GetDictionary(index, &site)) {
+ return;
+ }
+ site->SetInteger("default_resource_id", resource_id);
+}
+#endif
+
// Creates the list of popular sites based on a snapshot available for mobile.
std::unique_ptr<base::ListValue> DefaultPopularSites() {
#if defined(OS_ANDROID) || defined(OS_IOS)
@@ -141,6 +154,15 @@ std::unique_ptr<base::ListValue> DefaultPopularSites() {
ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DEFAULT_POPULAR_SITES_JSON)));
DCHECK(sites);
+ int index = 0;
+ for (int resource :
+ {IDR_DEFAULT_POPULAR_SITES_ICON0, IDR_DEFAULT_POPULAR_SITES_ICON1,
+ IDR_DEFAULT_POPULAR_SITES_ICON2, IDR_DEFAULT_POPULAR_SITES_ICON3,
+ IDR_DEFAULT_POPULAR_SITES_ICON4, IDR_DEFAULT_POPULAR_SITES_ICON5,
+ IDR_DEFAULT_POPULAR_SITES_ICON6, IDR_DEFAULT_POPULAR_SITES_ICON7}) {
+ SetDefaultResourceForSite(sites.get(), index++, resource);
+ }
+
return sites;
#endif
return base::MakeUnique<base::ListValue>();
@@ -157,7 +179,8 @@ PopularSites::Site::Site(const base::string16& title,
url(url),
favicon_url(favicon_url),
large_icon_url(large_icon_url),
- thumbnail_url(thumbnail_url) {}
+ thumbnail_url(thumbnail_url),
+ default_resource_id(-1) {}
PopularSites::Site::Site(const Site& other) = default;
« no previous file with comments | « components/ntp_tiles/popular_sites.h ('k') | components/ntp_tiles/popular_sites_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698