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

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

Issue 2232783002: Support action button to fetch more content suggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snippetsbridge
Patch Set: Refactor NewTabPageAdapterTest Created 4 years, 4 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 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Private methods 180 // Private methods
181 181
182 void ContentSuggestionsService::OnNewSuggestions( 182 void ContentSuggestionsService::OnNewSuggestions(
183 ContentSuggestionsProvider* provider, 183 ContentSuggestionsProvider* provider,
184 Category category, 184 Category category,
185 std::vector<ContentSuggestion> new_suggestions) { 185 std::vector<ContentSuggestion> new_suggestions) {
186 if (RegisterCategoryIfRequired(provider, category)) { 186 if (RegisterCategoryIfRequired(provider, category)) {
187 NotifyCategoryStatusChanged(category); 187 NotifyCategoryStatusChanged(category);
188 } 188 }
189 189
190 if (!IsCategoryStatusAvailable(provider->GetCategoryStatus(category))) {
Bernhard Bauer 2016/08/12 09:03:09 Nit: The if-statement above uses braces for a sing
Philipp Keck 2016/08/12 09:16:42 Removed them here and just above and just below.
191 return;
192 }
193
190 for (const ContentSuggestion& suggestion : 194 for (const ContentSuggestion& suggestion :
191 suggestions_by_category_[category]) { 195 suggestions_by_category_[category]) {
192 id_category_map_.erase(suggestion.id()); 196 id_category_map_.erase(suggestion.id());
193 } 197 }
194 198
195 for (const ContentSuggestion& suggestion : new_suggestions) { 199 for (const ContentSuggestion& suggestion : new_suggestions) {
196 id_category_map_.insert(std::make_pair(suggestion.id(), category)); 200 id_category_map_.insert(std::make_pair(suggestion.id(), category));
197 } 201 }
198 202
199 suggestions_by_category_[category] = std::move(new_suggestions); 203 suggestions_by_category_[category] = std::move(new_suggestions);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return true; 252 return true;
249 } 253 }
250 254
251 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { 255 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) {
252 FOR_EACH_OBSERVER( 256 FOR_EACH_OBSERVER(
253 Observer, observers_, 257 Observer, observers_,
254 OnCategoryStatusChanged(category, GetCategoryStatus(category))); 258 OnCategoryStatusChanged(category, GetCategoryStatus(category)));
255 } 259 }
256 260
257 } // namespace ntp_snippets 261 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698