Chromium Code Reviews| 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..707c5fe8c599725447ec49afbe492d70b2c8d93d 100644 |
| --- a/components/ntp_tiles/popular_sites_impl.cc |
| +++ b/components/ntp_tiles/popular_sites_impl.cc |
| @@ -130,10 +130,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(GOOGLE_CHROME_BUILD) && (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,9 +154,19 @@ std::unique_ptr<base::ListValue> DefaultPopularSites() { |
| base::ListValue::From(base::JSONReader().ReadToValue( |
|
Marc Treib
2017/02/27 12:41:49
Just use the static Read() instead of creating a J
fhorschig
2017/02/28 13:13:12
Done.
|
| ResourceBundle::GetSharedInstance().GetRawDataResource( |
| IDR_DEFAULT_POPULAR_SITES_JSON))); |
| +#if defined(GOOGLE_CHROME_BUILD) |
| DCHECK(sites); |
|
Marc Treib
2017/02/27 12:41:49
Put this outside the #if ?
fhorschig
2017/02/28 13:13:12
Done.
|
| + 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); |
| + } |
| +#endif // GOOGLE_CHROME_BUILD |
| return sites; |
| -#endif |
| +#endif // OS_ANDROID || OS_IOS |
| return base::MakeUnique<base::ListValue>(); |
|
Marc Treib
2017/02/27 12:41:49
Should this be in an #else? Otherwise I'd expect "
fhorschig
2017/02/28 13:13:12
It is now, but there haven't been warnings.
|
| } |
| @@ -158,7 +181,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; |