| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/user_image_screen.h" | 5 #include "chrome/browser/chromeos/login/user_image_screen.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/browser/chromeos/login/default_user_images.h" | 9 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 10 #include "chrome/browser/chromeos/login/login_utils.h" | 10 #include "chrome/browser/chromeos/login/login_utils.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 user_manager->GetUserDefaultImageIndex(logged_in_user); | 64 user_manager->GetUserDefaultImageIndex(logged_in_user); |
| 65 // The image must have been assigned by UserManager on new user login but | 65 // The image must have been assigned by UserManager on new user login but |
| 66 // under some circumstances (i.e. the data is not written to Local State | 66 // under some circumstances (i.e. the data is not written to Local State |
| 67 // or the file was corrupt) |kExternalImageIndex| could still be returned. | 67 // or the file was corrupt) |kExternalImageIndex| could still be returned. |
| 68 if (selected_image_index == UserManager::User::kInvalidImageIndex) { | 68 if (selected_image_index == UserManager::User::kInvalidImageIndex) { |
| 69 LOG(WARNING) << "Default user image index invalid!"; | 69 LOG(WARNING) << "Default user image index invalid!"; |
| 70 selected_image_index = 0; | 70 selected_image_index = 0; |
| 71 } | 71 } |
| 72 actor_->SelectImage(selected_image_index); | 72 actor_->SelectImage(selected_image_index); |
| 73 | 73 |
| 74 profile_image_downloader_.reset(new ProfileImageDownloader(this)); |
| 75 profile_image_downloader_->Start(); |
| 76 profile_image_load_start_time_ = base::Time::Now(); |
| 77 |
| 74 WizardAccessibilityHelper::GetInstance()->MaybeSpeak( | 78 WizardAccessibilityHelper::GetInstance()->MaybeSpeak( |
| 75 l10n_util::GetStringUTF8(IDS_OPTIONS_CHANGE_PICTURE_DIALOG_TEXT).c_str(), | 79 l10n_util::GetStringUTF8(IDS_OPTIONS_CHANGE_PICTURE_DIALOG_TEXT).c_str(), |
| 76 false, false); | 80 false, false); |
| 77 | |
| 78 profile_image_downloader_.reset(new ProfileImageDownloader(this)); | |
| 79 profile_image_downloader_->Start(); | |
| 80 } | 81 } |
| 81 | 82 |
| 82 void UserImageScreen::Hide() { | 83 void UserImageScreen::Hide() { |
| 83 camera_controller_.Stop(); | 84 camera_controller_.Stop(); |
| 84 if (actor_) | 85 if (actor_) |
| 85 actor_->Hide(); | 86 actor_->Hide(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void UserImageScreen::OnCaptureSuccess() { | 89 void UserImageScreen::OnCaptureSuccess() { |
| 89 if (!actor_) | 90 if (!actor_) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const content::NotificationDetails& details) { | 175 const content::NotificationDetails& details) { |
| 175 DCHECK(type == chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED); | 176 DCHECK(type == chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED); |
| 176 bool is_screen_locked = *content::Details<bool>(details).ptr(); | 177 bool is_screen_locked = *content::Details<bool>(details).ptr(); |
| 177 if (is_screen_locked) | 178 if (is_screen_locked) |
| 178 StopCamera(); | 179 StopCamera(); |
| 179 else if (actor_ && actor_->IsCapturing()) | 180 else if (actor_ && actor_->IsCapturing()) |
| 180 StartCamera(); | 181 StartCamera(); |
| 181 } | 182 } |
| 182 | 183 |
| 183 void UserImageScreen::OnDownloadSuccess(const SkBitmap& image) { | 184 void UserImageScreen::OnDownloadSuccess(const SkBitmap& image) { |
| 185 DCHECK(profile_image_load_start_time_.is_null()); |
| 186 |
| 187 base::TimeDelta delta = base::Time::Now() - profile_image_load_start_time_; |
| 188 VLOG(1) << "Profile image download time: " << delta.InSecondsF(); |
| 189 UMA_HISTOGRAM_TIMES("UserImage.FirstTimeProfileImageDownload", delta); |
| 190 |
| 184 // TODO(avayvod): Check for the default image. | 191 // TODO(avayvod): Check for the default image. |
| 185 if (actor_) | 192 if (actor_) |
| 186 actor_->AddProfileImage(image); | 193 actor_->AddProfileImage(image); |
| 187 } | 194 } |
| 188 | 195 |
| 189 } // namespace chromeos | 196 } // namespace chromeos |
| OLD | NEW |