| 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/ui/webui/options2/chromeos/change_picture_options_handl
er2.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/change_picture_options_handl
er2.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/chromeos/login/camera_detector.h" | 14 #include "chrome/browser/chromeos/login/camera_detector.h" |
| 15 #include "chrome/browser/chromeos/login/default_user_images.h" | 15 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 16 #include "chrome/browser/chromeos/login/user_image.h" | |
| 17 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
| 18 #include "chrome/browser/chromeos/options/take_photo_dialog.h" | 17 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/webui/web_ui_util.h" | 21 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 26 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 const User& user = user_manager->GetLoggedInUser(); | 250 const User& user = user_manager->GetLoggedInUser(); |
| 252 int image_index = User::kInvalidImageIndex; | 251 int image_index = User::kInvalidImageIndex; |
| 253 | 252 |
| 254 if (StartsWithASCII(image_url, chrome::kChromeUIUserImageURL, false)) { | 253 if (StartsWithASCII(image_url, chrome::kChromeUIUserImageURL, false)) { |
| 255 // Image from file/camera uses kChromeUIUserImageURL as URL while | 254 // Image from file/camera uses kChromeUIUserImageURL as URL while |
| 256 // current profile image always has a full data URL. | 255 // current profile image always has a full data URL. |
| 257 // This way transition from (current profile image) to | 256 // This way transition from (current profile image) to |
| 258 // (profile image, current image from file) is easier. | 257 // (profile image, current image from file) is easier. |
| 259 | 258 |
| 260 DCHECK(!previous_image_.empty()); | 259 DCHECK(!previous_image_.empty()); |
| 261 user_manager->SaveUserImage(user.email(), | 260 user_manager->SaveUserImage(user.email(), previous_image_); |
| 262 chromeos::UserImage(previous_image_)); | |
| 263 | 261 |
| 264 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 262 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
| 265 kHistogramImageOld, | 263 kHistogramImageOld, |
| 266 kHistogramImagesCount); | 264 kHistogramImagesCount); |
| 267 VLOG(1) << "Selected old user image"; | 265 VLOG(1) << "Selected old user image"; |
| 268 } else if (IsDefaultImageUrl(image_url, &image_index)) { | 266 } else if (IsDefaultImageUrl(image_url, &image_index)) { |
| 269 // One of the default user images. | 267 // One of the default user images. |
| 270 user_manager->SaveUserDefaultImageIndex(user.email(), image_index); | 268 user_manager->SaveUserDefaultImageIndex(user.email(), image_index); |
| 271 | 269 |
| 272 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 270 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
| (...skipping 24 matching lines...) Expand all Loading... |
| 297 UserManager* user_manager = UserManager::Get(); | 295 UserManager* user_manager = UserManager::Get(); |
| 298 user_manager->SaveUserImageFromFile(user_manager->GetLoggedInUser().email(), | 296 user_manager->SaveUserImageFromFile(user_manager->GetLoggedInUser().email(), |
| 299 path); | 297 path); |
| 300 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 298 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
| 301 kHistogramImageFromFile, | 299 kHistogramImageFromFile, |
| 302 kHistogramImagesCount); | 300 kHistogramImagesCount); |
| 303 } | 301 } |
| 304 | 302 |
| 305 void ChangePictureOptionsHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) { | 303 void ChangePictureOptionsHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) { |
| 306 UserManager* user_manager = UserManager::Get(); | 304 UserManager* user_manager = UserManager::Get(); |
| 307 user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), | 305 user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), photo); |
| 308 chromeos::UserImage(photo)); | |
| 309 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 306 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
| 310 kHistogramImageFromCamera, | 307 kHistogramImageFromCamera, |
| 311 kHistogramImagesCount); | 308 kHistogramImagesCount); |
| 312 } | 309 } |
| 313 | 310 |
| 314 void ChangePictureOptionsHandler::CheckCameraPresence() { | 311 void ChangePictureOptionsHandler::CheckCameraPresence() { |
| 315 CameraDetector::StartPresenceCheck( | 312 CameraDetector::StartPresenceCheck( |
| 316 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, | 313 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, |
| 317 weak_factory_.GetWeakPtr())); | 314 weak_factory_.GetWeakPtr())); |
| 318 } | 315 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 343 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { | 340 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { |
| 344 Browser* browser = | 341 Browser* browser = |
| 345 browser::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); | 342 browser::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); |
| 346 if (!browser) | 343 if (!browser) |
| 347 return NULL; | 344 return NULL; |
| 348 return browser->window()->GetNativeHandle(); | 345 return browser->window()->GetNativeHandle(); |
| 349 } | 346 } |
| 350 | 347 |
| 351 } // namespace options2 | 348 } // namespace options2 |
| 352 } // namespace chromeos | 349 } // namespace chromeos |
| OLD | NEW |