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/chromeos/login/supervised/supervised_user_creation_scre
en.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_scre
en.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/wallpaper/wallpaper_controller.h" | 9 #include "ash/common/wallpaper/wallpaper_controller.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 const base::DictionaryValue* users) { | 522 const base::DictionaryValue* users) { |
523 // Copy for passing to WebUI, contains only id, name and avatar URL. | 523 // Copy for passing to WebUI, contains only id, name and avatar URL. |
524 std::unique_ptr<base::ListValue> ui_users(new base::ListValue()); | 524 std::unique_ptr<base::ListValue> ui_users(new base::ListValue()); |
525 SupervisedUserManager* supervised_user_manager = | 525 SupervisedUserManager* supervised_user_manager = |
526 ChromeUserManager::Get()->GetSupervisedUserManager(); | 526 ChromeUserManager::Get()->GetSupervisedUserManager(); |
527 | 527 |
528 // Stored copy, contains all necessary information. | 528 // Stored copy, contains all necessary information. |
529 existing_users_.reset(new base::DictionaryValue()); | 529 existing_users_.reset(new base::DictionaryValue()); |
530 for (base::DictionaryValue::Iterator it(*users); !it.IsAtEnd(); | 530 for (base::DictionaryValue::Iterator it(*users); !it.IsAtEnd(); |
531 it.Advance()) { | 531 it.Advance()) { |
| 532 const base::DictionaryValue* value = nullptr; |
| 533 it.value().GetAsDictionary(&value); |
532 // Copy that would be stored in this class. | 534 // Copy that would be stored in this class. |
533 base::DictionaryValue* local_copy = | 535 std::unique_ptr<base::DictionaryValue> local_copy = value->CreateDeepCopy(); |
534 static_cast<base::DictionaryValue*>(it.value().DeepCopy()); | |
535 // Copy that would be passed to WebUI. It has some extra values for | 536 // Copy that would be passed to WebUI. It has some extra values for |
536 // displaying, but does not contain sensitive data, such as master password. | 537 // displaying, but does not contain sensitive data, such as master password. |
537 auto ui_copy = base::MakeUnique<base::DictionaryValue>(); | 538 auto ui_copy = base::MakeUnique<base::DictionaryValue>(); |
538 | 539 |
539 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; | 540 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; |
540 std::string chromeos_avatar; | 541 std::string chromeos_avatar; |
541 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar, | 542 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar, |
542 &chromeos_avatar) && | 543 &chromeos_avatar) && |
543 !chromeos_avatar.empty() && | 544 !chromeos_avatar.empty() && |
544 SupervisedUserSyncService::GetAvatarIndex( | 545 SupervisedUserSyncService::GetAvatarIndex( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 578 |
578 std::string signature_key; | 579 std::string signature_key; |
579 bool has_password = | 580 bool has_password = |
580 local_copy->GetString(SupervisedUserSyncService::kPasswordSignatureKey, | 581 local_copy->GetString(SupervisedUserSyncService::kPasswordSignatureKey, |
581 &signature_key) && | 582 &signature_key) && |
582 !signature_key.empty(); | 583 !signature_key.empty(); |
583 | 584 |
584 ui_copy->SetBoolean(kUserNeedPassword, !has_password); | 585 ui_copy->SetBoolean(kUserNeedPassword, !has_password); |
585 ui_copy->SetString("id", it.key()); | 586 ui_copy->SetString("id", it.key()); |
586 | 587 |
587 existing_users_->Set(it.key(), local_copy); | 588 existing_users_->Set(it.key(), std::move(local_copy)); |
588 ui_users->Append(std::move(ui_copy)); | 589 ui_users->Append(std::move(ui_copy)); |
589 } | 590 } |
590 view_->ShowExistingSupervisedUsers(ui_users.get()); | 591 view_->ShowExistingSupervisedUsers(ui_users.get()); |
591 } | 592 } |
592 | 593 |
593 void SupervisedUserCreationScreen::OnPhotoTaken( | 594 void SupervisedUserCreationScreen::OnPhotoTaken( |
594 const std::string& raw_data) { | 595 const std::string& raw_data) { |
595 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 596 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
596 user_photo_ = gfx::ImageSkia(); | 597 user_photo_ = gfx::ImageSkia(); |
597 ImageDecoder::Cancel(this); | 598 ImageDecoder::Cancel(this); |
(...skipping 24 matching lines...) Expand all Loading... |
622 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; | 623 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; |
623 } else { | 624 } else { |
624 NOTREACHED() << "Unexpected image type: " << image_type; | 625 NOTREACHED() << "Unexpected image type: " << image_type; |
625 } | 626 } |
626 } | 627 } |
627 | 628 |
628 void SupervisedUserCreationScreen::OnImageAccepted() { | 629 void SupervisedUserCreationScreen::OnImageAccepted() { |
629 } | 630 } |
630 | 631 |
631 } // namespace chromeos | 632 } // namespace chromeos |
OLD | NEW |