Chromium Code Reviews| 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); |
|
Marc Treib
2016/08/19 10:07:51
else return empty vector?
Philipp Keck
2016/08/19 12:11:53
Done.
| |
| 113 return iterator->second->GetDismissedSuggestionsForDebugging(category); | |
| 114 } | 113 } |
| 115 | 114 |
| 116 void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging( | 115 void ContentSuggestionsService::ClearDismissedSuggestionsForDebugging( |
| 117 Category category) { | 116 Category category) { |
| 118 auto iterator = providers_by_category_.find(category); | 117 auto iterator = providers_by_category_.find(category); |
| 119 if (iterator != providers_by_category_.end()) | 118 if (iterator != providers_by_category_.end()) |
| 120 iterator->second->ClearDismissedSuggestionsForDebugging(category); | 119 iterator->second->ClearDismissedSuggestionsForDebugging(category); |
| 121 } | 120 } |
| 122 | 121 |
| 123 void ContentSuggestionsService::DismissSuggestion( | 122 void ContentSuggestionsService::DismissSuggestion( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 return true; | 259 return true; |
| 261 } | 260 } |
| 262 | 261 |
| 263 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { | 262 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { |
| 264 FOR_EACH_OBSERVER( | 263 FOR_EACH_OBSERVER( |
| 265 Observer, observers_, | 264 Observer, observers_, |
| 266 OnCategoryStatusChanged(category, GetCategoryStatus(category))); | 265 OnCategoryStatusChanged(category, GetCategoryStatus(category))); |
| 267 } | 266 } |
| 268 | 267 |
| 269 } // namespace ntp_snippets | 268 } // namespace ntp_snippets |
| OLD | NEW |