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 CategoryInfo ContentSuggestionsService::GetCategoryInfo( | |
Marc Treib
2016/08/08 14:11:26
Didn't we agree on returning a base::Optional?
Philipp Keck
2016/08/08 14:50:18
Done.
| |
54 Category category) const { | |
55 auto iterator = providers_by_category_.find(category); | |
56 if (iterator == providers_by_category_.end()) | |
Marc Treib
2016/08/08 14:11:26
Braces if the body doesn't fit on one line
Philipp Keck
2016/08/08 14:50:18
Done.
That's one of the many reasons why I'd alwa
| |
57 return CategoryInfo(base::string16(), | |
58 ContentSuggestionsCardLayout::FULL_CARD); | |
59 | |
60 return iterator->second->GetCategoryInfo(category); | |
61 } | |
62 | |
53 const std::vector<ContentSuggestion>& | 63 const std::vector<ContentSuggestion>& |
54 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { | 64 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { |
55 auto iterator = suggestions_by_category_.find(category); | 65 auto iterator = suggestions_by_category_.find(category); |
56 if (iterator == suggestions_by_category_.end()) | 66 if (iterator == suggestions_by_category_.end()) |
57 return no_suggestions_; | 67 return no_suggestions_; |
58 return iterator->second; | 68 return iterator->second; |
59 } | 69 } |
60 | 70 |
61 void ContentSuggestionsService::FetchSuggestionImage( | 71 void ContentSuggestionsService::FetchSuggestionImage( |
62 const std::string& suggestion_id, | 72 const std::string& suggestion_id, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 return true; | 226 return true; |
217 } | 227 } |
218 | 228 |
219 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { | 229 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { |
220 FOR_EACH_OBSERVER( | 230 FOR_EACH_OBSERVER( |
221 Observer, observers_, | 231 Observer, observers_, |
222 OnCategoryStatusChanged(category, GetCategoryStatus(category))); | 232 OnCategoryStatusChanged(category, GetCategoryStatus(category))); |
223 } | 233 } |
224 | 234 |
225 } // namespace ntp_snippets | 235 } // namespace ntp_snippets |
OLD | NEW |