Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc

Issue 10454044: Added support for animated/nonanimated user image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Small fixes to comments. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 const User& user = user_manager->GetLoggedInUser(); 251 const User& user = user_manager->GetLoggedInUser();
251 int image_index = User::kInvalidImageIndex; 252 int image_index = User::kInvalidImageIndex;
252 253
253 if (StartsWithASCII(image_url, chrome::kChromeUIUserImageURL, false)) { 254 if (StartsWithASCII(image_url, chrome::kChromeUIUserImageURL, false)) {
254 // Image from file/camera uses kChromeUIUserImageURL as URL while 255 // Image from file/camera uses kChromeUIUserImageURL as URL while
255 // current profile image always has a full data URL. 256 // current profile image always has a full data URL.
256 // This way transition from (current profile image) to 257 // This way transition from (current profile image) to
257 // (profile image, current image from file) is easier. 258 // (profile image, current image from file) is easier.
258 259
259 DCHECK(!previous_image_.empty()); 260 DCHECK(!previous_image_.empty());
260 user_manager->SaveUserImage(user.email(), previous_image_); 261 user_manager->SaveUserImage(user.email(),
262 chromeos::UserImage(previous_image_));
261 263
262 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", 264 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice",
263 kHistogramImageOld, 265 kHistogramImageOld,
264 kHistogramImagesCount); 266 kHistogramImagesCount);
265 VLOG(1) << "Selected old user image"; 267 VLOG(1) << "Selected old user image";
266 } else if (IsDefaultImageUrl(image_url, &image_index)) { 268 } else if (IsDefaultImageUrl(image_url, &image_index)) {
267 // One of the default user images. 269 // One of the default user images.
268 user_manager->SaveUserDefaultImageIndex(user.email(), image_index); 270 user_manager->SaveUserDefaultImageIndex(user.email(), image_index);
269 271
270 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", 272 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice",
(...skipping 24 matching lines...) Expand all
295 UserManager* user_manager = UserManager::Get(); 297 UserManager* user_manager = UserManager::Get();
296 user_manager->SaveUserImageFromFile(user_manager->GetLoggedInUser().email(), 298 user_manager->SaveUserImageFromFile(user_manager->GetLoggedInUser().email(),
297 path); 299 path);
298 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", 300 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice",
299 kHistogramImageFromFile, 301 kHistogramImageFromFile,
300 kHistogramImagesCount); 302 kHistogramImagesCount);
301 } 303 }
302 304
303 void ChangePictureOptionsHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) { 305 void ChangePictureOptionsHandler::OnPhotoAccepted(const gfx::ImageSkia& photo) {
304 UserManager* user_manager = UserManager::Get(); 306 UserManager* user_manager = UserManager::Get();
305 user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(), photo); 307 user_manager->SaveUserImage(user_manager->GetLoggedInUser().email(),
308 chromeos::UserImage(photo));
306 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", 309 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice",
307 kHistogramImageFromCamera, 310 kHistogramImageFromCamera,
308 kHistogramImagesCount); 311 kHistogramImagesCount);
309 } 312 }
310 313
311 void ChangePictureOptionsHandler::CheckCameraPresence() { 314 void ChangePictureOptionsHandler::CheckCameraPresence() {
312 CameraDetector::StartPresenceCheck( 315 CameraDetector::StartPresenceCheck(
313 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, 316 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone,
314 weak_factory_.GetWeakPtr())); 317 weak_factory_.GetWeakPtr()));
315 } 318 }
(...skipping 24 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698