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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 SendOldImage( | 295 SendOldImage( |
296 default_user_image::GetDefaultImageUrl(previous_image_index_)); | 296 default_user_image::GetDefaultImageUrl(previous_image_index_)); |
297 } | 297 } |
298 } | 298 } |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
302 void ChangePictureOptionsHandler::SendProfileImage(const gfx::ImageSkia& image, | 302 void ChangePictureOptionsHandler::SendProfileImage(const gfx::ImageSkia& image, |
303 bool should_select) { | 303 bool should_select) { |
304 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); | 304 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); |
305 base::FundamentalValue select(should_select); | 305 base::Value select(should_select); |
306 web_ui()->CallJavascriptFunctionUnsafe("ChangePictureOptions.setProfileImage", | 306 web_ui()->CallJavascriptFunctionUnsafe("ChangePictureOptions.setProfileImage", |
307 data_url, select); | 307 data_url, select); |
308 } | 308 } |
309 | 309 |
310 void ChangePictureOptionsHandler::UpdateProfileImage() { | 310 void ChangePictureOptionsHandler::UpdateProfileImage() { |
311 UserImageManager* user_image_manager = | 311 UserImageManager* user_image_manager = |
312 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); | 312 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); |
313 // If we have a downloaded profile image and haven't sent it in | 313 // If we have a downloaded profile image and haven't sent it in |
314 // |SendSelectedImage|, send it now (without selecting). | 314 // |SendSelectedImage|, send it now (without selecting). |
315 if (previous_image_index_ != user_manager::User::USER_IMAGE_PROFILE && | 315 if (previous_image_index_ != user_manager::User::USER_IMAGE_PROFILE && |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 ->GetUserImageManager(GetUser()->GetAccountId()) | 416 ->GetUserImageManager(GetUser()->GetAccountId()) |
417 ->SaveUserImage(user_manager::UserImage::CreateAndEncode( | 417 ->SaveUserImage(user_manager::UserImage::CreateAndEncode( |
418 photo, user_manager::UserImage::FORMAT_JPEG)); | 418 photo, user_manager::UserImage::FORMAT_JPEG)); |
419 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 419 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
420 default_user_image::kHistogramImageFromCamera, | 420 default_user_image::kHistogramImageFromCamera, |
421 default_user_image::kHistogramImagesCount); | 421 default_user_image::kHistogramImagesCount); |
422 VLOG(1) << "Selected camera photo"; | 422 VLOG(1) << "Selected camera photo"; |
423 } | 423 } |
424 | 424 |
425 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { | 425 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { |
426 base::FundamentalValue present_value(present); | 426 base::Value present_value(present); |
427 | 427 |
428 web_ui()->CallJavascriptFunctionUnsafe( | 428 web_ui()->CallJavascriptFunctionUnsafe( |
429 "ChangePictureOptions.setCameraPresent", present_value); | 429 "ChangePictureOptions.setCameraPresent", present_value); |
430 } | 430 } |
431 | 431 |
432 void ChangePictureOptionsHandler::OnCameraPresenceCheckDone( | 432 void ChangePictureOptionsHandler::OnCameraPresenceCheckDone( |
433 bool is_camera_present) { | 433 bool is_camera_present) { |
434 SetCameraPresent(is_camera_present); | 434 SetCameraPresent(is_camera_present); |
435 } | 435 } |
436 | 436 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 Profile* profile = Profile::FromWebUI(web_ui()); | 469 Profile* profile = Profile::FromWebUI(web_ui()); |
470 const user_manager::User* user = | 470 const user_manager::User* user = |
471 ProfileHelper::Get()->GetUserByProfile(profile); | 471 ProfileHelper::Get()->GetUserByProfile(profile); |
472 if (!user) | 472 if (!user) |
473 return user_manager::UserManager::Get()->GetActiveUser(); | 473 return user_manager::UserManager::Get()->GetActiveUser(); |
474 return user; | 474 return user; |
475 } | 475 } |
476 | 476 |
477 } // namespace options | 477 } // namespace options |
478 } // namespace chromeos | 478 } // namespace chromeos |
OLD | NEW |