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 30 matching lines...) Expand all Loading... | |
41 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; | 41 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; |
42 } | 42 } |
43 | 43 |
44 auto iterator = providers_by_category_.find(category); | 44 auto iterator = providers_by_category_.find(category); |
45 if (iterator == providers_by_category_.end()) | 45 if (iterator == providers_by_category_.end()) |
46 return CategoryStatus::NOT_PROVIDED; | 46 return CategoryStatus::NOT_PROVIDED; |
47 | 47 |
48 return iterator->second->GetCategoryStatus(category); | 48 return iterator->second->GetCategoryStatus(category); |
49 } | 49 } |
50 | 50 |
51 CategoryInfo ContentSuggestionsService::GetCategoryInfo( | |
52 Category category) const { | |
53 auto iterator = providers_by_category_.find(category); | |
54 if (iterator == providers_by_category_.end()) | |
55 return CategoryInfo(base::string16()); | |
PEConn
2016/08/04 12:08:39
What does this represent - an empty category or an
Philipp Keck
2016/08/04 14:17:43
We're discussing the possibility of returning an O
| |
56 | |
57 return iterator->second->GetCategoryInfo(category); | |
58 } | |
59 | |
51 const std::vector<ContentSuggestion>& | 60 const std::vector<ContentSuggestion>& |
52 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { | 61 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { |
53 auto iterator = suggestions_by_category_.find(category); | 62 auto iterator = suggestions_by_category_.find(category); |
54 if (iterator == suggestions_by_category_.end()) | 63 if (iterator == suggestions_by_category_.end()) |
55 return no_suggestions_; | 64 return no_suggestions_; |
56 return iterator->second; | 65 return iterator->second; |
57 } | 66 } |
58 | 67 |
59 void ContentSuggestionsService::FetchSuggestionImage( | 68 void ContentSuggestionsService::FetchSuggestionImage( |
60 const std::string& suggestion_id, | 69 const std::string& suggestion_id, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 return true; | 221 return true; |
213 } | 222 } |
214 | 223 |
215 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { | 224 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { |
216 FOR_EACH_OBSERVER( | 225 FOR_EACH_OBSERVER( |
217 Observer, observers_, | 226 Observer, observers_, |
218 OnCategoryStatusChanged(category, GetCategoryStatus(category))); | 227 OnCategoryStatusChanged(category, GetCategoryStatus(category))); |
219 } | 228 } |
220 | 229 |
221 } // namespace ntp_snippets | 230 } // namespace ntp_snippets |
OLD | NEW |