blob: 670a4b44df75e90b6bb35490d3f26a4baaf89fb3 [file] [log] [blame]
[email protected]b1de2c72013-02-06 02:45:471// Copyright (c) 2012 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
brettwf00b9b42016-02-01 22:11:385#include "components/prefs/pref_registry_simple.h"
[email protected]b1de2c72013-02-06 02:45:476
vabr88e507212017-03-29 13:22:267#include <utility>
8
[email protected]57999812013-02-24 05:40:529#include "base/files/file_path.h"
[email protected]d529cb02013-06-10 19:06:5710#include "base/strings/string_number_conversions.h"
[email protected]b1de2c72013-02-06 02:45:4711#include "base/values.h"
12
Ilya Sherman652030d2018-01-22 05:36:1113PrefRegistrySimple::PrefRegistrySimple() = default;
14PrefRegistrySimple::~PrefRegistrySimple() = default;
Ilya Sherman557b2de72018-01-18 20:57:1715
raymes25fb8e7f2015-04-27 01:23:1016void PrefRegistrySimple::RegisterBooleanPref(const std::string& path,
17 bool default_value,
avi9ef8bb02015-12-24 05:29:3618 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4819 RegisterPreference(path, std::make_unique<base::Value>(default_value), flags);
raymes25fb8e7f2015-04-27 01:23:1020}
21
22void PrefRegistrySimple::RegisterIntegerPref(const std::string& path,
23 int default_value,
avi9ef8bb02015-12-24 05:29:3624 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4825 RegisterPreference(path, std::make_unique<base::Value>(default_value), flags);
raymes25fb8e7f2015-04-27 01:23:1026}
27
28void PrefRegistrySimple::RegisterDoublePref(const std::string& path,
29 double default_value,
avi9ef8bb02015-12-24 05:29:3630 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4831 RegisterPreference(path, std::make_unique<base::Value>(default_value), flags);
raymes25fb8e7f2015-04-27 01:23:1032}
33
34void PrefRegistrySimple::RegisterStringPref(const std::string& path,
35 const std::string& default_value,
avi9ef8bb02015-12-24 05:29:3636 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4837 RegisterPreference(path, std::make_unique<base::Value>(default_value), flags);
raymes25fb8e7f2015-04-27 01:23:1038}
39
40void PrefRegistrySimple::RegisterFilePathPref(
41 const std::string& path,
42 const base::FilePath& default_value,
avi9ef8bb02015-12-24 05:29:3643 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4844 RegisterPreference(path, std::make_unique<base::Value>(default_value.value()),
Sam McNally450271f2017-10-13 11:47:3445 flags);
raymes25fb8e7f2015-04-27 01:23:1046}
47
48void PrefRegistrySimple::RegisterListPref(const std::string& path,
avi9ef8bb02015-12-24 05:29:3649 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4850 RegisterPreference(path, std::make_unique<base::ListValue>(), flags);
raymes25fb8e7f2015-04-27 01:23:1051}
52
vabr88e507212017-03-29 13:22:2653void PrefRegistrySimple::RegisterListPref(
54 const std::string& path,
55 std::unique_ptr<base::ListValue> default_value,
56 uint32_t flags) {
Sam McNally450271f2017-10-13 11:47:3457 RegisterPreference(path, std::move(default_value), flags);
raymes25fb8e7f2015-04-27 01:23:1058}
59
60void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path,
avi9ef8bb02015-12-24 05:29:3661 uint32_t flags) {
Jinho Bang84b58bd2018-01-01 21:44:4862 RegisterPreference(path, std::make_unique<base::DictionaryValue>(), flags);
raymes25fb8e7f2015-04-27 01:23:1063}
64
65void PrefRegistrySimple::RegisterDictionaryPref(
66 const std::string& path,
vabr88e507212017-03-29 13:22:2667 std::unique_ptr<base::DictionaryValue> default_value,
avi9ef8bb02015-12-24 05:29:3668 uint32_t flags) {
Sam McNally450271f2017-10-13 11:47:3469 RegisterPreference(path, std::move(default_value), flags);
raymes25fb8e7f2015-04-27 01:23:1070}
71
72void PrefRegistrySimple::RegisterInt64Pref(const std::string& path,
avi9ef8bb02015-12-24 05:29:3673 int64_t default_value,
74 uint32_t flags) {
Sam McNally450271f2017-10-13 11:47:3475 RegisterPreference(
Jinho Bang84b58bd2018-01-01 21:44:4876 path, std::make_unique<base::Value>(base::Int64ToString(default_value)),
vabr88e507212017-03-29 13:22:2677 flags);
raymes25fb8e7f2015-04-27 01:23:1078}
79
80void PrefRegistrySimple::RegisterUint64Pref(const std::string& path,
avi9ef8bb02015-12-24 05:29:3681 uint64_t default_value,
82 uint32_t flags) {
Sam McNally450271f2017-10-13 11:47:3483 RegisterPreference(
Jinho Bang84b58bd2018-01-01 21:44:4884 path, std::make_unique<base::Value>(base::NumberToString(default_value)),
vabr88e507212017-03-29 13:22:2685 flags);
raymes25fb8e7f2015-04-27 01:23:1086}
Ilya Sherman557b2de72018-01-18 20:57:1787
88void PrefRegistrySimple::RegisterTimePref(const std::string& path,
89 base::Time default_value,
90 uint32_t flags) {
91 RegisterInt64Pref(
92 path, default_value.ToDeltaSinceWindowsEpoch().InMicroseconds(), flags);
93}