| 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 #include "chrome/browser/chromeos/login/screens/user_image_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/user_image_screen.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 using content::BrowserThread; | 45 using content::BrowserThread; |
| 46 | 46 |
| 47 namespace chromeos { | 47 namespace chromeos { |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 constexpr const char kContextKeyIsCameraPresent[] = "isCameraPresent"; | 51 constexpr const char kContextKeyIsCameraPresent[] = "isCameraPresent"; |
| 52 constexpr const char kContextKeyProfilePictureDataURL[] = | 52 constexpr const char kContextKeyProfilePictureDataURL[] = |
| 53 "profilePictureDataURL"; | 53 "profilePictureDataURL"; |
| 54 constexpr const char kContextKeySelectedImageURL[] = "selectedImageURL"; | 54 constexpr const char kContextKeySelectedImageURL[] = "selectedImageURL"; |
| 55 constexpr const char kContextKeyHasGaiaAccount[] = "hasGaiaAccount"; | |
| 56 | 55 |
| 57 // Time histogram suffix for profile image download. | 56 // Time histogram suffix for profile image download. |
| 58 const char kProfileDownloadReason[] = "OOBE"; | 57 const char kProfileDownloadReason[] = "OOBE"; |
| 59 | 58 |
| 60 // Maximum amount of time to wait for the user image to sync. | 59 // Maximum amount of time to wait for the user image to sync. |
| 61 // The screen is shown iff sync failed or time limit exceeded. | 60 // The screen is shown iff sync failed or time limit exceeded. |
| 62 const int kSyncTimeoutSeconds = 10; | 61 const int kSyncTimeoutSeconds = 10; |
| 63 | 62 |
| 64 } // namespace | 63 } // namespace |
| 65 | 64 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 208 } |
| 210 } | 209 } |
| 211 CameraPresenceNotifier::GetInstance()->AddObserver(this); | 210 CameraPresenceNotifier::GetInstance()->AddObserver(this); |
| 212 view_->Show(); | 211 view_->Show(); |
| 213 | 212 |
| 214 selected_image_ = GetUser()->image_index(); | 213 selected_image_ = GetUser()->image_index(); |
| 215 GetContextEditor().SetString( | 214 GetContextEditor().SetString( |
| 216 kContextKeySelectedImageURL, | 215 kContextKeySelectedImageURL, |
| 217 default_user_image::GetDefaultImageUrl(selected_image_)); | 216 default_user_image::GetDefaultImageUrl(selected_image_)); |
| 218 | 217 |
| 219 const user_manager::User* user = GetUser(); | 218 // Start fetching the profile image. |
| 220 // Fetch profile image for GAIA accounts. | 219 GetUserImageManager()->DownloadProfileImage(kProfileDownloadReason); |
| 221 if (user && user->HasGaiaAccount()) { | |
| 222 GetContextEditor().SetBoolean(kContextKeyHasGaiaAccount, true); | |
| 223 GetUserImageManager()->DownloadProfileImage(kProfileDownloadReason); | |
| 224 } else { | |
| 225 GetContextEditor().SetBoolean(kContextKeyHasGaiaAccount, false); | |
| 226 } | |
| 227 } | 220 } |
| 228 | 221 |
| 229 void UserImageScreen::Hide() { | 222 void UserImageScreen::Hide() { |
| 230 CameraPresenceNotifier::GetInstance()->RemoveObserver(this); | 223 CameraPresenceNotifier::GetInstance()->RemoveObserver(this); |
| 231 user_manager::UserManager::Get()->RemoveObserver(this); | 224 user_manager::UserManager::Get()->RemoveObserver(this); |
| 232 policy_registrar_.reset(); | 225 policy_registrar_.reset(); |
| 233 sync_timer_.reset(); | 226 sync_timer_.reset(); |
| 234 if (UserImageSyncObserver* sync_observer = GetSyncObserver()) | 227 if (UserImageSyncObserver* sync_observer = GetSyncObserver()) |
| 235 sync_observer->RemoveObserver(this); | 228 sync_observer->RemoveObserver(this); |
| 236 if (view_) | 229 if (view_) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 332 |
| 340 void UserImageScreen::ReportSyncResult(SyncResult timed_out) const { | 333 void UserImageScreen::ReportSyncResult(SyncResult timed_out) const { |
| 341 base::TimeDelta duration = base::Time::Now() - sync_waiting_start_time_; | 334 base::TimeDelta duration = base::Time::Now() - sync_waiting_start_time_; |
| 342 UMA_HISTOGRAM_TIMES("Login.NewUserPriorityPrefsSyncTime", duration); | 335 UMA_HISTOGRAM_TIMES("Login.NewUserPriorityPrefsSyncTime", duration); |
| 343 UMA_HISTOGRAM_ENUMERATION("Login.NewUserPriorityPrefsSyncResult", | 336 UMA_HISTOGRAM_ENUMERATION("Login.NewUserPriorityPrefsSyncResult", |
| 344 static_cast<int>(timed_out), | 337 static_cast<int>(timed_out), |
| 345 static_cast<int>(SyncResult::COUNT)); | 338 static_cast<int>(SyncResult::COUNT)); |
| 346 } | 339 } |
| 347 | 340 |
| 348 } // namespace chromeos | 341 } // namespace chromeos |
| OLD | NEW |