Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 SupervisedUserCreationScreen* SupervisedUserCreationScreen::Get( | 93 SupervisedUserCreationScreen* SupervisedUserCreationScreen::Get( |
| 94 ScreenManager* manager) { | 94 ScreenManager* manager) { |
| 95 return static_cast<SupervisedUserCreationScreen*>( | 95 return static_cast<SupervisedUserCreationScreen*>( |
| 96 manager->GetScreen(WizardController::kSupervisedUserCreationScreenName)); | 96 manager->GetScreen(WizardController::kSupervisedUserCreationScreenName)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 SupervisedUserCreationScreen::SupervisedUserCreationScreen( | 99 SupervisedUserCreationScreen::SupervisedUserCreationScreen( |
| 100 BaseScreenDelegate* base_screen_delegate, | 100 BaseScreenDelegate* base_screen_delegate, |
| 101 SupervisedUserCreationScreenHandler* actor) | 101 SupervisedUserCreationScreenHandler* actor) |
| 102 : BaseScreen(base_screen_delegate), | 102 : BaseScreen(base_screen_delegate), |
| 103 ImageDecoder::ImageRequest( | |
|
dcheng
2015/03/23 11:52:08
I think you should be able to just say ImageReques
Theresa
2015/03/23 17:33:09
Done.
| |
| 104 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 105 content::BrowserThread::UI)), | |
| 103 actor_(actor), | 106 actor_(actor), |
| 104 on_error_screen_(false), | 107 on_error_screen_(false), |
| 105 manager_signin_in_progress_(false), | 108 manager_signin_in_progress_(false), |
| 106 last_page_(kNameOfIntroScreen), | 109 last_page_(kNameOfIntroScreen), |
| 107 sync_service_(NULL), | 110 sync_service_(NULL), |
| 108 image_decoder_(NULL), | |
| 109 apply_photo_after_decoding_(false), | 111 apply_photo_after_decoding_(false), |
| 110 selected_image_(0), | 112 selected_image_(0), |
| 111 histogram_helper_(new ErrorScreensHistogramHelper("Supervised")), | 113 histogram_helper_(new ErrorScreensHistogramHelper("Supervised")), |
| 112 weak_factory_(this) { | 114 weak_factory_(this) { |
| 113 DCHECK(actor_); | 115 DCHECK(actor_); |
| 114 if (actor_) | 116 if (actor_) |
| 115 actor_->SetDelegate(this); | 117 actor_->SetDelegate(this); |
| 116 } | 118 } |
| 117 | 119 |
| 118 SupervisedUserCreationScreen::~SupervisedUserCreationScreen() { | 120 SupervisedUserCreationScreen::~SupervisedUserCreationScreen() { |
| 119 CameraPresenceNotifier::GetInstance()->RemoveObserver(this); | 121 CameraPresenceNotifier::GetInstance()->RemoveObserver(this); |
| 120 if (sync_service_) | 122 if (sync_service_) |
| 121 sync_service_->RemoveObserver(this); | 123 sync_service_->RemoveObserver(this); |
| 122 if (actor_) | 124 if (actor_) |
| 123 actor_->SetDelegate(NULL); | 125 actor_->SetDelegate(NULL); |
| 124 if (image_decoder_.get()) | |
| 125 image_decoder_->set_delegate(NULL); | |
| 126 NetworkPortalDetector::Get()->RemoveObserver(this); | 126 NetworkPortalDetector::Get()->RemoveObserver(this); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void SupervisedUserCreationScreen::PrepareToShow() { | 129 void SupervisedUserCreationScreen::PrepareToShow() { |
| 130 if (actor_) | 130 if (actor_) |
| 131 actor_->PrepareToShow(); | 131 actor_->PrepareToShow(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void SupervisedUserCreationScreen::Show() { | 134 void SupervisedUserCreationScreen::Show() { |
| 135 CameraPresenceNotifier::GetInstance()->AddObserver(this); | 135 CameraPresenceNotifier::GetInstance()->AddObserver(this); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 existing_users_->Set(it.key(), local_copy); | 585 existing_users_->Set(it.key(), local_copy); |
| 586 ui_users->Append(ui_copy); | 586 ui_users->Append(ui_copy); |
| 587 } | 587 } |
| 588 actor_->ShowExistingSupervisedUsers(ui_users.get()); | 588 actor_->ShowExistingSupervisedUsers(ui_users.get()); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void SupervisedUserCreationScreen::OnPhotoTaken( | 591 void SupervisedUserCreationScreen::OnPhotoTaken( |
| 592 const std::string& raw_data) { | 592 const std::string& raw_data) { |
| 593 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 593 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 594 user_photo_ = gfx::ImageSkia(); | 594 user_photo_ = gfx::ImageSkia(); |
| 595 if (image_decoder_.get()) | 595 ImageDecoder::Cancel(this); |
| 596 image_decoder_->set_delegate(NULL); | 596 ImageDecoder::Start(this, raw_data, ImageDecoder::DEFAULT_CODEC, false); |
| 597 image_decoder_ = new ImageDecoder(this, raw_data, | |
| 598 ImageDecoder::DEFAULT_CODEC); | |
| 599 scoped_refptr<base::MessageLoopProxy> task_runner = | |
| 600 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 601 content::BrowserThread::UI); | |
| 602 image_decoder_->Start(task_runner); | |
| 603 } | 597 } |
| 604 | 598 |
| 605 void SupervisedUserCreationScreen::OnImageDecoded( | 599 void SupervisedUserCreationScreen::OnImageDecoded( |
| 606 const ImageDecoder* decoder, | |
| 607 const SkBitmap& decoded_image) { | 600 const SkBitmap& decoded_image) { |
| 608 DCHECK_EQ(image_decoder_.get(), decoder); | |
| 609 user_photo_ = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image); | 601 user_photo_ = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image); |
| 610 if (apply_photo_after_decoding_) | 602 if (apply_photo_after_decoding_) |
| 611 ApplyPicture(); | 603 ApplyPicture(); |
| 612 } | 604 } |
| 613 | 605 |
| 614 void SupervisedUserCreationScreen::OnDecodeImageFailed( | 606 void SupervisedUserCreationScreen::OnDecodeImageFailed() { |
| 615 const ImageDecoder* decoder) { | |
| 616 NOTREACHED() << "Failed to decode PNG image from WebUI"; | 607 NOTREACHED() << "Failed to decode PNG image from WebUI"; |
| 617 } | 608 } |
| 618 | 609 |
| 619 void SupervisedUserCreationScreen::OnImageSelected( | 610 void SupervisedUserCreationScreen::OnImageSelected( |
| 620 const std::string& image_type, | 611 const std::string& image_type, |
| 621 const std::string& image_url) { | 612 const std::string& image_url) { |
| 622 if (image_url.empty()) | 613 if (image_url.empty()) |
| 623 return; | 614 return; |
| 624 int user_image_index = user_manager::User::USER_IMAGE_INVALID; | 615 int user_image_index = user_manager::User::USER_IMAGE_INVALID; |
| 625 if (image_type == "default" && | 616 if (image_type == "default" && |
| 626 user_manager::IsDefaultImageUrl(image_url, &user_image_index)) { | 617 user_manager::IsDefaultImageUrl(image_url, &user_image_index)) { |
| 627 selected_image_ = user_image_index; | 618 selected_image_ = user_image_index; |
| 628 } else if (image_type == "camera") { | 619 } else if (image_type == "camera") { |
| 629 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; | 620 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; |
| 630 } else { | 621 } else { |
| 631 NOTREACHED() << "Unexpected image type: " << image_type; | 622 NOTREACHED() << "Unexpected image type: " << image_type; |
| 632 } | 623 } |
| 633 } | 624 } |
| 634 | 625 |
| 635 void SupervisedUserCreationScreen::OnImageAccepted() { | 626 void SupervisedUserCreationScreen::OnImageAccepted() { |
| 636 } | 627 } |
| 637 | 628 |
| 638 } // namespace chromeos | 629 } // namespace chromeos |
| OLD | NEW |