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

Side by Side Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2560783002: [NTP::PhysicalWeb] Implement suggestion dismissal. (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_snippets/content_suggestions_service.h" 5 #include "components/ntp_snippets/content_suggestions_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const ContentSuggestion::ID& suggestion_id) { 161 const ContentSuggestion::ID& suggestion_id) {
162 if (!providers_by_category_.count(suggestion_id.category())) { 162 if (!providers_by_category_.count(suggestion_id.category())) {
163 LOG(WARNING) << "Dismissed suggestion " << suggestion_id 163 LOG(WARNING) << "Dismissed suggestion " << suggestion_id
164 << " for unavailable category " << suggestion_id.category(); 164 << " for unavailable category " << suggestion_id.category();
165 return; 165 return;
166 } 166 }
167 providers_by_category_[suggestion_id.category()]->DismissSuggestion( 167 providers_by_category_[suggestion_id.category()]->DismissSuggestion(
168 suggestion_id); 168 suggestion_id);
169 169
170 // Remove the suggestion locally. 170 // Remove the suggestion locally.
171 bool removed = RemoveSuggestionByID(suggestion_id); 171 RemoveSuggestionByID(suggestion_id);
jkrcal 2016/12/07 14:20:01 Why did you remove the DCHECK?
vitaliii 2016/12/08 07:13:41 Because of it one could not dismiss suggestions ob
jkrcal 2016/12/08 09:55:42 Ok, please expand the comment.
vitaliii 2016/12/08 11:05:29 Done.
172 DCHECK(removed) << "The dismissed suggestion " << suggestion_id
173 << " has already been removed. Providers must not call"
174 << " OnNewSuggestions in response to DismissSuggestion.";
175 } 172 }
176 173
177 void ContentSuggestionsService::DismissCategory(Category category) { 174 void ContentSuggestionsService::DismissCategory(Category category) {
178 auto providers_it = providers_by_category_.find(category); 175 auto providers_it = providers_by_category_.find(category);
179 if (providers_it == providers_by_category_.end()) { 176 if (providers_it == providers_by_category_.end()) {
180 return; 177 return;
181 } 178 }
182 179
183 ContentSuggestionsProvider* provider = providers_it->second; 180 ContentSuggestionsProvider* provider = providers_it->second;
184 UnregisterCategory(category, provider); 181 UnregisterCategory(category, provider);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { 492 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() {
496 base::ListValue list; 493 base::ListValue list;
497 for (const auto& category_provider_pair : dismissed_providers_by_category_) { 494 for (const auto& category_provider_pair : dismissed_providers_by_category_) {
498 list.AppendInteger(category_provider_pair.first.id()); 495 list.AppendInteger(category_provider_pair.first.id());
499 } 496 }
500 497
501 pref_service_->Set(prefs::kDismissedCategories, list); 498 pref_service_->Set(prefs::kDismissedCategories, list);
502 } 499 }
503 500
504 } // namespace ntp_snippets 501 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698