Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / login / screens / user_image_screen.h
blob5050f99c16b0b027e049fe420db7a67aa56d0380
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h"
11 #include "chrome/browser/chromeos/camera_presence_notifier.h"
12 #include "chrome/browser/chromeos/login/screens/base_screen.h"
13 #include "chrome/browser/chromeos/login/screens/user_image_model.h"
14 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h"
15 #include "chrome/browser/image_decoder.h"
16 #include "components/user_manager/user.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
20 namespace base {
21 class Timer;
22 class Value;
25 namespace policy {
26 class PolicyChangeRegistrar;
29 namespace chromeos {
31 class ScreenManager;
32 class UserImageManager;
33 class UserImageView;
35 class UserImageScreen : public UserImageModel,
36 public ImageDecoder::ImageRequest,
37 public content::NotificationObserver,
38 public UserImageSyncObserver::Observer,
39 public CameraPresenceNotifier::Observer {
40 public:
41 UserImageScreen(BaseScreenDelegate* base_screen_delegate,
42 UserImageView* view);
43 ~UserImageScreen() override;
45 static UserImageScreen* Get(ScreenManager* manager);
47 // BaseScreen implementation:
48 void PrepareToShow() override;
49 void Show() override;
50 void Hide() override;
52 // UserImageScreenActor::Delegate implementation:
53 void OnScreenReady() override;
54 void OnPhotoTaken(const std::string& raw_data) override;
55 void OnImageSelected(const std::string& image_url,
56 const std::string& image_type,
57 bool is_user_selection) override;
58 void OnImageAccepted() override;
59 void OnViewDestroyed(UserImageView* view) override;
61 // content::NotificationObserver implementation:
62 void Observe(int type,
63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) override;
66 // ImageDecoder::ImageRequest implementation:
67 void OnImageDecoded(const SkBitmap& decoded_image) override;
68 void OnDecodeImageFailed() override;
70 // CameraPresenceNotifier::Observer implementation:
71 void OnCameraPresenceCheckDone(bool is_camera_present) override;
73 // UserImageSyncObserver::Observer implementation:
74 void OnInitialSync(bool local_image_updated) override;
76 bool user_selected_image() const { return user_has_selected_image_; }
78 private:
79 // Must be kept synced with |NewUserPriorityPrefsSyncResult| enum from
80 // histograms.xml.
81 enum class SyncResult {
82 SUCCEEDED,
83 TIMED_OUT,
84 // Keeps a number of different sync results. Should be the last in the list.
85 COUNT
88 // Called when whaiting for sync timed out.
89 void OnSyncTimeout();
91 bool IsWaitingForSync() const;
93 // Called when the policy::key::kUserAvatarImage policy changes while the
94 // screen is being shown. If the policy is set, closes the screen because the
95 // user is not allowed to override a policy-set image.
96 void OnUserImagePolicyChanged(const base::Value* previous,
97 const base::Value* current);
99 // Returns current user.
100 const user_manager::User* GetUser();
102 // Returns UserImageManager for the current user.
103 UserImageManager* GetUserImageManager();
105 // Returns UserImageSyncObserver for the current user.
106 UserImageSyncObserver* GetSyncObserver();
108 // Called when it's decided not to skip the screen.
109 void HideCurtain();
111 // Closes the screen.
112 void ExitScreen();
114 // Reports sync duration and result to UMA.
115 void ReportSyncResult(SyncResult timed_out) const;
117 content::NotificationRegistrar notification_registrar_;
119 scoped_ptr<policy::PolicyChangeRegistrar> policy_registrar_;
121 UserImageView* view_;
123 // Last user photo, if taken.
124 gfx::ImageSkia user_photo_;
126 // If |true|, decoded photo should be immediately accepted (i.e., both
127 // HandleTakePhoto and HandleImageAccepted have already been called but we're
128 // still waiting for photo image decoding to finish.
129 bool accept_photo_after_decoding_;
131 // Index of the selected user image.
132 int selected_image_;
134 // Timer used for waiting for user image sync.
135 scoped_ptr<base::Timer> sync_timer_;
137 // If screen ready to be shown.
138 bool is_screen_ready_;
140 // True if user has explicitly selected some image.
141 bool user_has_selected_image_;
143 // The time when we started wait for user image sync.
144 base::Time sync_waiting_start_time_;
146 DISALLOW_COPY_AND_ASSIGN(UserImageScreen);
149 } // namespace chromeos
151 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_