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

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

Issue 2668943002: provide static popular sites for first run (Closed)
Patch Set: Add dependencies. Protect access with field_trial 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
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | components/ntp_tiles/popular_sites_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 whitelist_tiles.push_back(std::move(tile)); 319 whitelist_tiles.push_back(std::move(tile));
320 } 320 }
321 321
322 return whitelist_tiles; 322 return whitelist_tiles;
323 } 323 }
324 324
325 NTPTilesVector MostVisitedSites::CreatePopularSitesTiles( 325 NTPTilesVector MostVisitedSites::CreatePopularSitesTiles(
326 const NTPTilesVector& personal_tiles, 326 const NTPTilesVector& personal_tiles,
327 const NTPTilesVector& whitelist_tiles) { 327 const NTPTilesVector& whitelist_tiles) {
328 // For child accounts popular sites tiles will not be added. 328 // For child accounts popular sites tiles will not be added.
329 if (supervisor_ && supervisor_->IsChildProfile()) 329 if ((supervisor_ && supervisor_->IsChildProfile()) ||
330 !ShouldShowPopularSites())
sfiera 2017/02/13 15:05:54 I think this should be in the lower if-statement,
fhorschig 2017/02/13 18:13:44 Okay.
330 return NTPTilesVector(); 331 return NTPTilesVector();
331 332
332 size_t num_tiles = personal_tiles.size() + whitelist_tiles.size(); 333 size_t num_tiles = personal_tiles.size() + whitelist_tiles.size();
333 DCHECK_LE(num_tiles, static_cast<size_t>(num_sites_)); 334 DCHECK_LE(num_tiles, static_cast<size_t>(num_sites_));
334 335
335 // Collect non-blacklisted popular suggestions, skipping those already present 336 // Collect non-blacklisted popular suggestions, skipping those already present
336 // in the personal suggestions. 337 // in the personal suggestions.
337 size_t num_popular_sites_tiles = num_sites_ - num_tiles; 338 size_t num_popular_sites_tiles = num_sites_ - num_tiles;
338 NTPTilesVector popular_sites_tiles; 339 NTPTilesVector popular_sites_tiles;
339 340
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 return; 411 return;
411 412
412 observer_->OnMostVisitedURLsAvailable(current_tiles_); 413 observer_->OnMostVisitedURLsAvailable(current_tiles_);
413 } 414 }
414 415
415 void MostVisitedSites::OnPopularSitesDownloaded(bool success) { 416 void MostVisitedSites::OnPopularSitesDownloaded(bool success) {
416 if (!success) { 417 if (!success) {
417 LOG(WARNING) << "Download of popular sites failed"; 418 LOG(WARNING) << "Download of popular sites failed";
418 return; 419 return;
419 } 420 }
420
421 // Re-build the tile list. Once done, this will notify the observer.
422 BuildCurrentTiles();
423 } 421 }
424 422
425 void MostVisitedSites::OnIconMadeAvailable(const GURL& site_url, 423 void MostVisitedSites::OnIconMadeAvailable(const GURL& site_url,
426 bool newly_available) { 424 bool newly_available) {
427 if (newly_available) 425 if (newly_available)
428 observer_->OnIconMadeAvailable(site_url); 426 observer_->OnIconMadeAvailable(site_url);
429 } 427 }
430 428
431 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} 429 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {}
432 430
433 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 431 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
434 ChangeReason change_reason) { 432 ChangeReason change_reason) {
435 if (mv_source_ == NTPTileSource::TOP_SITES) { 433 if (mv_source_ == NTPTileSource::TOP_SITES) {
436 // The displayed tiles are invalidated. 434 // The displayed tiles are invalidated.
437 InitiateTopSitesQuery(); 435 InitiateTopSitesQuery();
438 } 436 }
439 } 437 }
440 438
441 } // namespace ntp_tiles 439 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | components/ntp_tiles/popular_sites_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698