| 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> |
| 8 |
| 7 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 8 #include "ash/common/wallpaper/wallpaper_controller.h" | 10 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 9 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "base/memory/ptr_util.h" |
| 10 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 11 #include "base/values.h" | 14 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/camera_detector.h" | 15 #include "chrome/browser/chromeos/camera_detector.h" |
| 13 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" | 16 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" |
| 14 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 17 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 15 #include "chrome/browser/chromeos/login/screen_manager.h" | 18 #include "chrome/browser/chromeos/login/screen_manager.h" |
| 16 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" | 19 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" |
| 17 #include "chrome/browser/chromeos/login/screens/error_screen.h" | 20 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
| 18 #include "chrome/browser/chromeos/login/screens/network_error.h" | 21 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 19 #include "chrome/browser/chromeos/login/signin_specifics.h" | 22 #include "chrome/browser/chromeos/login/signin_specifics.h" |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 534 |
| 532 // Stored copy, contains all necessary information. | 535 // Stored copy, contains all necessary information. |
| 533 existing_users_.reset(new base::DictionaryValue()); | 536 existing_users_.reset(new base::DictionaryValue()); |
| 534 for (base::DictionaryValue::Iterator it(*users); !it.IsAtEnd(); | 537 for (base::DictionaryValue::Iterator it(*users); !it.IsAtEnd(); |
| 535 it.Advance()) { | 538 it.Advance()) { |
| 536 // Copy that would be stored in this class. | 539 // Copy that would be stored in this class. |
| 537 base::DictionaryValue* local_copy = | 540 base::DictionaryValue* local_copy = |
| 538 static_cast<base::DictionaryValue*>(it.value().DeepCopy()); | 541 static_cast<base::DictionaryValue*>(it.value().DeepCopy()); |
| 539 // Copy that would be passed to WebUI. It has some extra values for | 542 // Copy that would be passed to WebUI. It has some extra values for |
| 540 // displaying, but does not contain sensitive data, such as master password. | 543 // displaying, but does not contain sensitive data, such as master password. |
| 541 base::DictionaryValue* ui_copy = | 544 auto ui_copy = base::MakeUnique<base::DictionaryValue>(); |
| 542 static_cast<base::DictionaryValue*>(new base::DictionaryValue()); | |
| 543 | 545 |
| 544 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; | 546 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; |
| 545 std::string chromeos_avatar; | 547 std::string chromeos_avatar; |
| 546 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar, | 548 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar, |
| 547 &chromeos_avatar) && | 549 &chromeos_avatar) && |
| 548 !chromeos_avatar.empty() && | 550 !chromeos_avatar.empty() && |
| 549 SupervisedUserSyncService::GetAvatarIndex( | 551 SupervisedUserSyncService::GetAvatarIndex( |
| 550 chromeos_avatar, &avatar_index)) { | 552 chromeos_avatar, &avatar_index)) { |
| 551 ui_copy->SetString(kAvatarURLKey, | 553 ui_copy->SetString(kAvatarURLKey, |
| 552 default_user_image::GetDefaultImageUrl(avatar_index)); | 554 default_user_image::GetDefaultImageUrl(avatar_index)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 583 std::string signature_key; | 585 std::string signature_key; |
| 584 bool has_password = | 586 bool has_password = |
| 585 local_copy->GetString(SupervisedUserSyncService::kPasswordSignatureKey, | 587 local_copy->GetString(SupervisedUserSyncService::kPasswordSignatureKey, |
| 586 &signature_key) && | 588 &signature_key) && |
| 587 !signature_key.empty(); | 589 !signature_key.empty(); |
| 588 | 590 |
| 589 ui_copy->SetBoolean(kUserNeedPassword, !has_password); | 591 ui_copy->SetBoolean(kUserNeedPassword, !has_password); |
| 590 ui_copy->SetString("id", it.key()); | 592 ui_copy->SetString("id", it.key()); |
| 591 | 593 |
| 592 existing_users_->Set(it.key(), local_copy); | 594 existing_users_->Set(it.key(), local_copy); |
| 593 ui_users->Append(ui_copy); | 595 ui_users->Append(std::move(ui_copy)); |
| 594 } | 596 } |
| 595 actor_->ShowExistingSupervisedUsers(ui_users.get()); | 597 actor_->ShowExistingSupervisedUsers(ui_users.get()); |
| 596 } | 598 } |
| 597 | 599 |
| 598 void SupervisedUserCreationScreen::OnPhotoTaken( | 600 void SupervisedUserCreationScreen::OnPhotoTaken( |
| 599 const std::string& raw_data) { | 601 const std::string& raw_data) { |
| 600 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 602 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 601 user_photo_ = gfx::ImageSkia(); | 603 user_photo_ = gfx::ImageSkia(); |
| 602 ImageDecoder::Cancel(this); | 604 ImageDecoder::Cancel(this); |
| 603 ImageDecoder::Start(this, raw_data); | 605 ImageDecoder::Start(this, raw_data); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 627 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; | 629 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; |
| 628 } else { | 630 } else { |
| 629 NOTREACHED() << "Unexpected image type: " << image_type; | 631 NOTREACHED() << "Unexpected image type: " << image_type; |
| 630 } | 632 } |
| 631 } | 633 } |
| 632 | 634 |
| 633 void SupervisedUserCreationScreen::OnImageAccepted() { | 635 void SupervisedUserCreationScreen::OnImageAccepted() { |
| 634 } | 636 } |
| 635 | 637 |
| 636 } // namespace chromeos | 638 } // namespace chromeos |
| OLD | NEW |