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 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void ContentSuggestionsService::RemoveObserver(Observer* observer) { | 175 void ContentSuggestionsService::RemoveObserver(Observer* observer) { |
176 observers_.RemoveObserver(observer); | 176 observers_.RemoveObserver(observer); |
177 } | 177 } |
178 | 178 |
179 void ContentSuggestionsService::RegisterProvider( | 179 void ContentSuggestionsService::RegisterProvider( |
180 std::unique_ptr<ContentSuggestionsProvider> provider) { | 180 std::unique_ptr<ContentSuggestionsProvider> provider) { |
181 DCHECK(state_ == State::ENABLED); | 181 DCHECK(state_ == State::ENABLED); |
182 providers_.push_back(std::move(provider)); | 182 providers_.push_back(std::move(provider)); |
183 } | 183 } |
184 | 184 |
| 185 void ContentSuggestionsService::FetchMore(Category category) { |
| 186 auto providers_it = providers_by_category_.find(category); |
| 187 if (providers_it == providers_by_category_.end()) |
| 188 return; |
| 189 |
| 190 providers_it->second->FetchMore(); |
| 191 } |
| 192 |
185 //////////////////////////////////////////////////////////////////////////////// | 193 //////////////////////////////////////////////////////////////////////////////// |
186 // Private methods | 194 // Private methods |
187 | 195 |
188 void ContentSuggestionsService::OnNewSuggestions( | 196 void ContentSuggestionsService::OnNewSuggestions( |
189 ContentSuggestionsProvider* provider, | 197 ContentSuggestionsProvider* provider, |
190 Category category, | 198 Category category, |
191 std::vector<ContentSuggestion> suggestions) { | 199 std::vector<ContentSuggestion> suggestions) { |
192 if (RegisterCategoryIfRequired(provider, category)) | 200 if (RegisterCategoryIfRequired(provider, category)) |
193 NotifyCategoryStatusChanged(category); | 201 NotifyCategoryStatusChanged(category); |
194 | 202 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) | 355 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) |
348 return false; | 356 return false; |
349 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) | 357 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) |
350 return true; | 358 return true; |
351 } | 359 } |
352 return category_factory_.CompareCategories(left, right); | 360 return category_factory_.CompareCategories(left, right); |
353 }); | 361 }); |
354 } | 362 } |
355 | 363 |
356 } // namespace ntp_snippets | 364 } // namespace ntp_snippets |
OLD | NEW |