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

Unified Diff: components/ntp_tiles/popular_sites_impl.cc

Issue 2695713004: Add baked-in favicons for default popular sites on NTP (Closed)
Patch Set: 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 34fa0274a06fdae706fd592b9930bb656fe5d22b..eff5c9c54090a7e2628b304887220c15fed6c4e5 100644
--- a/components/ntp_tiles/popular_sites_impl.cc
+++ b/components/ntp_tiles/popular_sites_impl.cc
@@ -17,6 +17,8 @@
#include "base/time/time.h"
#include "base/values.h"
#include "components/data_use_measurement/core/data_use_user_data.h"
+#include "components/favicon/core/favicon_service.h"
+#include "components/favicon_base/favicon_types.h"
#include "components/google/core/browser/google_util.h"
#include "components/ntp_tiles/constants.h"
#include "components/ntp_tiles/field_trial.h"
@@ -134,11 +136,52 @@ PopularSites::SitesVector ParseSiteList(const base::ListValue& list) {
// This allows instantiation of PopularSites without registered prefs.
// That case can occur during tests.
-PopularSites::SitesVector GetDefaultFromPrefs(const PrefService& prefs) {
+PopularSites::SitesVector GetDefaultFromPrefs(
jkrcal 2017/02/14 08:23:06 drive-by comment: When is this function called? Y
sfiera 2017/02/14 09:59:16 Even in the absence of sync, I think this implemen
fhorschig 2017/02/14 17:29:02 Good remark. It's now called by the IconCacher whi
+ const PrefService& prefs,
+ favicon::FaviconService* favicons) {
if (!ShouldShowPopularSites()) {
return PopularSites::SitesVector();
}
- return ParseSiteList(*prefs.GetList(kPopularSitesJsonPref));
+ PopularSites::SitesVector sites =
+ ParseSiteList(*prefs.GetList(kPopularSitesJsonPref));
+#if defined(OS_ANDROID) || defined(OS_IOS)
tschumann 2017/02/14 11:56:51 i wonder why is this part only relevant to mobile
fhorschig 2017/02/14 17:29:02 It used to load the defaults and if on mobile, reg
+ if (!favicons) {
+ return sites;
+ }
+ favicons->SetFavicons(sites[0].url, sites[0].large_icon_url,
tschumann 2017/02/14 11:56:51 +mastiz who looked into this. Feels weird to set t
mastiz 2017/02/14 14:44:59 This comment seems obsolete now. Please loop me in
fhorschig 2017/02/14 17:29:02 Like Jan and Chris have pointed out, this was neit
fhorschig 2017/02/14 17:29:02 Absolutely. It seems to be quite an interesting CL
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON0));
+ favicons->SetFavicons(sites[1].url, sites[1].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON1));
+ favicons->SetFavicons(sites[2].url, sites[2].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON2));
+ favicons->SetFavicons(sites[3].url, sites[3].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON3));
+ favicons->SetFavicons(sites[4].url, sites[4].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON4));
+ favicons->SetFavicons(sites[5].url, sites[5].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON5));
+ favicons->SetFavicons(sites[6].url, sites[6].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON6));
+ favicons->SetFavicons(sites[7].url, sites[7].large_icon_url,
+ favicon_base::IconType::FAVICON,
+ ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_POPULAR_SITES_ICON7));
+#endif
+ return sites;
}
// Creates the List of popular sites based on a snapshot available for mobile.
@@ -176,6 +219,7 @@ PopularSitesImpl::PopularSitesImpl(
PrefService* prefs,
const TemplateURLService* template_url_service,
VariationsService* variations_service,
+ favicon::FaviconService* favicon_service,
net::URLRequestContextGetter* download_context,
const base::FilePath& directory,
ParseJSONCallback parse_json)
@@ -187,7 +231,7 @@ PopularSitesImpl::PopularSitesImpl(
download_context_(download_context),
parse_json_(std::move(parse_json)),
is_fallback_(false),
- sites_(GetDefaultFromPrefs(*prefs_)),
+ sites_(GetDefaultFromPrefs(*prefs_, favicon_service)),
sfiera 2017/02/14 09:59:16 Initializing the favicon service in PopularSitesIm
fhorschig 2017/02/14 17:29:02 Agreed and removed.
weak_ptr_factory_(this) {
// If valid path provided, remove local files created by older versions.
if (!directory.empty() && blocking_runner_) {

Powered by Google App Engine
This is Rietveld 408576698