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 "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 apply_photo_after_decoding_ = true; | 451 apply_photo_after_decoding_ = true; |
452 return; | 452 return; |
453 } | 453 } |
454 image_manager->SaveUserImage( | 454 image_manager->SaveUserImage( |
455 user_manager::UserImage::CreateAndEncode(user_photo_)); | 455 user_manager::UserImage::CreateAndEncode(user_photo_)); |
456 break; | 456 break; |
457 case User::kProfileImageIndex: | 457 case User::kProfileImageIndex: |
458 NOTREACHED() << "Supervised users have no profile pictures"; | 458 NOTREACHED() << "Supervised users have no profile pictures"; |
459 break; | 459 break; |
460 default: | 460 default: |
461 DCHECK(selected_image_ >= 0 && | 461 DCHECK(selected_image_ >= 0 && selected_image_ < kDefaultImagesCount); |
462 selected_image_ < user_manager::kDefaultImagesCount); | |
463 image_manager->SaveUserDefaultImageIndex(selected_image_); | 462 image_manager->SaveUserDefaultImageIndex(selected_image_); |
464 break; | 463 break; |
465 } | 464 } |
466 // Proceed to tutorial. | 465 // Proceed to tutorial. |
467 actor_->ShowTutorialPage(); | 466 actor_->ShowTutorialPage(); |
468 } | 467 } |
469 | 468 |
470 void SupervisedUserCreationScreen::OnCreationSuccess() { | 469 void SupervisedUserCreationScreen::OnCreationSuccess() { |
471 ApplyPicture(); | 470 ApplyPicture(); |
472 } | 471 } |
(...skipping 23 matching lines...) Expand all Loading... |
496 base::DictionaryValue* ui_copy = | 495 base::DictionaryValue* ui_copy = |
497 static_cast<base::DictionaryValue*>(new base::DictionaryValue()); | 496 static_cast<base::DictionaryValue*>(new base::DictionaryValue()); |
498 | 497 |
499 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; | 498 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; |
500 std::string chromeos_avatar; | 499 std::string chromeos_avatar; |
501 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar, | 500 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar, |
502 &chromeos_avatar) && | 501 &chromeos_avatar) && |
503 !chromeos_avatar.empty() && | 502 !chromeos_avatar.empty() && |
504 SupervisedUserSyncService::GetAvatarIndex( | 503 SupervisedUserSyncService::GetAvatarIndex( |
505 chromeos_avatar, &avatar_index)) { | 504 chromeos_avatar, &avatar_index)) { |
506 ui_copy->SetString(kAvatarURLKey, | 505 ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(avatar_index)); |
507 user_manager::GetDefaultImageUrl(avatar_index)); | |
508 } else { | 506 } else { |
509 int i = base::RandInt(user_manager::kFirstDefaultImageIndex, | 507 int i = base::RandInt(kFirstDefaultImageIndex, kDefaultImagesCount - 1); |
510 user_manager::kDefaultImagesCount - 1); | |
511 local_copy->SetString( | 508 local_copy->SetString( |
512 SupervisedUserSyncService::kChromeOsAvatar, | 509 SupervisedUserSyncService::kChromeOsAvatar, |
513 SupervisedUserSyncService::BuildAvatarString(i)); | 510 SupervisedUserSyncService::BuildAvatarString(i)); |
514 local_copy->SetBoolean(kRandomAvatarKey, true); | 511 local_copy->SetBoolean(kRandomAvatarKey, true); |
515 ui_copy->SetString(kAvatarURLKey, user_manager::GetDefaultImageUrl(i)); | 512 ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(i)); |
516 } | 513 } |
517 | 514 |
518 local_copy->SetBoolean(kUserExists, false); | 515 local_copy->SetBoolean(kUserExists, false); |
519 ui_copy->SetBoolean(kUserExists, false); | 516 ui_copy->SetBoolean(kUserExists, false); |
520 | 517 |
521 base::string16 display_name; | 518 base::string16 display_name; |
522 local_copy->GetString(SupervisedUserSyncService::kName, &display_name); | 519 local_copy->GetString(SupervisedUserSyncService::kName, &display_name); |
523 | 520 |
524 if (supervised_user_manager->FindBySyncId(it.key())) { | 521 if (supervised_user_manager->FindBySyncId(it.key())) { |
525 local_copy->SetBoolean(kUserExists, true); | 522 local_copy->SetBoolean(kUserExists, true); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 NOTREACHED() << "Failed to decode PNG image from WebUI"; | 574 NOTREACHED() << "Failed to decode PNG image from WebUI"; |
578 } | 575 } |
579 | 576 |
580 void SupervisedUserCreationScreen::OnImageSelected( | 577 void SupervisedUserCreationScreen::OnImageSelected( |
581 const std::string& image_type, | 578 const std::string& image_type, |
582 const std::string& image_url) { | 579 const std::string& image_url) { |
583 if (image_url.empty()) | 580 if (image_url.empty()) |
584 return; | 581 return; |
585 int user_image_index = User::kInvalidImageIndex; | 582 int user_image_index = User::kInvalidImageIndex; |
586 if (image_type == "default" && | 583 if (image_type == "default" && |
587 user_manager::IsDefaultImageUrl(image_url, &user_image_index)) { | 584 IsDefaultImageUrl(image_url, &user_image_index)) { |
588 selected_image_ = user_image_index; | 585 selected_image_ = user_image_index; |
589 } else if (image_type == "camera") { | 586 } else if (image_type == "camera") { |
590 selected_image_ = User::kExternalImageIndex; | 587 selected_image_ = User::kExternalImageIndex; |
591 } else { | 588 } else { |
592 NOTREACHED() << "Unexpected image type: " << image_type; | 589 NOTREACHED() << "Unexpected image type: " << image_type; |
593 } | 590 } |
594 } | 591 } |
595 | 592 |
596 void SupervisedUserCreationScreen::OnImageAccepted() { | 593 void SupervisedUserCreationScreen::OnImageAccepted() { |
597 } | 594 } |
598 | 595 |
599 } // namespace chromeos | 596 } // namespace chromeos |
OLD | NEW |