OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "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" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 UserManager::User::kExternalImageIndex); | 297 UserManager::User::kExternalImageIndex); |
298 user_manager->SaveUserImage( | 298 user_manager->SaveUserImage( |
299 user.email(), photo, UserManager::User::kExternalImageIndex); | 299 user.email(), photo, UserManager::User::kExternalImageIndex); |
300 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | 300 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", |
301 kHistogramImageFromCamera, | 301 kHistogramImageFromCamera, |
302 kHistogramImagesCount); | 302 kHistogramImagesCount); |
303 } | 303 } |
304 | 304 |
305 void ChangePictureOptionsHandler::OnDownloadSuccess(const SkBitmap& image) { | 305 void ChangePictureOptionsHandler::OnDownloadSuccess(const SkBitmap& image) { |
306 // Profile image has been downloaded. | 306 // Profile image has been downloaded. |
307 // TODO(ivankr): check if profile image is default image. | 307 VLOG(1) << "Download of profile image on change picture failed."; |
| 308 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.ChangePicture", |
| 309 ProfileImageDownloader::kDownloadSuccess, |
| 310 ProfileImageDownloader::kDownloadResultsCount); |
308 | 311 |
309 std::string profile_image_data_url = web_ui_util::GetImageDataUrl(image); | 312 std::string profile_image_data_url = web_ui_util::GetImageDataUrl(image); |
310 if (profile_image_data_url != profile_image_data_url_) { | 313 if (profile_image_data_url != profile_image_data_url_) { |
| 314 VLOG(1) << "Updating profile image for the user"; |
| 315 if (profile_image_data_url_ != chrome::kAboutBlankURL) { |
| 316 UMA_HISTOGRAM_ENUMERATION( |
| 317 "UserImageDownloadResult.ChangePicture", |
| 318 ProfileImageDownloader::kDownloadSuccessChanged, |
| 319 ProfileImageDownloader::kDownloadResultsCount); |
| 320 } |
| 321 |
311 // Differs from the current profile image. | 322 // Differs from the current profile image. |
312 profile_image_ = image; | 323 profile_image_ = image; |
313 profile_image_data_url_ = profile_image_data_url; | 324 profile_image_data_url_ = profile_image_data_url; |
314 | 325 |
315 base::StringValue image_data_url(profile_image_data_url); | 326 base::StringValue image_data_url(profile_image_data_url); |
316 base::FundamentalValue select(false); | 327 base::FundamentalValue select(false); |
317 web_ui_->CallJavascriptFunction("ChangePictureOptions.setProfileImage", | 328 web_ui_->CallJavascriptFunction("ChangePictureOptions.setProfileImage", |
318 image_data_url, select); | 329 image_data_url, select); |
319 } | 330 } |
320 } | 331 } |
321 | 332 |
| 333 void ChangePictureOptionsHandler::OnDownloadFailure() { |
| 334 VLOG(1) << "Download of profile image on change picture failed."; |
| 335 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.ChangePicture", |
| 336 ProfileImageDownloader::kDownloadFailure, |
| 337 ProfileImageDownloader::kDownloadResultsCount); |
| 338 } |
| 339 |
| 340 void ChangePictureOptionsHandler::OnDownloadDefaultImage() { |
| 341 VLOG(1) << "User still has the default profile image."; |
| 342 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.ChangePicture", |
| 343 ProfileImageDownloader::kDownloadDefault, |
| 344 ProfileImageDownloader::kDownloadResultsCount); |
| 345 } |
| 346 |
322 void ChangePictureOptionsHandler::CheckCameraPresence() { | 347 void ChangePictureOptionsHandler::CheckCameraPresence() { |
323 CameraDetector::StartPresenceCheck( | 348 CameraDetector::StartPresenceCheck( |
324 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, | 349 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, |
325 weak_factory_.GetWeakPtr())); | 350 weak_factory_.GetWeakPtr())); |
326 } | 351 } |
327 | 352 |
328 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { | 353 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { |
329 base::FundamentalValue present_value(present); | 354 base::FundamentalValue present_value(present); |
330 web_ui_->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", | 355 web_ui_->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", |
331 present_value); | 356 present_value); |
(...skipping 27 matching lines...) Expand all Loading... |
359 | 384 |
360 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { | 385 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { |
361 Browser* browser = | 386 Browser* browser = |
362 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui_)); | 387 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui_)); |
363 if (!browser) | 388 if (!browser) |
364 return NULL; | 389 return NULL; |
365 return browser->window()->GetNativeHandle(); | 390 return browser->window()->GetNativeHandle(); |
366 } | 391 } |
367 | 392 |
368 } // namespace chromeos | 393 } // namespace chromeos |
OLD | NEW |