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

Side by Side Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2572133002: Add more features to ntp-tiles-internal (Closed)
Patch Set: Add ntp_tiles owners to client webui owners 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_tiles/most_visited_sites.h" 5 #include "components/ntp_tiles/most_visited_sites.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 DCHECK(suggestions_service_); 71 DCHECK(suggestions_service_);
72 if (supervisor_) 72 if (supervisor_)
73 supervisor_->SetObserver(this); 73 supervisor_->SetObserver(this);
74 } 74 }
75 75
76 MostVisitedSites::~MostVisitedSites() { 76 MostVisitedSites::~MostVisitedSites() {
77 if (supervisor_) 77 if (supervisor_)
78 supervisor_->SetObserver(nullptr); 78 supervisor_->SetObserver(nullptr);
79 } 79 }
80 80
81 bool MostVisitedSites::DoesSourceExist(NTPTileSource source) const {
82 switch (source) {
83 case NTPTileSource::TOP_SITES:
84 return top_sites_ != nullptr;
85 case NTPTileSource::SUGGESTIONS_SERVICE:
86 return suggestions_service_ != nullptr;
87 case NTPTileSource::POPULAR:
88 return popular_sites_ != nullptr;
89 case NTPTileSource::WHITELIST:
90 return supervisor_ != nullptr;
91 }
92 NOTREACHED();
93 return false;
94 }
95
81 void MostVisitedSites::SetMostVisitedURLsObserver(Observer* observer, 96 void MostVisitedSites::SetMostVisitedURLsObserver(Observer* observer,
82 int num_sites) { 97 int num_sites) {
83 DCHECK(observer); 98 DCHECK(observer);
84 observer_ = observer; 99 observer_ = observer;
85 num_sites_ = num_sites; 100 num_sites_ = num_sites;
86 101
87 // The order for this condition is important, ShouldShowPopularSites() should 102 // The order for this condition is important, ShouldShowPopularSites() should
88 // always be called last to keep metrics as relevant as possible. 103 // always be called last to keep metrics as relevant as possible.
89 if (popular_sites_ && NeedPopularSites(prefs_, num_sites_) && 104 if (popular_sites_ && NeedPopularSites(prefs_, num_sites_) &&
90 ShouldShowPopularSites()) { 105 ShouldShowPopularSites()) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 434
420 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 435 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
421 ChangeReason change_reason) { 436 ChangeReason change_reason) {
422 if (mv_source_ == NTPTileSource::TOP_SITES) { 437 if (mv_source_ == NTPTileSource::TOP_SITES) {
423 // The displayed tiles are invalidated. 438 // The displayed tiles are invalidated.
424 InitiateTopSitesQuery(); 439 InitiateTopSitesQuery();
425 } 440 }
426 } 441 }
427 442
428 } // namespace ntp_tiles 443 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/webui/ntp_tiles_internals_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698