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 | |
9 #include <set> | 8 #include <set> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // to the avatar index that is stored as a shared setting. | 221 // to the avatar index that is stored as a shared setting. |
222 std::string chrome_avatar; | 222 std::string chrome_avatar; |
223 std::string chromeos_avatar; | 223 std::string chromeos_avatar; |
224 #if defined(OS_CHROMEOS) | 224 #if defined(OS_CHROMEOS) |
225 chromeos_avatar = BuildAvatarString(avatar_index); | 225 chromeos_avatar = BuildAvatarString(avatar_index); |
226 #else | 226 #else |
227 chrome_avatar = BuildAvatarString(avatar_index); | 227 chrome_avatar = BuildAvatarString(avatar_index); |
228 #endif | 228 #endif |
229 result->SetString(kChromeAvatar, chrome_avatar); | 229 result->SetString(kChromeAvatar, chrome_avatar); |
230 result->SetString(kChromeOsAvatar, chromeos_avatar); | 230 result->SetString(kChromeOsAvatar, chromeos_avatar); |
231 return result.Pass(); | 231 return result; |
232 } | 232 } |
233 | 233 |
234 void SupervisedUserSyncService::AddSupervisedUser( | 234 void SupervisedUserSyncService::AddSupervisedUser( |
235 const std::string& id, | 235 const std::string& id, |
236 const std::string& name, | 236 const std::string& name, |
237 const std::string& master_key, | 237 const std::string& master_key, |
238 const std::string& signature_key, | 238 const std::string& signature_key, |
239 const std::string& encryption_key, | 239 const std::string& encryption_key, |
240 int avatar_index) { | 240 int avatar_index) { |
241 UpdateSupervisedUserImpl(id, | 241 UpdateSupervisedUserImpl(id, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 NotifySupervisedUsersSyncingStopped(); | 402 NotifySupervisedUsersSyncingStopped(); |
403 SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this); | 403 SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this); |
404 } | 404 } |
405 | 405 |
406 SyncMergeResult SupervisedUserSyncService::MergeDataAndStartSyncing( | 406 SyncMergeResult SupervisedUserSyncService::MergeDataAndStartSyncing( |
407 ModelType type, | 407 ModelType type, |
408 const SyncDataList& initial_sync_data, | 408 const SyncDataList& initial_sync_data, |
409 scoped_ptr<SyncChangeProcessor> sync_processor, | 409 scoped_ptr<SyncChangeProcessor> sync_processor, |
410 scoped_ptr<SyncErrorFactory> error_handler) { | 410 scoped_ptr<SyncErrorFactory> error_handler) { |
411 DCHECK_EQ(SUPERVISED_USERS, type); | 411 DCHECK_EQ(SUPERVISED_USERS, type); |
412 sync_processor_ = sync_processor.Pass(); | 412 sync_processor_ = std::move(sync_processor); |
413 error_handler_ = error_handler.Pass(); | 413 error_handler_ = std::move(error_handler); |
414 | 414 |
415 SyncChangeList change_list; | 415 SyncChangeList change_list; |
416 SyncMergeResult result(SUPERVISED_USERS); | 416 SyncMergeResult result(SUPERVISED_USERS); |
417 | 417 |
418 DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers); | 418 DictionaryPrefUpdate update(prefs_, prefs::kSupervisedUsers); |
419 base::DictionaryValue* dict = update.Get(); | 419 base::DictionaryValue* dict = update.Get(); |
420 result.set_num_items_before_association(dict->size()); | 420 result.set_num_items_before_association(dict->size()); |
421 std::set<std::string> seen_ids; | 421 std::set<std::string> seen_ids; |
422 int num_items_added = 0; | 422 int num_items_added = 0; |
423 int num_items_modified = 0; | 423 int num_items_modified = 0; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 OnSupervisedUsersChanged()); | 570 OnSupervisedUsersChanged()); |
571 } | 571 } |
572 | 572 |
573 void SupervisedUserSyncService::DispatchCallbacks() { | 573 void SupervisedUserSyncService::DispatchCallbacks() { |
574 const base::DictionaryValue* supervised_users = | 574 const base::DictionaryValue* supervised_users = |
575 prefs_->GetDictionary(prefs::kSupervisedUsers); | 575 prefs_->GetDictionary(prefs::kSupervisedUsers); |
576 for (const auto& callback : callbacks_) | 576 for (const auto& callback : callbacks_) |
577 callback.Run(supervised_users); | 577 callback.Run(supervised_users); |
578 callbacks_.clear(); | 578 callbacks_.clear(); |
579 } | 579 } |
OLD | NEW |