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

Unified Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2584853002: ntp_tiles: Fix Top Sites potentially overriding Suggestions Service (Closed)
Patch Set: Rebased. Created 3 years, 11 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 | « no previous file | components/ntp_tiles/most_visited_sites_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/most_visited_sites.cc
diff --git a/components/ntp_tiles/most_visited_sites.cc b/components/ntp_tiles/most_visited_sites.cc
index 376c4e45a4fe181c474c30c9e1422174c8f07eff..47918739aca14ab147eb3cd8b53317b70c7b1cef 100644
--- a/components/ntp_tiles/most_visited_sites.cc
+++ b/components/ntp_tiles/most_visited_sites.cc
@@ -62,7 +62,7 @@ MostVisitedSites::MostVisitedSites(
observer_(nullptr),
num_sites_(0),
top_sites_observer_(this),
- mv_source_(NTPTileSource::SUGGESTIONS_SERVICE),
+ mv_source_(NTPTileSource::TOP_SITES),
weak_ptr_factory_(this) {
DCHECK(prefs_);
// top_sites_ can be null in tests.
@@ -187,8 +187,12 @@ base::FilePath MostVisitedSites::GetWhitelistLargeIconPath(const GURL& url) {
void MostVisitedSites::OnMostVisitedURLsAvailable(
const history::MostVisitedURLList& visited_list) {
- // TODO(mastiz): Verify if suggestion service results have been fetched in
- // the meantime, and if that's the case ignore this event.
+ // Ignore the event if tiles provided by the Suggestions Service, which take
+ // precedence.
+ if (mv_source_ == NTPTileSource::SUGGESTIONS_SERVICE) {
+ return;
+ }
+
NTPTilesVector tiles;
size_t num_tiles =
std::min(visited_list.size(), static_cast<size_t>(num_sites_));
@@ -221,6 +225,7 @@ void MostVisitedSites::OnSuggestionsProfileAvailable(
// With no server suggestions, fall back to local TopSites.
if (num_tiles == 0 ||
!base::FeatureList::IsEnabled(kDisplaySuggestionsServiceTiles)) {
+ mv_source_ = NTPTileSource::TOP_SITES;
InitiateTopSitesQuery();
return;
}
« no previous file with comments | « no previous file | components/ntp_tiles/most_visited_sites_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698