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