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

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

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Fix Android Compilation Error Created 3 years, 8 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 488 }
489 } 489 }
490 490
491 void ContentSuggestionsService::RestoreDismissedCategoriesFromPrefs() { 491 void ContentSuggestionsService::RestoreDismissedCategoriesFromPrefs() {
492 // This must only be called at startup. 492 // This must only be called at startup.
493 DCHECK(dismissed_providers_by_category_.empty()); 493 DCHECK(dismissed_providers_by_category_.empty());
494 DCHECK(providers_by_category_.empty()); 494 DCHECK(providers_by_category_.empty());
495 495
496 const base::ListValue* list = 496 const base::ListValue* list =
497 pref_service_->GetList(prefs::kDismissedCategories); 497 pref_service_->GetList(prefs::kDismissedCategories);
498 for (const std::unique_ptr<base::Value>& entry : *list) { 498 for (const base::Value& entry : *list) {
499 int id = 0; 499 int id = 0;
500 if (!entry->GetAsInteger(&id)) { 500 if (!entry.GetAsInteger(&id)) {
501 DLOG(WARNING) << "Invalid category pref value: " << *entry; 501 DLOG(WARNING) << "Invalid category pref value: " << entry;
502 continue; 502 continue;
503 } 503 }
504 504
505 // When the provider is registered, it will be stored in this map. 505 // When the provider is registered, it will be stored in this map.
506 dismissed_providers_by_category_[Category::FromIDValue(id)] = nullptr; 506 dismissed_providers_by_category_[Category::FromIDValue(id)] = nullptr;
507 } 507 }
508 } 508 }
509 509
510 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { 510 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() {
511 base::ListValue list; 511 base::ListValue list;
512 for (const auto& category_provider_pair : dismissed_providers_by_category_) { 512 for (const auto& category_provider_pair : dismissed_providers_by_category_) {
513 list.AppendInteger(category_provider_pair.first.id()); 513 list.AppendInteger(category_provider_pair.first.id());
514 } 514 }
515 515
516 pref_service_->Set(prefs::kDismissedCategories, list); 516 pref_service_->Set(prefs::kDismissedCategories, list);
517 } 517 }
518 518
519 } // namespace ntp_snippets 519 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698