Add support for components/ntp_tiles in InstantService
This will allow us to get server-side suggestions on the local NTP.
BUG=514752
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
Review-Url: https://codereview.chromium.org/2532103002
Cr-Commit-Position: refs/heads/master@{#437576}
diff --git a/components/ntp_tiles/most_visited_sites.cc b/components/ntp_tiles/most_visited_sites.cc
index fe51e1d..397b9e4 100644
--- a/components/ntp_tiles/most_visited_sites.cc
+++ b/components/ntp_tiles/most_visited_sites.cc
@@ -109,6 +109,10 @@
// SuggestionsService's cache or, if that is empty, sites from TopSites.
BuildCurrentTiles();
// Also start a request for fresh suggestions.
+ Refresh();
+}
+
+void MostVisitedSites::Refresh() {
suggestions_service_->FetchSuggestionsData();
}
@@ -131,6 +135,18 @@
}
}
+void MostVisitedSites::ClearBlacklistedUrls() {
+ if (top_sites_) {
+ // Always update the blacklist in the local TopSites.
+ top_sites_->ClearBlacklistedURLs();
+ }
+
+ // Only update the server-side blacklist if it's active.
+ if (mv_source_ == NTPTileSource::SUGGESTIONS_SERVICE) {
+ suggestions_service_->ClearBlacklist();
+ }
+}
+
void MostVisitedSites::OnBlockedSitesChanged() {
BuildCurrentTiles();
}
@@ -219,6 +235,8 @@
tile.url = url;
tile.source = NTPTileSource::SUGGESTIONS_SERVICE;
tile.whitelist_icon_path = GetWhitelistLargeIconPath(url);
+ tile.thumbnail_url = GURL(suggestion_pb.thumbnail());
+ tile.favicon_url = GURL(suggestion_pb.favicon_url());
tiles.push_back(std::move(tile));
}