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