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

Unified Diff: components/ntp_tiles/popular_sites_impl.cc

Issue 2695713004: Add baked-in favicons for default popular sites on NTP (Closed)
Patch Set: Rebase. 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 6e443ab3718b911648397fa206f4d6d16dbb50c8..7777e37dc47718bdca635e405a29690262ee1137 100644
--- a/components/ntp_tiles/popular_sites_impl.cc
+++ b/components/ntp_tiles/popular_sites_impl.cc
@@ -130,21 +130,46 @@ 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_icon_resource",
+ &sites.back().default_icon_resource);
}
return sites;
}
+#if defined(GOOGLE_CHROME_BUILD) && (defined(OS_ANDROID) || defined(OS_IOS))
+void SetDefaultResourceForSite(int index,
+ int resource_id,
+ base::ListValue* sites) {
+ base::DictionaryValue* site;
+ if (!sites->GetDictionary(index, &site)) {
+ return;
+ }
+ site->SetInteger("default_icon_resource", 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)
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+ return base::MakeUnique<base::ListValue>();
+#else
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 icon_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(index++, icon_resource, sites.get());
+ }
+#endif // GOOGLE_CHROME_BUILD
return sites;
-#endif
- return base::MakeUnique<base::ListValue>();
+#endif // OS_ANDROID || OS_IOS
}
} // namespace
@@ -158,7 +183,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_icon_resource(-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