OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 return prefs->GetInteger(prefs::kNumPersonalTiles) < num_tiles; | 39 return prefs->GetInteger(prefs::kNumPersonalTiles) < num_tiles; |
40 } | 40 } |
41 | 41 |
42 bool AreURLsEquivalent(const GURL& url1, const GURL& url2) { | 42 bool AreURLsEquivalent(const GURL& url1, const GURL& url2) { |
43 return url1.host_piece() == url2.host_piece() && | 43 return url1.host_piece() == url2.host_piece() && |
44 url1.path_piece() == url2.path_piece(); | 44 url1.path_piece() == url2.path_piece(); |
45 } | 45 } |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 MostVisitedSites::MostVisitedSites(PrefService* prefs, | 49 MostVisitedSites::MostVisitedSites( |
50 scoped_refptr<history::TopSites> top_sites, | 50 PrefService* prefs, |
51 SuggestionsService* suggestions, | 51 scoped_refptr<history::TopSites> top_sites, |
52 std::unique_ptr<PopularSites> popular_sites, | 52 SuggestionsService* suggestions, |
53 std::unique_ptr<IconCacher> icon_cacher, | 53 std::unique_ptr<PopularSites> popular_sites, |
54 MostVisitedSitesSupervisor* supervisor) | 54 std::unique_ptr<IconCacher> icon_cacher, |
| 55 std::unique_ptr<MostVisitedSitesSupervisor> supervisor) |
55 : prefs_(prefs), | 56 : prefs_(prefs), |
56 top_sites_(top_sites), | 57 top_sites_(top_sites), |
57 suggestions_service_(suggestions), | 58 suggestions_service_(suggestions), |
58 popular_sites_(std::move(popular_sites)), | 59 popular_sites_(std::move(popular_sites)), |
59 icon_cacher_(std::move(icon_cacher)), | 60 icon_cacher_(std::move(icon_cacher)), |
60 supervisor_(supervisor), | 61 supervisor_(std::move(supervisor)), |
61 observer_(nullptr), | 62 observer_(nullptr), |
62 num_sites_(0), | 63 num_sites_(0), |
63 top_sites_observer_(this), | 64 top_sites_observer_(this), |
64 mv_source_(NTPTileSource::SUGGESTIONS_SERVICE), | 65 mv_source_(NTPTileSource::SUGGESTIONS_SERVICE), |
65 weak_ptr_factory_(this) { | 66 weak_ptr_factory_(this) { |
66 DCHECK(prefs_); | 67 DCHECK(prefs_); |
67 // top_sites_ can be null in tests. | 68 // top_sites_ can be null in tests. |
68 // TODO(sfiera): have iOS use a dummy TopSites in its tests. | 69 // TODO(sfiera): have iOS use a dummy TopSites in its tests. |
69 DCHECK(suggestions_service_); | 70 DCHECK(suggestions_service_); |
70 if (supervisor_) | 71 if (supervisor_) |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 401 |
401 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, | 402 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, |
402 ChangeReason change_reason) { | 403 ChangeReason change_reason) { |
403 if (mv_source_ == NTPTileSource::TOP_SITES) { | 404 if (mv_source_ == NTPTileSource::TOP_SITES) { |
404 // The displayed tiles are invalidated. | 405 // The displayed tiles are invalidated. |
405 InitiateTopSitesQuery(); | 406 InitiateTopSitesQuery(); |
406 } | 407 } |
407 } | 408 } |
408 | 409 |
409 } // namespace ntp_tiles | 410 } // namespace ntp_tiles |
OLD | NEW |