| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/options/chromeos/change_picture_options_handle
r.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/change_picture_options_handle
r.h" |
| 6 | 6 |
| 7 #include "ash/audio/sounds.h" | 7 #include "ash/audio/sounds.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/chromeos/camera_presence_notifier.h" | 17 #include "chrome/browser/chromeos/camera_presence_notifier.h" |
| 18 #include "chrome/browser/chromeos/login/users/avatar/default_user_images.h" | 18 #include "chrome/browser/chromeos/login/users/avatar/default_user_images.h" |
| 19 #include "chrome/browser/chromeos/login/users/avatar/user_image.h" | |
| 20 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" | 19 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" |
| 21 #include "chrome/browser/chromeos/login/users/user_manager.h" | 20 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 23 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 25 #include "chrome/browser/ui/chrome_select_file_policy.h" | 24 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 26 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 29 #include "chromeos/audio/chromeos_sounds.h" | 28 #include "chromeos/audio/chromeos_sounds.h" |
| 29 #include "components/user_manager/avatar/user_image.h" |
| 30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
| 33 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
| 34 #include "grit/browser_resources.h" | 34 #include "grit/browser_resources.h" |
| 35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 36 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
| 37 #include "net/base/data_url.h" | 37 #include "net/base/data_url.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 UserImageManager* user_image_manager = | 339 UserImageManager* user_image_manager = |
| 340 UserManager::Get()->GetUserImageManager(GetUser()->email()); | 340 UserManager::Get()->GetUserImageManager(GetUser()->email()); |
| 341 int image_index = User::kInvalidImageIndex; | 341 int image_index = User::kInvalidImageIndex; |
| 342 bool waiting_for_camera_photo = false; | 342 bool waiting_for_camera_photo = false; |
| 343 | 343 |
| 344 if (image_type == "old") { | 344 if (image_type == "old") { |
| 345 // Previous image (from camera or manually uploaded) re-selected. | 345 // Previous image (from camera or manually uploaded) re-selected. |
| 346 DCHECK(!previous_image_.isNull()); | 346 DCHECK(!previous_image_.isNull()); |
| 347 user_image_manager->SaveUserImage( | 347 user_image_manager->SaveUserImage( |
| 348 UserImage::CreateAndEncode(previous_image_)); | 348 user_manager::UserImage::CreateAndEncode(previous_image_)); |
| 349 | 349 |
| 350 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 350 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
| 351 kHistogramImageOld, | 351 kHistogramImageOld, |
| 352 kHistogramImagesCount); | 352 kHistogramImagesCount); |
| 353 VLOG(1) << "Selected old user image"; | 353 VLOG(1) << "Selected old user image"; |
| 354 } else if (image_type == "default" && | 354 } else if (image_type == "default" && |
| 355 IsDefaultImageUrl(image_url, &image_index)) { | 355 IsDefaultImageUrl(image_url, &image_index)) { |
| 356 // One of the default user images. | 356 // One of the default user images. |
| 357 user_image_manager->SaveUserDefaultImageIndex(image_index); | 357 user_image_manager->SaveUserDefaultImageIndex(image_index); |
| 358 | 358 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 user_manager->GetUserImageManager(GetUser()->email())-> | 400 user_manager->GetUserImageManager(GetUser()->email())-> |
| 401 SaveUserImageFromFile(path); | 401 SaveUserImageFromFile(path); |
| 402 UMA_HISTOGRAM_ENUMERATION( | 402 UMA_HISTOGRAM_ENUMERATION( |
| 403 "UserImage.ChangeChoice", kHistogramImageFromFile, kHistogramImagesCount); | 403 "UserImage.ChangeChoice", kHistogramImageFromFile, kHistogramImagesCount); |
| 404 VLOG(1) << "Selected image from file"; | 404 VLOG(1) << "Selected image from file"; |
| 405 } | 405 } |
| 406 | 406 |
| 407 void ChangePictureOptionsHandler::SetImageFromCamera( | 407 void ChangePictureOptionsHandler::SetImageFromCamera( |
| 408 const gfx::ImageSkia& photo) { | 408 const gfx::ImageSkia& photo) { |
| 409 UserManager* user_manager = UserManager::Get(); | 409 UserManager* user_manager = UserManager::Get(); |
| 410 user_manager->GetUserImageManager(GetUser()->email())->SaveUserImage( | 410 user_manager->GetUserImageManager(GetUser()->email()) |
| 411 UserImage::CreateAndEncode(photo)); | 411 ->SaveUserImage(user_manager::UserImage::CreateAndEncode(photo)); |
| 412 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 412 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
| 413 kHistogramImageFromCamera, | 413 kHistogramImageFromCamera, |
| 414 kHistogramImagesCount); | 414 kHistogramImagesCount); |
| 415 VLOG(1) << "Selected camera photo"; | 415 VLOG(1) << "Selected camera photo"; |
| 416 } | 416 } |
| 417 | 417 |
| 418 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { | 418 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { |
| 419 base::FundamentalValue present_value(present); | 419 base::FundamentalValue present_value(present); |
| 420 | 420 |
| 421 web_ui()->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", | 421 web_ui()->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 User* ChangePictureOptionsHandler::GetUser() const { | 466 User* ChangePictureOptionsHandler::GetUser() const { |
| 467 Profile* profile = Profile::FromWebUI(web_ui()); | 467 Profile* profile = Profile::FromWebUI(web_ui()); |
| 468 User* user = ProfileHelper::Get()->GetUserByProfile(profile); | 468 User* user = ProfileHelper::Get()->GetUserByProfile(profile); |
| 469 if (!user) | 469 if (!user) |
| 470 return UserManager::Get()->GetActiveUser(); | 470 return UserManager::Get()->GetActiveUser(); |
| 471 return user; | 471 return user; |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace options | 474 } // namespace options |
| 475 } // namespace chromeos | 475 } // namespace chromeos |
| OLD | NEW |