| 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/sync_preferences/pref_service_syncable.h" | 5 #include "components/sync_preferences/pref_service_syncable.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 PrefServiceSyncable::~PrefServiceSyncable() { | 63 PrefServiceSyncable::~PrefServiceSyncable() { |
| 64 // Remove our callback from the registry, since it may outlive us. | 64 // Remove our callback from the registry, since it may outlive us. |
| 65 user_prefs::PrefRegistrySyncable* registry = | 65 user_prefs::PrefRegistrySyncable* registry = |
| 66 static_cast<user_prefs::PrefRegistrySyncable*>(pref_registry_.get()); | 66 static_cast<user_prefs::PrefRegistrySyncable*>(pref_registry_.get()); |
| 67 registry->SetSyncableRegistrationCallback( | 67 registry->SetSyncableRegistrationCallback( |
| 68 user_prefs::PrefRegistrySyncable::SyncableRegistrationCallback()); | 68 user_prefs::PrefRegistrySyncable::SyncableRegistrationCallback()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 PrefServiceSyncable* PrefServiceSyncable::CreateIncognitoPrefService( | |
| 72 PrefStore* incognito_extension_pref_store, | |
| 73 const std::vector<const char*>& overlay_pref_names) { | |
| 74 pref_service_forked_ = true; | |
| 75 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); | |
| 76 OverlayUserPrefStore* incognito_pref_store = | |
| 77 new OverlayUserPrefStore(user_pref_store_.get()); | |
| 78 for (const char* overlay_pref_name : overlay_pref_names) | |
| 79 incognito_pref_store->RegisterOverlayPref(overlay_pref_name); | |
| 80 | |
| 81 scoped_refptr<user_prefs::PrefRegistrySyncable> forked_registry = | |
| 82 static_cast<user_prefs::PrefRegistrySyncable*>(pref_registry_.get()) | |
| 83 ->ForkForIncognito(); | |
| 84 PrefServiceSyncable* incognito_service = new PrefServiceSyncable( | |
| 85 pref_notifier, | |
| 86 pref_value_store_->CloneAndSpecialize(NULL, // managed | |
| 87 NULL, // supervised_user | |
| 88 incognito_extension_pref_store, | |
| 89 NULL, // command_line_prefs | |
| 90 incognito_pref_store, | |
| 91 NULL, // recommended | |
| 92 forked_registry->defaults().get(), | |
| 93 pref_notifier), | |
| 94 incognito_pref_store, forked_registry.get(), | |
| 95 pref_sync_associator_.client(), read_error_callback_, false); | |
| 96 return incognito_service; | |
| 97 } | |
| 98 | |
| 99 bool PrefServiceSyncable::IsSyncing() { | 71 bool PrefServiceSyncable::IsSyncing() { |
| 100 return pref_sync_associator_.models_associated(); | 72 return pref_sync_associator_.models_associated(); |
| 101 } | 73 } |
| 102 | 74 |
| 103 bool PrefServiceSyncable::IsPrioritySyncing() { | 75 bool PrefServiceSyncable::IsPrioritySyncing() { |
| 104 return priority_pref_sync_associator_.models_associated(); | 76 return priority_pref_sync_associator_.models_associated(); |
| 105 } | 77 } |
| 106 | 78 |
| 107 bool PrefServiceSyncable::IsPrefSynced(const std::string& name) const { | 79 bool PrefServiceSyncable::IsPrefSynced(const std::string& name) const { |
| 108 return pref_sync_associator_.IsPrefSynced(name) || | 80 return pref_sync_associator_.IsPrefSynced(name) || |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 for (auto& observer : observer_list_) | 152 for (auto& observer : observer_list_) |
| 181 observer.OnIsSyncingChanged(); | 153 observer.OnIsSyncingChanged(); |
| 182 } | 154 } |
| 183 | 155 |
| 184 void PrefServiceSyncable::ProcessPrefChange(const std::string& name) { | 156 void PrefServiceSyncable::ProcessPrefChange(const std::string& name) { |
| 185 pref_sync_associator_.ProcessPrefChange(name); | 157 pref_sync_associator_.ProcessPrefChange(name); |
| 186 priority_pref_sync_associator_.ProcessPrefChange(name); | 158 priority_pref_sync_associator_.ProcessPrefChange(name); |
| 187 } | 159 } |
| 188 | 160 |
| 189 } // namespace sync_preferences | 161 } // namespace sync_preferences |
| OLD | NEW |