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