| 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/user_prefs/pref_registry_syncable.h" | 5 #include "components/user_prefs/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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 CreateLocaleDefaultValue(base::Value::TYPE_STRING, | 181 CreateLocaleDefaultValue(base::Value::TYPE_STRING, |
| 182 locale_default_message_id), | 182 locale_default_message_id), |
| 183 sync_status); | 183 sync_status); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void PrefRegistrySyncable::RegisterInt64Pref( | 186 void PrefRegistrySyncable::RegisterInt64Pref( |
| 187 const char* path, | 187 const char* path, |
| 188 int64 default_value, | 188 int64 default_value, |
| 189 PrefSyncStatus sync_status) { | 189 PrefSyncStatus sync_status) { |
| 190 RegisterSyncablePreference( | 190 RegisterSyncablePreference( |
| 191 path, | 191 path, new base::StringValue(default_value), sync_status); |
| 192 base::Value::CreateStringValue(base::Int64ToString(default_value)), | |
| 193 sync_status); | |
| 194 } | 192 } |
| 195 | 193 |
| 196 void PrefRegistrySyncable::RegisterUint64Pref( | 194 void PrefRegistrySyncable::RegisterUint64Pref( |
| 197 const char* path, | 195 const char* path, |
| 198 uint64 default_value, | 196 uint64 default_value, |
| 199 PrefSyncStatus sync_status) { | 197 PrefSyncStatus sync_status) { |
| 200 RegisterSyncablePreference( | 198 RegisterSyncablePreference( |
| 201 path, | 199 path, new base::StringValue(default_value), sync_status); |
| 202 base::Value::CreateStringValue(base::Uint64ToString(default_value)), | |
| 203 sync_status); | |
| 204 } | 200 } |
| 205 | 201 |
| 206 void PrefRegistrySyncable::RegisterSyncablePreference( | 202 void PrefRegistrySyncable::RegisterSyncablePreference( |
| 207 const char* path, | 203 const char* path, |
| 208 base::Value* default_value, | 204 base::Value* default_value, |
| 209 PrefSyncStatus sync_status) { | 205 PrefSyncStatus sync_status) { |
| 210 PrefRegistry::RegisterPreference(path, default_value); | 206 PrefRegistry::RegisterPreference(path, default_value); |
| 211 | 207 |
| 212 if (sync_status == PrefRegistrySyncable::SYNCABLE_PREF || | 208 if (sync_status == PrefRegistrySyncable::SYNCABLE_PREF || |
| 213 sync_status == PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) { | 209 sync_status == PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) { |
| 214 syncable_preferences_[path] = sync_status; | 210 syncable_preferences_[path] = sync_status; |
| 215 | 211 |
| 216 if (!callback_.is_null()) | 212 if (!callback_.is_null()) |
| 217 callback_.Run(path, sync_status); | 213 callback_.Run(path, sync_status); |
| 218 } | 214 } |
| 219 } | 215 } |
| 220 | 216 |
| 221 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { | 217 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { |
| 222 // TODO(joi): We can directly reuse the same PrefRegistry once | 218 // TODO(joi): We can directly reuse the same PrefRegistry once |
| 223 // PrefService no longer registers for callbacks on registration and | 219 // PrefService no longer registers for callbacks on registration and |
| 224 // unregistration. | 220 // unregistration. |
| 225 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); | 221 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); |
| 226 registry->defaults_ = defaults_; | 222 registry->defaults_ = defaults_; |
| 227 return registry; | 223 return registry; |
| 228 } | 224 } |
| 229 | 225 |
| 230 } // namespace user_prefs | 226 } // namespace user_prefs |
| OLD | NEW |