Chromium Code Reviews| Index: components/ntp_snippets/content_suggestions_service.cc |
| diff --git a/components/ntp_snippets/content_suggestions_service.cc b/components/ntp_snippets/content_suggestions_service.cc |
| index 43ee91ef2542ea02ef3d1af0723761ffe8b84ee5..ab6839db0f05d28920730adb8c3293e946c095be 100644 |
| --- a/components/ntp_snippets/content_suggestions_service.cc |
| +++ b/components/ntp_snippets/content_suggestions_service.cc |
| @@ -79,19 +79,42 @@ void ContentSuggestionsService::FetchSuggestionImage( |
| callback); |
| } |
| -void ContentSuggestionsService::ClearCachedSuggestionsForDebugging() { |
| +void ContentSuggestionsService::ClearAllCachedSuggestionsForDebugging() { |
| suggestions_by_category_.clear(); |
| id_category_map_.clear(); |
| for (auto& category_provider_pair : providers_by_category_) { |
|
Marc Treib
2016/08/08 13:52:09
const auto&
Philipp Keck
2016/08/08 14:15:09
Done.
|
| - category_provider_pair.second->ClearCachedSuggestionsForDebugging(); |
| + category_provider_pair.second->ClearCachedSuggestionsForDebugging( |
| + category_provider_pair.first); |
| } |
| FOR_EACH_OBSERVER(Observer, observers_, OnNewSuggestions()); |
| } |
| -void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging() { |
| - for (auto& category_provider_pair : providers_by_category_) { |
| - category_provider_pair.second->ClearDismissedSuggestionsForDebugging(); |
| +void ContentSuggestionsService::ClearCachedSuggestionsForDebugging( |
| + Category category) { |
| + for (const ContentSuggestion& suggestion : |
| + suggestions_by_category_[category]) { |
| + id_category_map_.erase(suggestion.id()); |
| } |
| + suggestions_by_category_[category] = std::vector<ContentSuggestion>(); |
|
Marc Treib
2016/08/08 13:52:09
.clear()
?
Philipp Keck
2016/08/08 14:15:09
Done.
|
| + auto iterator = providers_by_category_.find(category); |
| + if (iterator != providers_by_category_.end()) |
| + iterator->second->ClearCachedSuggestionsForDebugging(category); |
| +} |
| + |
| +std::vector<ContentSuggestion> |
| +ContentSuggestionsService::GetDismissedSuggestionsForDebugging( |
| + Category category) { |
| + auto iterator = providers_by_category_.find(category); |
| + if (iterator == providers_by_category_.end()) |
| + return std::vector<ContentSuggestion>(); |
| + return iterator->second->GetDismissedSuggestionsForDebugging(category); |
| +} |
| + |
| +void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging( |
| + Category category) { |
| + auto iterator = providers_by_category_.find(category); |
| + if (iterator != providers_by_category_.end()) |
| + iterator->second->ClearDismissedSuggestionsForDebugging(category); |
| } |
| void ContentSuggestionsService::DismissSuggestion( |