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/chromeos/login/user_manager.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 void UserManager::OnImageLoaded(const std::string& username, | 674 void UserManager::OnImageLoaded(const std::string& username, |
675 const SkBitmap& image, | 675 const SkBitmap& image, |
676 int image_index, | 676 int image_index, |
677 bool should_save_image) { | 677 bool should_save_image) { |
678 DVLOG(1) << "Loaded image for " << username; | 678 DVLOG(1) << "Loaded image for " << username; |
679 SetUserImage(username, image, image_index, should_save_image); | 679 SetUserImage(username, image, image_index, should_save_image); |
680 } | 680 } |
681 | 681 |
682 void UserManager::OnDownloadSuccess(const SkBitmap& image) { | 682 void UserManager::OnDownloadSuccess(const SkBitmap& image) { |
683 VLOG(1) << "Downloaded profile image for logged-in user."; | 683 VLOG(1) << "Downloaded profile image for logged-in user."; |
| 684 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.LoggedIn", |
| 685 ProfileImageDownloader::kDownloadSuccess, |
| 686 ProfileImageDownloader::kDownloadResultsCount); |
684 | 687 |
685 std::string current_image_data_url = | 688 std::string current_image_data_url = |
686 web_ui_util::GetImageDataUrl(logged_in_user_.image()); | 689 web_ui_util::GetImageDataUrl(logged_in_user_.image()); |
687 std::string new_image_data_url = | 690 std::string new_image_data_url = |
688 web_ui_util::GetImageDataUrl(image); | 691 web_ui_util::GetImageDataUrl(image); |
689 if (current_image_data_url != new_image_data_url) { | 692 if (current_image_data_url != new_image_data_url) { |
690 VLOG(1) << "Updating profile image for logged-in user"; | 693 VLOG(1) << "Updating profile image for logged-in user"; |
| 694 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.LoggedIn", |
| 695 ProfileImageDownloader::kDownloadSuccessChanged, |
| 696 ProfileImageDownloader::kDownloadResultsCount); |
| 697 |
691 SetLoggedInUserImage(image, User::kProfileImageIndex); | 698 SetLoggedInUserImage(image, User::kProfileImageIndex); |
692 SaveUserImage(logged_in_user_.email(), image, User::kProfileImageIndex); | 699 SaveUserImage(logged_in_user_.email(), image, User::kProfileImageIndex); |
693 content::NotificationService::current()->Notify( | 700 content::NotificationService::current()->Notify( |
694 chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED, | 701 chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED, |
695 content::Source<UserManager>(this), | 702 content::Source<UserManager>(this), |
696 content::Details<const UserManager::User>(&logged_in_user())); | 703 content::Details<const UserManager::User>(&logged_in_user())); |
697 } | 704 } |
698 } | 705 } |
699 | 706 |
| 707 void UserManager::OnDownloadFailure() { |
| 708 VLOG(1) << "Download of profile image for logged-in user failed."; |
| 709 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.LoggedIn", |
| 710 ProfileImageDownloader::kDownloadFailure, |
| 711 ProfileImageDownloader::kDownloadResultsCount); |
| 712 } |
| 713 |
| 714 void UserManager::OnDownloadDefaultImage() { |
| 715 VLOG(1) << "Logged-in user still has the default profile image."; |
| 716 UMA_HISTOGRAM_ENUMERATION("UserImageDownloadResult.LoggedIn", |
| 717 ProfileImageDownloader::kDownloadDefault, |
| 718 ProfileImageDownloader::kDownloadResultsCount); |
| 719 } |
| 720 |
700 bool UserManager::IsLoggedInAsGuest() const { | 721 bool UserManager::IsLoggedInAsGuest() const { |
701 return logged_in_user().email() == kGuestUser; | 722 return logged_in_user().email() == kGuestUser; |
702 } | 723 } |
703 | 724 |
704 // Private constructor and destructor. Do nothing. | 725 // Private constructor and destructor. Do nothing. |
705 UserManager::UserManager() | 726 UserManager::UserManager() |
706 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader(this))), | 727 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader(this))), |
707 offline_login_(false), | 728 offline_login_(false), |
708 current_user_is_owner_(false), | 729 current_user_is_owner_(false), |
709 current_user_is_new_(false), | 730 current_user_is_new_(false), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 observer_list_, | 849 observer_list_, |
829 LocalStateChanged(this)); | 850 LocalStateChanged(this)); |
830 } | 851 } |
831 | 852 |
832 void UserManager::DownloadProfileImage() { | 853 void UserManager::DownloadProfileImage() { |
833 profile_image_downloader_.reset(new ProfileImageDownloader(this)); | 854 profile_image_downloader_.reset(new ProfileImageDownloader(this)); |
834 profile_image_downloader_->Start(); | 855 profile_image_downloader_->Start(); |
835 } | 856 } |
836 | 857 |
837 } // namespace chromeos | 858 } // namespace chromeos |
OLD | NEW |