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/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" |
10 #include "chrome/browser/chromeos/camera_presence_notifier.h" | 11 #include "chrome/browser/chromeos/camera_presence_notifier.h" |
11 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 12 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
12 #include "chrome/browser/chromeos/login/screens/user_image_model.h" | 13 #include "chrome/browser/chromeos/login/screens/user_image_model.h" |
13 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" | 14 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" |
14 #include "chrome/browser/image_decoder.h" | 15 #include "chrome/browser/image_decoder.h" |
15 #include "components/user_manager/user.h" | 16 #include "components/user_manager/user.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 // CameraPresenceNotifier::Observer implementation: | 70 // CameraPresenceNotifier::Observer implementation: |
70 void OnCameraPresenceCheckDone(bool is_camera_present) override; | 71 void OnCameraPresenceCheckDone(bool is_camera_present) override; |
71 | 72 |
72 // UserImageSyncObserver::Observer implementation: | 73 // UserImageSyncObserver::Observer implementation: |
73 void OnInitialSync(bool local_image_updated) override; | 74 void OnInitialSync(bool local_image_updated) override; |
74 | 75 |
75 bool user_selected_image() const { return user_has_selected_image_; } | 76 bool user_selected_image() const { return user_has_selected_image_; } |
76 | 77 |
77 private: | 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 |
| 86 }; |
| 87 |
78 // Called when whaiting for sync timed out. | 88 // Called when whaiting for sync timed out. |
79 void OnSyncTimeout(); | 89 void OnSyncTimeout(); |
80 | 90 |
81 bool IsWaitingForSync() const; | 91 bool IsWaitingForSync() const; |
82 | 92 |
83 // Called when the policy::key::kUserAvatarImage policy changes while the | 93 // Called when the policy::key::kUserAvatarImage policy changes while the |
84 // screen is being shown. If the policy is set, closes the screen because the | 94 // screen is being shown. If the policy is set, closes the screen because the |
85 // user is not allowed to override a policy-set image. | 95 // user is not allowed to override a policy-set image. |
86 void OnUserImagePolicyChanged(const base::Value* previous, | 96 void OnUserImagePolicyChanged(const base::Value* previous, |
87 const base::Value* current); | 97 const base::Value* current); |
88 | 98 |
89 // Returns current user. | 99 // Returns current user. |
90 const user_manager::User* GetUser(); | 100 const user_manager::User* GetUser(); |
91 | 101 |
92 // Returns UserImageManager for the current user. | 102 // Returns UserImageManager for the current user. |
93 UserImageManager* GetUserImageManager(); | 103 UserImageManager* GetUserImageManager(); |
94 | 104 |
95 // Returns UserImageSyncObserver for the current user. | 105 // Returns UserImageSyncObserver for the current user. |
96 UserImageSyncObserver* GetSyncObserver(); | 106 UserImageSyncObserver* GetSyncObserver(); |
97 | 107 |
98 // Called when it's decided not to skip the screen. | 108 // Called when it's decided not to skip the screen. |
99 void HideCurtain(); | 109 void HideCurtain(); |
100 | 110 |
101 // Closes the screen. | 111 // Closes the screen. |
102 void ExitScreen(); | 112 void ExitScreen(); |
103 | 113 |
| 114 // Reports sync duration and result to UMA. |
| 115 void ReportSyncResult(SyncResult timed_out) const; |
| 116 |
104 content::NotificationRegistrar notification_registrar_; | 117 content::NotificationRegistrar notification_registrar_; |
105 | 118 |
106 scoped_ptr<policy::PolicyChangeRegistrar> policy_registrar_; | 119 scoped_ptr<policy::PolicyChangeRegistrar> policy_registrar_; |
107 | 120 |
108 UserImageView* view_; | 121 UserImageView* view_; |
109 | 122 |
110 // Last user photo, if taken. | 123 // Last user photo, if taken. |
111 gfx::ImageSkia user_photo_; | 124 gfx::ImageSkia user_photo_; |
112 | 125 |
113 // If |true|, decoded photo should be immediately accepted (i.e., both | 126 // If |true|, decoded photo should be immediately accepted (i.e., both |
114 // HandleTakePhoto and HandleImageAccepted have already been called but we're | 127 // HandleTakePhoto and HandleImageAccepted have already been called but we're |
115 // still waiting for photo image decoding to finish. | 128 // still waiting for photo image decoding to finish. |
116 bool accept_photo_after_decoding_; | 129 bool accept_photo_after_decoding_; |
117 | 130 |
118 // Index of the selected user image. | 131 // Index of the selected user image. |
119 int selected_image_; | 132 int selected_image_; |
120 | 133 |
121 // Timer used for waiting for user image sync. | 134 // Timer used for waiting for user image sync. |
122 scoped_ptr<base::Timer> sync_timer_; | 135 scoped_ptr<base::Timer> sync_timer_; |
123 | 136 |
124 // If screen ready to be shown. | 137 // If screen ready to be shown. |
125 bool is_screen_ready_; | 138 bool is_screen_ready_; |
126 | 139 |
127 // True if user has explicitly selected some image. | 140 // True if user has explicitly selected some image. |
128 bool user_has_selected_image_; | 141 bool user_has_selected_image_; |
129 | 142 |
| 143 // The time when we started wait for user image sync. |
| 144 base::Time sync_waiting_start_time_; |
| 145 |
130 DISALLOW_COPY_AND_ASSIGN(UserImageScreen); | 146 DISALLOW_COPY_AND_ASSIGN(UserImageScreen); |
131 }; | 147 }; |
132 | 148 |
133 } // namespace chromeos | 149 } // namespace chromeos |
134 | 150 |
135 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ | 151 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_ |
OLD | NEW |