| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/screens/user_image_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/user_image_screen.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 20 #include "chrome/browser/chromeos/camera_presence_notifier.h" |
| 20 #include "chrome/browser/chromeos/login/default_user_images.h" | 21 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 21 #include "chrome/browser/chromeos/login/login_utils.h" | 22 #include "chrome/browser/chromeos/login/login_utils.h" |
| 22 #include "chrome/browser/chromeos/login/screens/screen_observer.h" | 23 #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
| 23 #include "chrome/browser/chromeos/login/user_image.h" | 24 #include "chrome/browser/chromeos/login/user_image.h" |
| 24 #include "chrome/browser/chromeos/login/user_image_manager.h" | 25 #include "chrome/browser/chromeos/login/user_image_manager.h" |
| 25 #include "chrome/browser/chromeos/login/user_manager.h" | 26 #include "chrome/browser/chromeos/login/user_manager.h" |
| 26 #include "chrome/browser/chromeos/login/wizard_controller.h" | 27 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 27 #include "chrome/browser/policy/profile_policy_connector.h" | 28 #include "chrome/browser/policy/profile_policy_connector.h" |
| 28 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 29 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 is_screen_ready_(false), | 70 is_screen_ready_(false), |
| 70 user_has_selected_image_(false) { | 71 user_has_selected_image_(false) { |
| 71 actor_->SetDelegate(this); | 72 actor_->SetDelegate(this); |
| 72 SetProfilePictureEnabled(true); | 73 SetProfilePictureEnabled(true); |
| 73 notification_registrar_.Add(this, | 74 notification_registrar_.Add(this, |
| 74 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 75 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 75 content::NotificationService::AllSources()); | 76 content::NotificationService::AllSources()); |
| 76 } | 77 } |
| 77 | 78 |
| 78 UserImageScreen::~UserImageScreen() { | 79 UserImageScreen::~UserImageScreen() { |
| 80 CameraPresenceNotifier::GetInstance()->RemoveObserver(this); |
| 79 if (actor_) | 81 if (actor_) |
| 80 actor_->SetDelegate(NULL); | 82 actor_->SetDelegate(NULL); |
| 81 if (image_decoder_.get()) | 83 if (image_decoder_.get()) |
| 82 image_decoder_->set_delegate(NULL); | 84 image_decoder_->set_delegate(NULL); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void UserImageScreen::OnScreenReady() { | 87 void UserImageScreen::OnScreenReady() { |
| 86 is_screen_ready_ = true; | 88 is_screen_ready_ = true; |
| 87 if (!IsWaitingForSync()) | 89 if (!IsWaitingForSync()) |
| 88 HideCurtain(); | 90 HideCurtain(); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 300 } |
| 299 sync_observer->AddObserver(this); | 301 sync_observer->AddObserver(this); |
| 300 sync_timer_.reset(new base::Timer( | 302 sync_timer_.reset(new base::Timer( |
| 301 FROM_HERE, | 303 FROM_HERE, |
| 302 base::TimeDelta::FromSeconds(kSyncTimeoutSeconds), | 304 base::TimeDelta::FromSeconds(kSyncTimeoutSeconds), |
| 303 base::Bind(&UserImageScreen::OnSyncTimeout, base::Unretained(this)), | 305 base::Bind(&UserImageScreen::OnSyncTimeout, base::Unretained(this)), |
| 304 false)); | 306 false)); |
| 305 sync_timer_->Reset(); | 307 sync_timer_->Reset(); |
| 306 } | 308 } |
| 307 } | 309 } |
| 310 CameraPresenceNotifier::GetInstance()->AddObserver(this); |
| 308 actor_->Show(); | 311 actor_->Show(); |
| 309 actor_->SetProfilePictureEnabled(profile_picture_enabled_); | 312 actor_->SetProfilePictureEnabled(profile_picture_enabled_); |
| 310 | 313 |
| 311 selected_image_ = GetUser()->image_index(); | 314 selected_image_ = GetUser()->image_index(); |
| 312 actor_->SelectImage(selected_image_); | 315 actor_->SelectImage(selected_image_); |
| 313 | 316 |
| 314 if (profile_picture_enabled_) { | 317 if (profile_picture_enabled_) { |
| 315 // Start fetching the profile image. | 318 // Start fetching the profile image. |
| 316 GetUserImageManager()->DownloadProfileImage(kProfileDownloadReason); | 319 GetUserImageManager()->DownloadProfileImage(kProfileDownloadReason); |
| 317 } | 320 } |
| 318 } | 321 } |
| 319 | 322 |
| 320 void UserImageScreen::Hide() { | 323 void UserImageScreen::Hide() { |
| 324 CameraPresenceNotifier::GetInstance()->RemoveObserver(this); |
| 321 if (actor_) | 325 if (actor_) |
| 322 actor_->Hide(); | 326 actor_->Hide(); |
| 323 } | 327 } |
| 324 | 328 |
| 325 std::string UserImageScreen::GetName() const { | 329 std::string UserImageScreen::GetName() const { |
| 326 return WizardController::kUserImageScreenName; | 330 return WizardController::kUserImageScreenName; |
| 327 } | 331 } |
| 328 | 332 |
| 329 void UserImageScreen::OnActorDestroyed(UserImageScreenActor* actor) { | 333 void UserImageScreen::OnActorDestroyed(UserImageScreenActor* actor) { |
| 330 if (actor_ == actor) | 334 if (actor_ == actor) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 379 |
| 376 void UserImageScreen::ExitScreen() { | 380 void UserImageScreen::ExitScreen() { |
| 377 policy_registrar_.reset(); | 381 policy_registrar_.reset(); |
| 378 sync_timer_.reset(); | 382 sync_timer_.reset(); |
| 379 if (UserImageSyncObserver* sync_observer = GetSyncObserver()) | 383 if (UserImageSyncObserver* sync_observer = GetSyncObserver()) |
| 380 sync_observer->RemoveObserver(this); | 384 sync_observer->RemoveObserver(this); |
| 381 get_screen_observer()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); | 385 get_screen_observer()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); |
| 382 } | 386 } |
| 383 | 387 |
| 384 } // namespace chromeos | 388 } // namespace chromeos |
| OLD | NEW |