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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void ContentSuggestionsService::RemoveObserver(Observer* observer) { | 189 void ContentSuggestionsService::RemoveObserver(Observer* observer) { |
190 observers_.RemoveObserver(observer); | 190 observers_.RemoveObserver(observer); |
191 } | 191 } |
192 | 192 |
193 void ContentSuggestionsService::RegisterProvider( | 193 void ContentSuggestionsService::RegisterProvider( |
194 std::unique_ptr<ContentSuggestionsProvider> provider) { | 194 std::unique_ptr<ContentSuggestionsProvider> provider) { |
195 DCHECK(state_ == State::ENABLED); | 195 DCHECK(state_ == State::ENABLED); |
196 providers_.push_back(std::move(provider)); | 196 providers_.push_back(std::move(provider)); |
197 } | 197 } |
198 | 198 |
199 void ContentSuggestionsService::FetchMore(const Category& category, | 199 void ContentSuggestionsService::Fetch( |
200 const FetchedMoreCallback& callback) { | 200 const Category& category, |
| 201 std::set<std::string> known_suggestion_ids, |
| 202 const FetchingCallback& callback) { |
201 auto providers_it = providers_by_category_.find(category); | 203 auto providers_it = providers_by_category_.find(category); |
202 if (providers_it == providers_by_category_.end()) | 204 if (providers_it == providers_by_category_.end()) |
203 return; | 205 return; |
204 | 206 |
205 providers_it->second->FetchMore(category, callback); | 207 providers_it->second->Fetch(category, known_suggestion_ids, callback); |
206 } | 208 } |
207 | 209 |
208 //////////////////////////////////////////////////////////////////////////////// | 210 //////////////////////////////////////////////////////////////////////////////// |
209 // Private methods | 211 // Private methods |
210 | 212 |
211 void ContentSuggestionsService::OnNewSuggestions( | 213 void ContentSuggestionsService::OnNewSuggestions( |
212 ContentSuggestionsProvider* provider, | 214 ContentSuggestionsProvider* provider, |
213 Category category, | 215 Category category, |
214 std::vector<ContentSuggestion> suggestions) { | 216 std::vector<ContentSuggestion> suggestions) { |
215 // Providers shouldn't call this when they're in a non-available state. | 217 // Providers shouldn't call this when they're in a non-available state. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 440 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
439 base::ListValue list; | 441 base::ListValue list; |
440 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 442 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
441 list.AppendInteger(category_provider_pair.first.id()); | 443 list.AppendInteger(category_provider_pair.first.id()); |
442 } | 444 } |
443 | 445 |
444 pref_service_->Set(prefs::kDismissedCategories, list); | 446 pref_service_->Set(prefs::kDismissedCategories, list); |
445 } | 447 } |
446 | 448 |
447 } // namespace ntp_snippets | 449 } // namespace ntp_snippets |
OLD | NEW |