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

Unified Diff: components/ntp_tiles/popular_sites_impl.cc

Issue 2695713004: Add baked-in favicons for default popular sites on NTP (Closed)
Patch Set: Drop bool from callback 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
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 6e443ab3718b911648397fa206f4d6d16dbb50c8..39b060ccb1dd9722dbf3231da100d950a90de7f9 100644
--- a/components/ntp_tiles/popular_sites_impl.cc
+++ b/components/ntp_tiles/popular_sites_impl.cc
@@ -130,21 +130,45 @@ 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(GOOGLE_CHROME_BUILD) && (defined(OS_ANDROID) || defined(OS_IOS))
+void SetDefaultResourceForSite(base::ListValue* sites,
mastiz 2017/03/01 08:48:12 Nit: output params should be last according to the
fhorschig 2017/03/01 20:57:36 Done.
+ 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)
mastiz 2017/03/01 08:48:12 Nit: how about inverting this logic and returning
fhorschig 2017/03/01 20:57:36 Done.
std::unique_ptr<base::ListValue> sites =
- base::ListValue::From(base::JSONReader().ReadToValue(
+ base::ListValue::From(base::JSONReader::Read(
ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DEFAULT_POPULAR_SITES_JSON)));
DCHECK(sites);
+#if defined(GOOGLE_CHROME_BUILD)
+ int index = 0;
+ for (int resource :
mastiz 2017/03/01 08:48:12 Nit: rename to resource_id for consistency with th
fhorschig 2017/03/01 20:57:36 Done.
+ {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);
+ }
+#endif // GOOGLE_CHROME_BUILD
return sites;
-#endif
+#else
return base::MakeUnique<base::ListValue>();
+#endif // OS_ANDROID || OS_IOS
}
} // namespace
@@ -158,7 +182,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;

Powered by Google App Engine
This is Rietveld 408576698