OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 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/pref_registry/pref_registry_syncable.h" | 5 #include "components/pref_registry/pref_registry_syncable.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/prefs/default_pref_store.h" | 8 #include "base/prefs/default_pref_store.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 case base::Value::TYPE_INTEGER: { | 34 case base::Value::TYPE_INTEGER: { |
35 int val; | 35 int val; |
36 base::StringToInt(resource_string, &val); | 36 base::StringToInt(resource_string, &val); |
37 return new base::FundamentalValue(val); | 37 return new base::FundamentalValue(val); |
38 } | 38 } |
39 | 39 |
40 case base::Value::TYPE_DOUBLE: { | 40 case base::Value::TYPE_DOUBLE: { |
41 double val; | 41 double val; |
42 base::StringToDouble(resource_string, &val); | 42 base::StringToDouble(resource_string, &val); |
43 return base::Value::CreateDoubleValue(val); | 43 return new base::FundamentalValue(val); |
44 } | 44 } |
45 | 45 |
46 case base::Value::TYPE_STRING: { | 46 case base::Value::TYPE_STRING: { |
47 return new base::StringValue(resource_string); | 47 return new base::StringValue(resource_string); |
48 } | 48 } |
49 | 49 |
50 default: { | 50 default: { |
51 NOTREACHED() << | 51 NOTREACHED() << |
52 "list and dictionary types cannot have default locale values"; | 52 "list and dictionary types cannot have default locale values"; |
53 } | 53 } |
(...skipping 30 matching lines...) Expand all Loading... |
84 void PrefRegistrySyncable::RegisterIntegerPref(const char* path, | 84 void PrefRegistrySyncable::RegisterIntegerPref(const char* path, |
85 int default_value, | 85 int default_value, |
86 PrefSyncStatus sync_status) { | 86 PrefSyncStatus sync_status) { |
87 RegisterSyncablePreference( | 87 RegisterSyncablePreference( |
88 path, new base::FundamentalValue(default_value), sync_status); | 88 path, new base::FundamentalValue(default_value), sync_status); |
89 } | 89 } |
90 | 90 |
91 void PrefRegistrySyncable::RegisterDoublePref(const char* path, | 91 void PrefRegistrySyncable::RegisterDoublePref(const char* path, |
92 double default_value, | 92 double default_value, |
93 PrefSyncStatus sync_status) { | 93 PrefSyncStatus sync_status) { |
94 RegisterSyncablePreference(path, | 94 RegisterSyncablePreference( |
95 base::Value::CreateDoubleValue(default_value), | 95 path, new base::FundamentalValue(default_value), sync_status); |
96 sync_status); | |
97 } | 96 } |
98 | 97 |
99 void PrefRegistrySyncable::RegisterStringPref(const char* path, | 98 void PrefRegistrySyncable::RegisterStringPref(const char* path, |
100 const std::string& default_value, | 99 const std::string& default_value, |
101 PrefSyncStatus sync_status) { | 100 PrefSyncStatus sync_status) { |
102 RegisterSyncablePreference( | 101 RegisterSyncablePreference( |
103 path, new base::StringValue(default_value), sync_status); | 102 path, new base::StringValue(default_value), sync_status); |
104 } | 103 } |
105 | 104 |
106 void PrefRegistrySyncable::RegisterFilePathPref( | 105 void PrefRegistrySyncable::RegisterFilePathPref( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { | 215 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { |
217 // TODO(joi): We can directly reuse the same PrefRegistry once | 216 // TODO(joi): We can directly reuse the same PrefRegistry once |
218 // PrefService no longer registers for callbacks on registration and | 217 // PrefService no longer registers for callbacks on registration and |
219 // unregistration. | 218 // unregistration. |
220 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); | 219 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); |
221 registry->defaults_ = defaults_; | 220 registry->defaults_ = defaults_; |
222 return registry; | 221 return registry; |
223 } | 222 } |
224 | 223 |
225 } // namespace user_prefs | 224 } // namespace user_prefs |
OLD | NEW |