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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; | 43 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; |
44 } | 44 } |
45 | 45 |
46 auto iterator = providers_by_category_.find(category); | 46 auto iterator = providers_by_category_.find(category); |
47 if (iterator == providers_by_category_.end()) | 47 if (iterator == providers_by_category_.end()) |
48 return CategoryStatus::NOT_PROVIDED; | 48 return CategoryStatus::NOT_PROVIDED; |
49 | 49 |
50 return iterator->second->GetCategoryStatus(category); | 50 return iterator->second->GetCategoryStatus(category); |
51 } | 51 } |
52 | 52 |
| 53 base::Optional<CategoryInfo> ContentSuggestionsService::GetCategoryInfo( |
| 54 Category category) const { |
| 55 auto iterator = providers_by_category_.find(category); |
| 56 if (iterator == providers_by_category_.end()) |
| 57 return base::Optional<CategoryInfo>(); |
| 58 return iterator->second->GetCategoryInfo(category); |
| 59 } |
| 60 |
53 const std::vector<ContentSuggestion>& | 61 const std::vector<ContentSuggestion>& |
54 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { | 62 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { |
55 auto iterator = suggestions_by_category_.find(category); | 63 auto iterator = suggestions_by_category_.find(category); |
56 if (iterator == suggestions_by_category_.end()) | 64 if (iterator == suggestions_by_category_.end()) |
57 return no_suggestions_; | 65 return no_suggestions_; |
58 return iterator->second; | 66 return iterator->second; |
59 } | 67 } |
60 | 68 |
61 void ContentSuggestionsService::FetchSuggestionImage( | 69 void ContentSuggestionsService::FetchSuggestionImage( |
62 const std::string& suggestion_id, | 70 const std::string& suggestion_id, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 return true; | 224 return true; |
217 } | 225 } |
218 | 226 |
219 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { | 227 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { |
220 FOR_EACH_OBSERVER( | 228 FOR_EACH_OBSERVER( |
221 Observer, observers_, | 229 Observer, observers_, |
222 OnCategoryStatusChanged(category, GetCategoryStatus(category))); | 230 OnCategoryStatusChanged(category, GetCategoryStatus(category))); |
223 } | 231 } |
224 | 232 |
225 } // namespace ntp_snippets | 233 } // namespace ntp_snippets |
OLD | NEW |