| 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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" | 
| 10 #include "base/values.h" | 10 #include "base/values.h" | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55 } | 55 } | 
| 56 | 56 | 
| 57 }  // namespace | 57 }  // namespace | 
| 58 | 58 | 
| 59 PrefRegistrySyncable::PrefRegistrySyncable() { | 59 PrefRegistrySyncable::PrefRegistrySyncable() { | 
| 60 } | 60 } | 
| 61 | 61 | 
| 62 PrefRegistrySyncable::~PrefRegistrySyncable() { | 62 PrefRegistrySyncable::~PrefRegistrySyncable() { | 
| 63 } | 63 } | 
| 64 | 64 | 
| 65 const std::set<std::string>& | 65 const PrefRegistrySyncable::PrefToStatus& | 
| 66 PrefRegistrySyncable::syncable_preferences() const { | 66 PrefRegistrySyncable::syncable_preferences() const { | 
| 67   return syncable_preferences_; | 67   return syncable_preferences_; | 
| 68 } | 68 } | 
| 69 | 69 | 
| 70 void PrefRegistrySyncable::SetSyncableRegistrationCallback( | 70 void PrefRegistrySyncable::SetSyncableRegistrationCallback( | 
| 71     const SyncableRegistrationCallback& cb) { | 71     const SyncableRegistrationCallback& cb) { | 
| 72   callback_ = cb; | 72   callback_ = cb; | 
| 73 } | 73 } | 
| 74 | 74 | 
| 75 void PrefRegistrySyncable::RegisterBooleanPref(const char* path, | 75 void PrefRegistrySyncable::RegisterBooleanPref(const char* path, | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 195       Value::CreateStringValue(base::Uint64ToString(default_value)), | 195       Value::CreateStringValue(base::Uint64ToString(default_value)), | 
| 196       sync_status); | 196       sync_status); | 
| 197 } | 197 } | 
| 198 | 198 | 
| 199 void PrefRegistrySyncable::RegisterSyncablePreference( | 199 void PrefRegistrySyncable::RegisterSyncablePreference( | 
| 200     const char* path, | 200     const char* path, | 
| 201     base::Value* default_value, | 201     base::Value* default_value, | 
| 202     PrefSyncStatus sync_status) { | 202     PrefSyncStatus sync_status) { | 
| 203   PrefRegistry::RegisterPreference(path, default_value); | 203   PrefRegistry::RegisterPreference(path, default_value); | 
| 204 | 204 | 
| 205   if (sync_status == SYNCABLE_PREF) { | 205   if (sync_status == PrefRegistrySyncable::SYNCABLE_PREF || | 
| 206     syncable_preferences_.insert(path); | 206       sync_status == PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) { | 
|  | 207     syncable_preferences_[path] = sync_status; | 
| 207 | 208 | 
| 208     if (!callback_.is_null()) | 209     if (!callback_.is_null()) | 
| 209       callback_.Run(path); | 210       callback_.Run(path, sync_status); | 
| 210   } | 211   } | 
| 211 } | 212 } | 
| 212 | 213 | 
| 213 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { | 214 scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { | 
| 214   // TODO(joi): We can directly reuse the same PrefRegistry once | 215   // TODO(joi): We can directly reuse the same PrefRegistry once | 
| 215   // PrefService no longer registers for callbacks on registration and | 216   // PrefService no longer registers for callbacks on registration and | 
| 216   // unregistration. | 217   // unregistration. | 
| 217   scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); | 218   scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); | 
| 218   registry->defaults_ = defaults_; | 219   registry->defaults_ = defaults_; | 
| 219   return registry; | 220   return registry; | 
| 220 } | 221 } | 
| OLD | NEW | 
|---|