| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/chromeos/camera_presence_notifier.h" | 13 #include "chrome/browser/chromeos/camera_presence_notifier.h" |
| 14 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 14 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 15 #include "chrome/browser/chromeos/login/screens/user_image_model.h" | 15 #include "chrome/browser/chromeos/login/screens/user_image_model.h" |
| 16 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" | 16 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" |
| 17 #include "chrome/browser/image_decoder.h" | 17 #include "chrome/browser/image_decoder.h" |
| 18 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 19 #include "content/public/browser/notification_observer.h" | 19 #include "components/user_manager/user_manager.h" |
| 20 #include "content/public/browser/notification_registrar.h" | |
| 21 | 20 |
| 22 namespace base { | 21 namespace base { |
| 23 class Timer; | 22 class Timer; |
| 24 class Value; | 23 class Value; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace policy { | 26 namespace policy { |
| 28 class PolicyChangeRegistrar; | 27 class PolicyChangeRegistrar; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace chromeos { | 30 namespace chromeos { |
| 32 | 31 |
| 33 class ScreenManager; | 32 class ScreenManager; |
| 34 class UserImageManager; | 33 class UserImageManager; |
| 35 class UserImageView; | 34 class UserImageView; |
| 36 | 35 |
| 37 class UserImageScreen : public UserImageModel, | 36 class UserImageScreen : public UserImageModel, |
| 38 public ImageDecoder::ImageRequest, | 37 public ImageDecoder::ImageRequest, |
| 39 public content::NotificationObserver, | 38 public user_manager::UserManager::Observer, |
| 40 public UserImageSyncObserver::Observer, | 39 public UserImageSyncObserver::Observer, |
| 41 public CameraPresenceNotifier::Observer { | 40 public CameraPresenceNotifier::Observer { |
| 42 public: | 41 public: |
| 43 UserImageScreen(BaseScreenDelegate* base_screen_delegate, | 42 UserImageScreen(BaseScreenDelegate* base_screen_delegate, |
| 44 UserImageView* view); | 43 UserImageView* view); |
| 45 ~UserImageScreen() override; | 44 ~UserImageScreen() override; |
| 46 | 45 |
| 47 static UserImageScreen* Get(ScreenManager* manager); | 46 static UserImageScreen* Get(ScreenManager* manager); |
| 48 | 47 |
| 49 // BaseScreen implementation: | 48 // BaseScreen implementation: |
| 50 void Show() override; | 49 void Show() override; |
| 51 void Hide() override; | 50 void Hide() override; |
| 52 | 51 |
| 53 // UserImageScreenActor::Delegate implementation: | 52 // UserImageScreenActor::Delegate implementation: |
| 54 void OnScreenReady() override; | 53 void OnScreenReady() override; |
| 55 void OnPhotoTaken(const std::string& raw_data) override; | 54 void OnPhotoTaken(const std::string& raw_data) override; |
| 56 void OnImageSelected(const std::string& image_url, | 55 void OnImageSelected(const std::string& image_url, |
| 57 const std::string& image_type, | 56 const std::string& image_type, |
| 58 bool is_user_selection) override; | 57 bool is_user_selection) override; |
| 59 void OnImageAccepted() override; | 58 void OnImageAccepted() override; |
| 60 void OnViewDestroyed(UserImageView* view) override; | 59 void OnViewDestroyed(UserImageView* view) override; |
| 61 | 60 |
| 62 // content::NotificationObserver implementation: | 61 // user_manager::UserManager::Observer implementation: |
| 63 void Observe(int type, | 62 void OnUserImageChanged(const user_manager::User& user) override; |
| 64 const content::NotificationSource& source, | 63 void OnUserProfileImageUpdateFailed(const user_manager::User& user) override; |
| 65 const content::NotificationDetails& details) override; | 64 void OnUserProfileImageUpdated(const user_manager::User& user, |
| 65 const gfx::ImageSkia& profile_image) override; |
| 66 | 66 |
| 67 // ImageDecoder::ImageRequest implementation: | 67 // ImageDecoder::ImageRequest implementation: |
| 68 void OnImageDecoded(const SkBitmap& decoded_image) override; | 68 void OnImageDecoded(const SkBitmap& decoded_image) override; |
| 69 void OnDecodeImageFailed() override; | 69 void OnDecodeImageFailed() override; |
| 70 | 70 |
| 71 // CameraPresenceNotifier::Observer implementation: | 71 // CameraPresenceNotifier::Observer implementation: |
| 72 void OnCameraPresenceCheckDone(bool is_camera_present) override; | 72 void OnCameraPresenceCheckDone(bool is_camera_present) override; |
| 73 | 73 |
| 74 // UserImageSyncObserver::Observer implementation: | 74 // UserImageSyncObserver::Observer implementation: |
| 75 void OnInitialSync(bool local_image_updated) override; | 75 void OnInitialSync(bool local_image_updated) override; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Called when it's decided not to skip the screen. | 109 // Called when it's decided not to skip the screen. |
| 110 void HideCurtain(); | 110 void HideCurtain(); |
| 111 | 111 |
| 112 // Closes the screen. | 112 // Closes the screen. |
| 113 void ExitScreen(); | 113 void ExitScreen(); |
| 114 | 114 |
| 115 // Reports sync duration and result to UMA. | 115 // Reports sync duration and result to UMA. |
| 116 void ReportSyncResult(SyncResult timed_out) const; | 116 void ReportSyncResult(SyncResult timed_out) const; |
| 117 | 117 |
| 118 content::NotificationRegistrar notification_registrar_; | |
| 119 | |
| 120 std::unique_ptr<policy::PolicyChangeRegistrar> policy_registrar_; | 118 std::unique_ptr<policy::PolicyChangeRegistrar> policy_registrar_; |
| 121 | 119 |
| 122 UserImageView* view_; | 120 UserImageView* view_; |
| 123 | 121 |
| 124 // Last user photo, if taken. | 122 // Last user photo, if taken. |
| 125 gfx::ImageSkia user_photo_; | 123 gfx::ImageSkia user_photo_; |
| 126 | 124 |
| 127 // If |true|, decoded photo should be immediately accepted (i.e., both | 125 // If |true|, decoded photo should be immediately accepted (i.e., both |
| 128 // HandleTakePhoto and HandleImageAccepted have already been called but we're | 126 // HandleTakePhoto and HandleImageAccepted have already been called but we're |
| 129 // still waiting for photo image decoding to finish. | 127 // still waiting for photo image decoding to finish. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 | 141 |
| 144 // The time when we started wait for user image sync. | 142 // The time when we started wait for user image sync. |
| 145 base::Time sync_waiting_start_time_; | 143 base::Time sync_waiting_start_time_; |
| 146 | 144 |
| 147 DISALLOW_COPY_AND_ASSIGN(UserImageScreen); | 145 DISALLOW_COPY_AND_ASSIGN(UserImageScreen); |
| 148 }; | 146 }; |
| 149 | 147 |
| 150 } // namespace chromeos | 148 } // namespace chromeos |
| 151 | 149 |
| 152 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ | 150 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ |
| OLD | NEW |