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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 SendOldImage( | 247 SendOldImage( |
248 default_user_image::GetDefaultImageUrl(previous_image_index_)); | 248 default_user_image::GetDefaultImageUrl(previous_image_index_)); |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 void ChangePictureHandler::SendProfileImage(const gfx::ImageSkia& image, | 254 void ChangePictureHandler::SendProfileImage(const gfx::ImageSkia& image, |
255 bool should_select) { | 255 bool should_select) { |
256 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); | 256 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); |
257 base::FundamentalValue select(should_select); | 257 base::Value select(should_select); |
258 CallJavascriptFunction("cr.webUIListenerCallback", | 258 CallJavascriptFunction("cr.webUIListenerCallback", |
259 base::StringValue("profile-image-changed"), data_url, | 259 base::StringValue("profile-image-changed"), data_url, |
260 select); | 260 select); |
261 } | 261 } |
262 | 262 |
263 void ChangePictureHandler::UpdateProfileImage() { | 263 void ChangePictureHandler::UpdateProfileImage() { |
264 UserImageManager* user_image_manager = | 264 UserImageManager* user_image_manager = |
265 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); | 265 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); |
266 // If we have a downloaded profile image and haven't sent it in | 266 // If we have a downloaded profile image and haven't sent it in |
267 // |SendSelectedImage|, send it now (without selecting). | 267 // |SendSelectedImage|, send it now (without selecting). |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ->SaveUserImage(user_manager::UserImage::CreateAndEncode(photo)); | 365 ->SaveUserImage(user_manager::UserImage::CreateAndEncode(photo)); |
366 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 366 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
367 default_user_image::kHistogramImageFromCamera, | 367 default_user_image::kHistogramImageFromCamera, |
368 default_user_image::kHistogramImagesCount); | 368 default_user_image::kHistogramImagesCount); |
369 VLOG(1) << "Selected camera photo"; | 369 VLOG(1) << "Selected camera photo"; |
370 } | 370 } |
371 | 371 |
372 void ChangePictureHandler::SetCameraPresent(bool present) { | 372 void ChangePictureHandler::SetCameraPresent(bool present) { |
373 CallJavascriptFunction("cr.webUIListenerCallback", | 373 CallJavascriptFunction("cr.webUIListenerCallback", |
374 base::StringValue("camera-presence-changed"), | 374 base::StringValue("camera-presence-changed"), |
375 base::FundamentalValue(present)); | 375 base::Value(present)); |
376 } | 376 } |
377 | 377 |
378 void ChangePictureHandler::OnCameraPresenceCheckDone(bool is_camera_present) { | 378 void ChangePictureHandler::OnCameraPresenceCheckDone(bool is_camera_present) { |
379 SetCameraPresent(is_camera_present); | 379 SetCameraPresent(is_camera_present); |
380 } | 380 } |
381 | 381 |
382 void ChangePictureHandler::Observe( | 382 void ChangePictureHandler::Observe( |
383 int type, | 383 int type, |
384 const content::NotificationSource& source, | 384 const content::NotificationSource& source, |
385 const content::NotificationDetails& details) { | 385 const content::NotificationDetails& details) { |
(...skipping 28 matching lines...) Expand all Loading... |
414 Profile* profile = Profile::FromWebUI(web_ui()); | 414 Profile* profile = Profile::FromWebUI(web_ui()); |
415 const user_manager::User* user = | 415 const user_manager::User* user = |
416 ProfileHelper::Get()->GetUserByProfile(profile); | 416 ProfileHelper::Get()->GetUserByProfile(profile); |
417 if (!user) | 417 if (!user) |
418 return user_manager::UserManager::Get()->GetActiveUser(); | 418 return user_manager::UserManager::Get()->GetActiveUser(); |
419 return user; | 419 return user; |
420 } | 420 } |
421 | 421 |
422 } // namespace settings | 422 } // namespace settings |
423 } // namespace chromeos | 423 } // namespace chromeos |
OLD | NEW |