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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/feature_list.h" | 14 #include "base/feature_list.h" |
15 #include "base/metrics/user_metrics.h" | |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "components/history/core/browser/top_sites.h" | 17 #include "components/history/core/browser/top_sites.h" |
17 #include "components/ntp_tiles/constants.h" | 18 #include "components/ntp_tiles/constants.h" |
18 #include "components/ntp_tiles/field_trial.h" | 19 #include "components/ntp_tiles/field_trial.h" |
19 #include "components/ntp_tiles/icon_cacher.h" | 20 #include "components/ntp_tiles/icon_cacher.h" |
20 #include "components/ntp_tiles/pref_names.h" | 21 #include "components/ntp_tiles/pref_names.h" |
21 #include "components/ntp_tiles/switches.h" | 22 #include "components/ntp_tiles/switches.h" |
22 #include "components/pref_registry/pref_registry_syncable.h" | 23 #include "components/pref_registry/pref_registry_syncable.h" |
23 #include "components/prefs/pref_service.h" | 24 #include "components/prefs/pref_service.h" |
24 | 25 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 // Also start a request for fresh suggestions. | 128 // Also start a request for fresh suggestions. |
128 Refresh(); | 129 Refresh(); |
129 } | 130 } |
130 | 131 |
131 void MostVisitedSites::Refresh() { | 132 void MostVisitedSites::Refresh() { |
132 suggestions_service_->FetchSuggestionsData(); | 133 suggestions_service_->FetchSuggestionsData(); |
133 } | 134 } |
134 | 135 |
135 void MostVisitedSites::AddOrRemoveBlacklistedUrl(const GURL& url, | 136 void MostVisitedSites::AddOrRemoveBlacklistedUrl(const GURL& url, |
136 bool add_url) { | 137 bool add_url) { |
138 if (add_url) { | |
Marc Treib
2017/05/05 16:05:39
nit: Maybe it's time to combine the now-three "if
dgn
2017/05/08 12:40:50
Do you mind if I do that in a separate patch? I ca
Marc Treib
2017/05/08 12:46:20
I just meant to reorder things within this method:
dgn
2017/05/08 13:40:35
yeah but because of the style guide you have to ad
| |
139 base::RecordAction(base::UserMetricsAction("Suggestions.Site.Removed")); | |
140 } else { | |
141 base::RecordAction( | |
142 base::UserMetricsAction("Suggestions.Site.RemovalUndone")); | |
143 } | |
144 | |
137 if (top_sites_) { | 145 if (top_sites_) { |
138 // Always blacklist in the local TopSites. | 146 // Always blacklist in the local TopSites. |
139 if (add_url) | 147 if (add_url) |
140 top_sites_->AddBlacklistedURL(url); | 148 top_sites_->AddBlacklistedURL(url); |
141 else | 149 else |
142 top_sites_->RemoveBlacklistedURL(url); | 150 top_sites_->RemoveBlacklistedURL(url); |
143 } | 151 } |
144 | 152 |
145 // Only blacklist in the server-side suggestions service if it's active. | 153 // Only blacklist in the server-side suggestions service if it's active. |
146 if (mv_source_ == TileSource::SUGGESTIONS_SERVICE) { | 154 if (mv_source_ == TileSource::SUGGESTIONS_SERVICE) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 | 442 |
435 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, | 443 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, |
436 ChangeReason change_reason) { | 444 ChangeReason change_reason) { |
437 if (mv_source_ == TileSource::TOP_SITES) { | 445 if (mv_source_ == TileSource::TOP_SITES) { |
438 // The displayed tiles are invalidated. | 446 // The displayed tiles are invalidated. |
439 InitiateTopSitesQuery(); | 447 InitiateTopSitesQuery(); |
440 } | 448 } |
441 } | 449 } |
442 | 450 |
443 } // namespace ntp_tiles | 451 } // namespace ntp_tiles |
OLD | NEW |