1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/prefs/pref_registry_simple.h"
9 #include "base/files/file_path.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h"
12 #include "base/values.h"
14 PrefRegistrySimple::PrefRegistrySimple() = default;
15 PrefRegistrySimple::~PrefRegistrySimple() = default;
17 void PrefRegistrySimple::RegisterBooleanPref(const std::string& path,
20 RegisterPreference(path, base::Value(default_value), flags);
23 void PrefRegistrySimple::RegisterIntegerPref(const std::string& path,
26 RegisterPreference(path, base::Value(default_value), flags);
29 void PrefRegistrySimple::RegisterDoublePref(const std::string& path,
32 RegisterPreference(path, base::Value(default_value), flags);
35 void PrefRegistrySimple::RegisterStringPref(const std::string& path,
36 const std::string& default_value,
38 RegisterPreference(path, base::Value(default_value), flags);
41 void PrefRegistrySimple::RegisterFilePathPref(
42 const std::string& path,
43 const base::FilePath& default_value,
45 RegisterPreference(path, base::Value(default_value.AsUTF8Unsafe()), flags);
48 void PrefRegistrySimple::RegisterListPref(const std::string& path,
50 RegisterPreference(path, base::Value(base::Value::Type::LIST), flags);
53 void PrefRegistrySimple::RegisterListPref(const std::string& path,
54 base::Value::List default_value,
56 RegisterPreference(path, base::Value(std::move(default_value)), flags);
59 void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path,
61 RegisterPreference(path, base::Value(base::Value::Type::DICT), flags);
64 void PrefRegistrySimple::RegisterDictionaryPref(const std::string& path,
65 base::Value::Dict default_value,
67 RegisterPreference(path, base::Value(std::move(default_value)), flags);
70 void PrefRegistrySimple::RegisterInt64Pref(const std::string& path,
71 int64_t default_value,
73 RegisterPreference(path, base::Value(base::NumberToString(default_value)),
77 void PrefRegistrySimple::RegisterUint64Pref(const std::string& path,
78 uint64_t default_value,
80 RegisterPreference(path, base::Value(base::NumberToString(default_value)),
84 void PrefRegistrySimple::RegisterTimePref(const std::string& path,
85 base::Time default_value,
88 path, default_value.ToDeltaSinceWindowsEpoch().InMicroseconds(), flags);
91 void PrefRegistrySimple::RegisterTimeDeltaPref(const std::string& path,
92 base::TimeDelta default_value,
94 RegisterInt64Pref(path, default_value.InMicroseconds(), flags);