OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/settings/chromeos/change_picture_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 SendOldImage( | 241 SendOldImage( |
242 default_user_image::GetDefaultImageUrl(previous_image_index_)); | 242 default_user_image::GetDefaultImageUrl(previous_image_index_)); |
243 } | 243 } |
244 } | 244 } |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 void ChangePictureHandler::SendProfileImage(const gfx::ImageSkia& image, | 248 void ChangePictureHandler::SendProfileImage(const gfx::ImageSkia& image, |
249 bool should_select) { | 249 bool should_select) { |
250 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); | 250 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); |
251 base::FundamentalValue select(should_select); | 251 base::Value select(should_select); |
252 CallJavascriptFunction("cr.webUIListenerCallback", | 252 CallJavascriptFunction("cr.webUIListenerCallback", |
253 base::StringValue("profile-image-changed"), data_url, | 253 base::StringValue("profile-image-changed"), data_url, |
254 select); | 254 select); |
255 } | 255 } |
256 | 256 |
257 void ChangePictureHandler::UpdateProfileImage() { | 257 void ChangePictureHandler::UpdateProfileImage() { |
258 UserImageManager* user_image_manager = | 258 UserImageManager* user_image_manager = |
259 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); | 259 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); |
260 // If we have a downloaded profile image and haven't sent it in | 260 // If we have a downloaded profile image and haven't sent it in |
261 // |SendSelectedImage|, send it now (without selecting). | 261 // |SendSelectedImage|, send it now (without selecting). |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 photo, user_manager::UserImage::FORMAT_JPEG)); | 362 photo, user_manager::UserImage::FORMAT_JPEG)); |
363 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 363 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
364 default_user_image::kHistogramImageFromCamera, | 364 default_user_image::kHistogramImageFromCamera, |
365 default_user_image::kHistogramImagesCount); | 365 default_user_image::kHistogramImagesCount); |
366 VLOG(1) << "Selected camera photo"; | 366 VLOG(1) << "Selected camera photo"; |
367 } | 367 } |
368 | 368 |
369 void ChangePictureHandler::SetCameraPresent(bool present) { | 369 void ChangePictureHandler::SetCameraPresent(bool present) { |
370 CallJavascriptFunction("cr.webUIListenerCallback", | 370 CallJavascriptFunction("cr.webUIListenerCallback", |
371 base::StringValue("camera-presence-changed"), | 371 base::StringValue("camera-presence-changed"), |
372 base::FundamentalValue(present)); | 372 base::Value(present)); |
373 } | 373 } |
374 | 374 |
375 void ChangePictureHandler::OnCameraPresenceCheckDone(bool is_camera_present) { | 375 void ChangePictureHandler::OnCameraPresenceCheckDone(bool is_camera_present) { |
376 SetCameraPresent(is_camera_present); | 376 SetCameraPresent(is_camera_present); |
377 } | 377 } |
378 | 378 |
379 void ChangePictureHandler::OnUserImageChanged(const user_manager::User& user) { | 379 void ChangePictureHandler::OnUserImageChanged(const user_manager::User& user) { |
380 // Not initialized yet. | 380 // Not initialized yet. |
381 if (previous_image_index_ == user_manager::User::USER_IMAGE_INVALID) | 381 if (previous_image_index_ == user_manager::User::USER_IMAGE_INVALID) |
382 return; | 382 return; |
(...skipping 26 matching lines...) Expand all Loading... |
409 Profile* profile = Profile::FromWebUI(web_ui()); | 409 Profile* profile = Profile::FromWebUI(web_ui()); |
410 const user_manager::User* user = | 410 const user_manager::User* user = |
411 ProfileHelper::Get()->GetUserByProfile(profile); | 411 ProfileHelper::Get()->GetUserByProfile(profile); |
412 if (!user) | 412 if (!user) |
413 return user_manager::UserManager::Get()->GetActiveUser(); | 413 return user_manager::UserManager::Get()->GetActiveUser(); |
414 return user; | 414 return user; |
415 } | 415 } |
416 | 416 |
417 } // namespace settings | 417 } // namespace settings |
418 } // namespace chromeos | 418 } // namespace chromeos |
OLD | NEW |