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

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

Issue 2279123002: [Sync] Initial implementation of foreign sessions suggestions provider. (Closed)
Patch Set: Updating for comments, again! Created 4 years, 3 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
« no previous file with comments | « components/ntp_snippets/pref_util.h ('k') | components/ntp_snippets/sessions/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/ntp_snippets/pref_util.h"
6
7 #include <memory>
8
9 #include "base/values.h"
10 #include "components/prefs/pref_service.h"
11
12 namespace ntp_snippets {
13 namespace prefs {
14
15 std::set<std::string> ReadDismissedIDsFromPrefs(const PrefService& pref_service,
16 const std::string& pref_name) {
17 std::set<std::string> dismissed_ids;
18 const base::ListValue* list = pref_service.GetList(pref_name);
19 for (const std::unique_ptr<base::Value>& value : *list) {
20 std::string dismissed_id;
21 bool success = value->GetAsString(&dismissed_id);
22 DCHECK(success) << "Failed to parse dismissed id from prefs param "
23 << pref_name << " into string.";
24 dismissed_ids.insert(dismissed_id);
25 }
26 return dismissed_ids;
27 }
28
29 void StoreDismissedIDsToPrefs(PrefService* pref_service,
30 const std::string& pref_name,
31 const std::set<std::string>& dismissed_ids) {
32 base::ListValue list;
33 for (const std::string& dismissed_id : dismissed_ids) {
34 list.AppendString(dismissed_id);
35 }
36 pref_service->Set(pref_name, list);
37 }
38
39 } // namespace prefs
40 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/pref_util.h ('k') | components/ntp_snippets/sessions/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698