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

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

Issue 2422633002: [NTP Snippets] Properly restore the status of restored sections (Closed)
Patch Set: 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 //////////////////////////////////////////////////////////////////////////////// 185 ////////////////////////////////////////////////////////////////////////////////
186 // Private methods 186 // Private methods
187 187
188 void ContentSuggestionsService::OnNewSuggestions( 188 void ContentSuggestionsService::OnNewSuggestions(
189 ContentSuggestionsProvider* provider, 189 ContentSuggestionsProvider* provider,
190 Category category, 190 Category category,
191 std::vector<ContentSuggestion> suggestions) { 191 std::vector<ContentSuggestion> suggestions) {
192 if (RegisterCategoryIfRequired(provider, category)) 192 if (RegisterCategoryIfRequired(provider, category))
193 NotifyCategoryStatusChanged(category); 193 NotifyCategoryStatusChanged(category);
194 194
195 if (!IsCategoryStatusAvailable(provider->GetCategoryStatus(category))) 195 if (!IsCategoryStatusAvailable(provider->GetCategoryStatus(category))) {
196 // A provider shouldn't send us suggestions while it's not available.
197 DCHECK(suggestions.empty());
196 return; 198 return;
199 }
197 200
198 suggestions_by_category_[category] = std::move(suggestions); 201 suggestions_by_category_[category] = std::move(suggestions);
199 202
200 // The positioning of the bookmarks category depends on whether it's empty. 203 // The positioning of the bookmarks category depends on whether it's empty.
201 // TODO(treib): Remove this temporary hack, crbug.com/640568. 204 // TODO(treib): Remove this temporary hack, crbug.com/640568.
202 if (category.IsKnownCategory(KnownCategories::BOOKMARKS)) 205 if (category.IsKnownCategory(KnownCategories::BOOKMARKS))
203 SortCategories(); 206 SortCategories();
204 207
205 FOR_EACH_OBSERVER(Observer, observers_, OnNewSuggestions(category)); 208 FOR_EACH_OBSERVER(Observer, observers_, OnNewSuggestions(category));
206 } 209 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (left.IsKnownCategory(KnownCategories::BOOKMARKS)) 347 if (left.IsKnownCategory(KnownCategories::BOOKMARKS))
345 return false; 348 return false;
346 if (right.IsKnownCategory(KnownCategories::BOOKMARKS)) 349 if (right.IsKnownCategory(KnownCategories::BOOKMARKS))
347 return true; 350 return true;
348 } 351 }
349 return category_factory_.CompareCategories(left, right); 352 return category_factory_.CompareCategories(left, right);
350 }); 353 });
351 } 354 }
352 355
353 } // namespace ntp_snippets 356 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698