| OLD | NEW |
| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 for (const ContentSuggestion& suggestion : | 97 for (const ContentSuggestion& suggestion : |
| 98 suggestions_by_category_[category]) { | 98 suggestions_by_category_[category]) { |
| 99 id_category_map_.erase(suggestion.id()); | 99 id_category_map_.erase(suggestion.id()); |
| 100 } | 100 } |
| 101 suggestions_by_category_[category].clear(); | 101 suggestions_by_category_[category].clear(); |
| 102 auto iterator = providers_by_category_.find(category); | 102 auto iterator = providers_by_category_.find(category); |
| 103 if (iterator != providers_by_category_.end()) | 103 if (iterator != providers_by_category_.end()) |
| 104 iterator->second->ClearCachedSuggestionsForDebugging(category); | 104 iterator->second->ClearCachedSuggestionsForDebugging(category); |
| 105 } | 105 } |
| 106 | 106 |
| 107 std::vector<ContentSuggestion> | 107 void ContentSuggestionsService::GetDismissedSuggestionsForDebugging( |
| 108 ContentSuggestionsService::GetDismissedSuggestionsForDebugging( | 108 Category category, |
| 109 Category category) { | 109 const DismissedSuggestionsCallback& callback) { |
| 110 auto iterator = providers_by_category_.find(category); | 110 auto iterator = providers_by_category_.find(category); |
| 111 if (iterator == providers_by_category_.end()) | 111 if (iterator != providers_by_category_.end()) |
| 112 return std::vector<ContentSuggestion>(); | 112 iterator->second->GetDismissedSuggestionsForDebugging(category, callback); |
| 113 return iterator->second->GetDismissedSuggestionsForDebugging(category); | 113 else |
| 114 callback.Run(std::vector<ContentSuggestion>()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging( | 117 void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging( |
| 117 Category category) { | 118 Category category) { |
| 118 auto iterator = providers_by_category_.find(category); | 119 auto iterator = providers_by_category_.find(category); |
| 119 if (iterator != providers_by_category_.end()) | 120 if (iterator != providers_by_category_.end()) |
| 120 iterator->second->ClearDismissedSuggestionsForDebugging(category); | 121 iterator->second->ClearDismissedSuggestionsForDebugging(category); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void ContentSuggestionsService::DismissSuggestion( | 124 void ContentSuggestionsService::DismissSuggestion( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return true; | 261 return true; |
| 261 } | 262 } |
| 262 | 263 |
| 263 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { | 264 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { |
| 264 FOR_EACH_OBSERVER( | 265 FOR_EACH_OBSERVER( |
| 265 Observer, observers_, | 266 Observer, observers_, |
| 266 OnCategoryStatusChanged(category, GetCategoryStatus(category))); | 267 OnCategoryStatusChanged(category, GetCategoryStatus(category))); |
| 267 } | 268 } |
| 268 | 269 |
| 269 } // namespace ntp_snippets | 270 } // namespace ntp_snippets |
| OLD | NEW |