| 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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/chromeos/login/screens/user_image_screen_actor.h" | 10 #include "chrome/browser/chromeos/login/screens/user_image_screen_actor.h" |
| 10 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" | 11 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" |
| 11 #include "chrome/browser/chromeos/login/user.h" | 12 #include "chrome/browser/chromeos/login/user.h" |
| 13 #include "chrome/browser/image_decoder.h" |
| 12 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 14 | 16 |
| 15 namespace chromeos { | 17 namespace chromeos { |
| 16 | 18 |
| 17 class UserImageScreen: public WizardScreen, | 19 class UserImageScreen: public WizardScreen, |
| 18 public UserImageScreenActor::Delegate, | 20 public UserImageScreenActor::Delegate, |
| 21 public ImageDecoder::Delegate, |
| 19 public content::NotificationObserver { | 22 public content::NotificationObserver { |
| 20 public: | 23 public: |
| 21 UserImageScreen(ScreenObserver* screen_observer, | 24 UserImageScreen(ScreenObserver* screen_observer, |
| 22 UserImageScreenActor* actor); | 25 UserImageScreenActor* actor); |
| 23 virtual ~UserImageScreen(); | 26 virtual ~UserImageScreen(); |
| 24 | 27 |
| 25 // Indicates whether profile picture is enabled for given user. | 28 // Indicates whether profile picture is enabled for given user. |
| 26 void SetProfilePictureEnabled(bool support_profile_picture); | 29 void SetProfilePictureEnabled(bool support_profile_picture); |
| 27 // Sets |user_id| of user that would have picture updated. | 30 // Sets |user_id| of user that would have picture updated. |
| 28 void SetUserID(const std::string& user_id); | 31 void SetUserID(const std::string& user_id); |
| 29 | 32 |
| 30 // WizardScreen implementation: | 33 // WizardScreen implementation: |
| 31 virtual void PrepareToShow() OVERRIDE; | 34 virtual void PrepareToShow() OVERRIDE; |
| 32 virtual void Show() OVERRIDE; | 35 virtual void Show() OVERRIDE; |
| 33 virtual void Hide() OVERRIDE; | 36 virtual void Hide() OVERRIDE; |
| 34 virtual std::string GetName() const OVERRIDE; | 37 virtual std::string GetName() const OVERRIDE; |
| 35 | 38 |
| 36 // UserImageScreenActor::Delegate implementation: | 39 // UserImageScreenActor::Delegate implementation: |
| 37 virtual void OnPhotoTaken(const gfx::ImageSkia& image) OVERRIDE; | 40 virtual void CheckCameraPresence() OVERRIDE; |
| 38 virtual void OnProfileImageSelected() OVERRIDE; | 41 virtual void OnPhotoTaken(const std::string& raw_data) OVERRIDE; |
| 39 virtual void OnDefaultImageSelected(int index) OVERRIDE; | 42 virtual void OnImageSelected(const std::string& image_url, |
| 43 const std::string& image_type) OVERRIDE; |
| 44 virtual void OnImageAccepted() OVERRIDE; |
| 40 virtual void OnActorDestroyed(UserImageScreenActor* actor) OVERRIDE; | 45 virtual void OnActorDestroyed(UserImageScreenActor* actor) OVERRIDE; |
| 41 | 46 |
| 47 virtual bool profile_picture_absent() OVERRIDE; |
| 48 virtual int selected_image() OVERRIDE; |
| 49 virtual std::string profile_picture_data_url() OVERRIDE; |
| 50 |
| 42 // content::NotificationObserver implementation: | 51 // content::NotificationObserver implementation: |
| 43 virtual void Observe(int type, | 52 virtual void Observe(int type, |
| 44 const content::NotificationSource& source, | 53 const content::NotificationSource& source, |
| 45 const content::NotificationDetails& details) OVERRIDE; | 54 const content::NotificationDetails& details) OVERRIDE; |
| 46 | 55 |
| 56 // Overriden from ImageDecoder::Delegate: |
| 57 virtual void OnImageDecoded(const ImageDecoder* decoder, |
| 58 const SkBitmap& decoded_image) OVERRIDE; |
| 59 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; |
| 60 |
| 47 private: | 61 private: |
| 48 const User* GetUser(); | 62 const User* GetUser(); |
| 49 | 63 |
| 64 // Called when the camera presence check has been completed. |
| 65 void OnCameraPresenceCheckDone(); |
| 66 |
| 50 content::NotificationRegistrar registrar_; | 67 content::NotificationRegistrar registrar_; |
| 51 | 68 |
| 52 UserImageScreenActor* actor_; | 69 UserImageScreenActor* actor_; |
| 53 | 70 |
| 71 base::WeakPtrFactory<UserImageScreen> weak_factory_; |
| 72 |
| 73 // Last ImageDecoder instance used to decode an image blob received by |
| 74 // HandlePhotoTaken. |
| 75 scoped_refptr<ImageDecoder> image_decoder_; |
| 76 |
| 77 // Last user photo, if taken. |
| 78 gfx::ImageSkia user_photo_; |
| 79 |
| 80 // If |true|, decoded photo should be immediately accepeted (i.e., both |
| 81 // HandleTakePhoto and HandleImageAccepted have already been called but we're |
| 82 // still waiting for photo image decoding to finish. |
| 83 bool accept_photo_after_decoding_; |
| 84 |
| 85 // Index of the selected user image. |
| 86 int selected_image_; |
| 87 |
| 54 bool profile_picture_enabled_; | 88 bool profile_picture_enabled_; |
| 55 | 89 |
| 90 // Encoded profile picture. |
| 91 std::string profile_picture_data_url_; |
| 92 |
| 93 // True if user has no custom profile picture. |
| 94 bool profile_picture_absent_; |
| 95 |
| 56 std::string user_id_; | 96 std::string user_id_; |
| 57 | 97 |
| 58 DISALLOW_COPY_AND_ASSIGN(UserImageScreen); | 98 DISALLOW_COPY_AND_ASSIGN(UserImageScreen); |
| 59 }; | 99 }; |
| 60 | 100 |
| 61 } // namespace chromeos | 101 } // namespace chromeos |
| 62 | 102 |
| 63 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ | 103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ |
| OLD | NEW |