Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2421463002: FetchMore functionality backend (Closed)
Patch Set: Introduced callback, removed strategy. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 void ContentSuggestionsService::RemoveObserver(Observer* observer) { 188 void ContentSuggestionsService::RemoveObserver(Observer* observer) {
189 observers_.RemoveObserver(observer); 189 observers_.RemoveObserver(observer);
190 } 190 }
191 191
192 void ContentSuggestionsService::RegisterProvider( 192 void ContentSuggestionsService::RegisterProvider(
193 std::unique_ptr<ContentSuggestionsProvider> provider) { 193 std::unique_ptr<ContentSuggestionsProvider> provider) {
194 DCHECK(state_ == State::ENABLED); 194 DCHECK(state_ == State::ENABLED);
195 providers_.push_back(std::move(provider)); 195 providers_.push_back(std::move(provider));
196 } 196 }
197 197
198 void ContentSuggestionsService::FetchMore(const Category& category,
199 FetchedMoreCallback callback) {
200 auto providers_it = providers_by_category_.find(category);
201 if (providers_it == providers_by_category_.end())
202 return;
203
204 providers_it->second->FetchMore(category, callback);
205 }
206
198 //////////////////////////////////////////////////////////////////////////////// 207 ////////////////////////////////////////////////////////////////////////////////
199 // Private methods 208 // Private methods
200 209
201 void ContentSuggestionsService::OnNewSuggestions( 210 void ContentSuggestionsService::OnNewSuggestions(
202 ContentSuggestionsProvider* provider, 211 ContentSuggestionsProvider* provider,
203 Category category, 212 Category category,
204 std::vector<ContentSuggestion> suggestions) { 213 std::vector<ContentSuggestion> suggestions) {
205 if (TryRegisterProviderForCategory(provider, category)) { 214 if (TryRegisterProviderForCategory(provider, category)) {
206 NotifyCategoryStatusChanged(category); 215 NotifyCategoryStatusChanged(category);
207 } else if (IsCategoryDismissed(category)) { 216 } else if (IsCategoryDismissed(category)) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { 433 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() {
425 base::ListValue list; 434 base::ListValue list;
426 for (const auto& category_provider_pair : dismissed_providers_by_category_) { 435 for (const auto& category_provider_pair : dismissed_providers_by_category_) {
427 list.AppendInteger(category_provider_pair.first.id()); 436 list.AppendInteger(category_provider_pair.first.id());
428 } 437 }
429 438
430 pref_service_->Set(prefs::kDismissedCategories, list); 439 pref_service_->Set(prefs::kDismissedCategories, list);
431 } 440 }
432 441
433 } // namespace ntp_snippets 442 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698