Chromium Code Reviews| 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"; | |
|
Ivan Korotkov
2011/10/27 13:58:15
As discussed offline, this will report a change ev
| |
| 315 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.ChangePicture", | |
| 316 ProfileImageDownloader::kDownloadSuccessChanged, | |
| 317 ProfileImageDownloader::kDownloadResultsCount); | |
| 318 | |
| 311 // Differs from the current profile image. | 319 // Differs from the current profile image. |
| 312 profile_image_ = image; | 320 profile_image_ = image; |
| 313 profile_image_data_url_ = profile_image_data_url; | 321 profile_image_data_url_ = profile_image_data_url; |
| 314 | 322 |
| 315 base::StringValue image_data_url(profile_image_data_url); | 323 base::StringValue image_data_url(profile_image_data_url); |
| 316 base::FundamentalValue select(false); | 324 base::FundamentalValue select(false); |
| 317 web_ui_->CallJavascriptFunction("ChangePictureOptions.setProfileImage", | 325 web_ui_->CallJavascriptFunction("ChangePictureOptions.setProfileImage", |
| 318 image_data_url, select); | 326 image_data_url, select); |
| 319 } | 327 } |
| 320 } | 328 } |
| 321 | 329 |
| 330 void ChangePictureOptionsHandler::OnDownloadFailure() { | |
| 331 VLOG(1) << "Download of profile image on change picture failed."; | |
| 332 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.ChangePicture", | |
| 333 ProfileImageDownloader::kDownloadFailure, | |
| 334 ProfileImageDownloader::kDownloadResultsCount); | |
| 335 } | |
| 336 | |
| 337 void ChangePictureOptionsHandler::OnDownloadDefaultImage() { | |
| 338 VLOG(1) << "User still has the default profile image."; | |
| 339 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.ChangePicture", | |
| 340 ProfileImageDownloader::kDownloadDefault, | |
| 341 ProfileImageDownloader::kDownloadResultsCount); | |
| 342 } | |
| 343 | |
| 322 void ChangePictureOptionsHandler::CheckCameraPresence() { | 344 void ChangePictureOptionsHandler::CheckCameraPresence() { |
| 323 CameraDetector::StartPresenceCheck( | 345 CameraDetector::StartPresenceCheck( |
| 324 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, | 346 base::Bind(&ChangePictureOptionsHandler::OnCameraPresenceCheckDone, |
| 325 weak_factory_.GetWeakPtr())); | 347 weak_factory_.GetWeakPtr())); |
| 326 } | 348 } |
| 327 | 349 |
| 328 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { | 350 void ChangePictureOptionsHandler::SetCameraPresent(bool present) { |
| 329 base::FundamentalValue present_value(present); | 351 base::FundamentalValue present_value(present); |
| 330 web_ui_->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", | 352 web_ui_->CallJavascriptFunction("ChangePictureOptions.setCameraPresent", |
| 331 present_value); | 353 present_value); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 359 | 381 |
| 360 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { | 382 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { |
| 361 Browser* browser = | 383 Browser* browser = |
| 362 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui_)); | 384 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui_)); |
| 363 if (!browser) | 385 if (!browser) |
| 364 return NULL; | 386 return NULL; |
| 365 return browser->window()->GetNativeHandle(); | 387 return browser->window()->GetNativeHandle(); |
| 366 } | 388 } |
| 367 | 389 |
| 368 } // namespace chromeos | 390 } // namespace chromeos |
| OLD | NEW |