| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" | 5 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 void SupervisedUserSyncService::AddObserver( | 200 void SupervisedUserSyncService::AddObserver( |
| 201 SupervisedUserSyncServiceObserver* observer) { | 201 SupervisedUserSyncServiceObserver* observer) { |
| 202 observers_.AddObserver(observer); | 202 observers_.AddObserver(observer); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void SupervisedUserSyncService::RemoveObserver( | 205 void SupervisedUserSyncService::RemoveObserver( |
| 206 SupervisedUserSyncServiceObserver* observer) { | 206 SupervisedUserSyncServiceObserver* observer) { |
| 207 observers_.RemoveObserver(observer); | 207 observers_.RemoveObserver(observer); |
| 208 } | 208 } |
| 209 | 209 |
| 210 scoped_ptr<base::DictionaryValue> SupervisedUserSyncService::CreateDictionary( | 210 std::unique_ptr<base::DictionaryValue> |
| 211 const std::string& name, | 211 SupervisedUserSyncService::CreateDictionary(const std::string& name, |
| 212 const std::string& master_key, | 212 const std::string& master_key, |
| 213 const std::string& signature_key, | 213 const std::string& signature_key, |
| 214 const std::string& encryption_key, | 214 const std::string& encryption_key, |
| 215 int avatar_index) { | 215 int avatar_index) { |
| 216 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 216 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 217 result->SetString(kName, name); | 217 result->SetString(kName, name); |
| 218 result->SetString(kMasterKey, master_key); | 218 result->SetString(kMasterKey, master_key); |
| 219 result->SetString(kPasswordSignatureKey, signature_key); | 219 result->SetString(kPasswordSignatureKey, signature_key); |
| 220 result->SetString(kPasswordEncryptionKey, encryption_key); | 220 result->SetString(kPasswordEncryptionKey, encryption_key); |
| 221 // TODO(akuegel): Get rid of the avatar stuff here when Chrome OS switches | 221 // TODO(akuegel): Get rid of the avatar stuff here when Chrome OS switches |
| 222 // to the avatar index that is stored as a shared setting. | 222 // to the avatar index that is stored as a shared setting. |
| 223 std::string chrome_avatar; | 223 std::string chrome_avatar; |
| 224 std::string chromeos_avatar; | 224 std::string chromeos_avatar; |
| 225 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
| 226 chromeos_avatar = BuildAvatarString(avatar_index); | 226 chromeos_avatar = BuildAvatarString(avatar_index); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void SupervisedUserSyncService::UpdateSupervisedUserImpl( | 267 void SupervisedUserSyncService::UpdateSupervisedUserImpl( |
| 268 const std::string& id, | 268 const std::string& id, |
| 269 const std::string& name, | 269 const std::string& name, |
| 270 const std::string& master_key, | 270 const std::string& master_key, |
| 271 const std::string& signature_key, | 271 const std::string& signature_key, |
| 272 const std::string& encryption_key, | 272 const std::string& encryption_key, |
| 273 int avatar_index, | 273 int avatar_index, |
| 274 bool add_user) { | 274 bool add_user) { |
| 275 DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers); | 275 DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers); |
| 276 base::DictionaryValue* dict = update.Get(); | 276 base::DictionaryValue* dict = update.Get(); |
| 277 scoped_ptr<base::DictionaryValue> value = CreateDictionary( | 277 std::unique_ptr<base::DictionaryValue> value = CreateDictionary( |
| 278 name, master_key, signature_key, encryption_key, avatar_index); | 278 name, master_key, signature_key, encryption_key, avatar_index); |
| 279 | 279 |
| 280 DCHECK_EQ(add_user, !dict->HasKey(id)); | 280 DCHECK_EQ(add_user, !dict->HasKey(id)); |
| 281 base::DictionaryValue* entry = value.get(); | 281 base::DictionaryValue* entry = value.get(); |
| 282 dict->SetWithoutPathExpansion(id, value.release()); | 282 dict->SetWithoutPathExpansion(id, value.release()); |
| 283 | 283 |
| 284 if (!sync_processor_) | 284 if (!sync_processor_) |
| 285 return; | 285 return; |
| 286 | 286 |
| 287 // If we're already syncing, create a new change and upload it. | 287 // If we're already syncing, create a new change and upload it. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 void SupervisedUserSyncService::Shutdown() { | 402 void SupervisedUserSyncService::Shutdown() { |
| 403 NotifySupervisedUsersSyncingStopped(); | 403 NotifySupervisedUsersSyncingStopped(); |
| 404 SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this); | 404 SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this); |
| 405 } | 405 } |
| 406 | 406 |
| 407 SyncMergeResult SupervisedUserSyncService::MergeDataAndStartSyncing( | 407 SyncMergeResult SupervisedUserSyncService::MergeDataAndStartSyncing( |
| 408 ModelType type, | 408 ModelType type, |
| 409 const SyncDataList& initial_sync_data, | 409 const SyncDataList& initial_sync_data, |
| 410 scoped_ptr<SyncChangeProcessor> sync_processor, | 410 std::unique_ptr<SyncChangeProcessor> sync_processor, |
| 411 scoped_ptr<SyncErrorFactory> error_handler) { | 411 std::unique_ptr<SyncErrorFactory> error_handler) { |
| 412 DCHECK_EQ(SUPERVISED_USERS, type); | 412 DCHECK_EQ(SUPERVISED_USERS, type); |
| 413 sync_processor_ = std::move(sync_processor); | 413 sync_processor_ = std::move(sync_processor); |
| 414 error_handler_ = std::move(error_handler); | 414 error_handler_ = std::move(error_handler); |
| 415 | 415 |
| 416 SyncChangeList change_list; | 416 SyncChangeList change_list; |
| 417 SyncMergeResult result(SUPERVISED_USERS); | 417 SyncMergeResult result(SUPERVISED_USERS); |
| 418 | 418 |
| 419 DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers); | 419 DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers); |
| 420 base::DictionaryValue* dict = update.Get(); | 420 base::DictionaryValue* dict = update.Get(); |
| 421 result.set_num_items_before_association(dict->size()); | 421 result.set_num_items_before_association(dict->size()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 OnSupervisedUsersChanged()); | 571 OnSupervisedUsersChanged()); |
| 572 } | 572 } |
| 573 | 573 |
| 574 void SupervisedUserSyncService::DispatchCallbacks() { | 574 void SupervisedUserSyncService::DispatchCallbacks() { |
| 575 const base::DictionaryValue* supervised_users = | 575 const base::DictionaryValue* supervised_users = |
| 576 prefs_->GetDictionary(prefs::kSupervisedUsers); | 576 prefs_->GetDictionary(prefs::kSupervisedUsers); |
| 577 for (const auto& callback : callbacks_) | 577 for (const auto& callback : callbacks_) |
| 578 callback.Run(supervised_users); | 578 callback.Run(supervised_users); |
| 579 callbacks_.clear(); | 579 callbacks_.clear(); |
| 580 } | 580 } |
| OLD | NEW |