Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/chromeos/login/user_image_manager_impl.cc

Issue 23095006: If user profile doesn't contain language setting, default to his Google account settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment on "list of preferred languages". Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_image_manager_impl.h" 5 #include "chrome/browser/chromeos/login/user_image_manager_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 void UserImageManagerImpl::OnProfileDownloadSuccess( 632 void UserImageManagerImpl::OnProfileDownloadSuccess(
633 ProfileDownloader* downloader) { 633 ProfileDownloader* downloader) {
634 // Make sure that |ProfileDownloader| gets deleted after return. 634 // Make sure that |ProfileDownloader| gets deleted after return.
635 scoped_ptr<ProfileDownloader> profile_image_downloader( 635 scoped_ptr<ProfileDownloader> profile_image_downloader(
636 profile_image_downloader_.release()); 636 profile_image_downloader_.release());
637 DCHECK_EQ(downloader, profile_image_downloader.get()); 637 DCHECK_EQ(downloader, profile_image_downloader.get());
638 638
639 UserManager* user_manager = UserManager::Get(); 639 UserManager* user_manager = UserManager::Get();
640 const User* user = user_manager->GetLoggedInUser(); 640 const User* user = user_manager->GetLoggedInUser();
641 641
642 if (!downloader->GetProfileFullName().empty()) { 642 user_manager->UpdateUserAccountData(user->email(),
643 user_manager->SaveUserDisplayName( 643 downloader->GetProfileFullName(),
644 user->email(), downloader->GetProfileFullName()); 644 downloader->GetProfileLocale());
645 }
646 645
647 bool requested_image = downloading_profile_image_; 646 bool requested_image = downloading_profile_image_;
648 downloading_profile_image_ = false; 647 downloading_profile_image_ = false;
649 if (!requested_image) 648 if (!requested_image)
650 return; 649 return;
651 650
652 ProfileDownloadResult result = kDownloadFailure; 651 ProfileDownloadResult result = kDownloadFailure;
653 switch (downloader->GetProfilePictureStatus()) { 652 switch (downloader->GetProfilePictureStatus()) {
654 case ProfileDownloader::PICTURE_SUCCESS: 653 case ProfileDownloader::PICTURE_SUCCESS:
655 result = kDownloadSuccess; 654 result = kDownloadSuccess;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 profile_image_downloader_.reset(); 715 profile_image_downloader_.reset();
717 716
718 UMA_HISTOGRAM_ENUMERATION("UserImage.ProfileDownloadResult", 717 UMA_HISTOGRAM_ENUMERATION("UserImage.ProfileDownloadResult",
719 kDownloadFailure, kDownloadResultsCount); 718 kDownloadFailure, kDownloadResultsCount);
720 719
721 DCHECK(!profile_image_load_start_time_.is_null()); 720 DCHECK(!profile_image_load_start_time_.is_null());
722 base::TimeDelta delta = base::Time::Now() - profile_image_load_start_time_; 721 base::TimeDelta delta = base::Time::Now() - profile_image_load_start_time_;
723 AddProfileImageTimeHistogram(kDownloadFailure, profile_image_download_reason_, 722 AddProfileImageTimeHistogram(kDownloadFailure, profile_image_download_reason_,
724 delta); 723 delta);
725 724
725 UserManager* user_manager = UserManager::Get();
726 const User* user = user_manager->GetLoggedInUser();
727
728 // Need note that at least one attempt finished.
729 user_manager->UpdateUserAccountData(user->email(), string16(), "");
730
726 // Retry download after some time if a network error has occured. 731 // Retry download after some time if a network error has occured.
727 if (reason == ProfileDownloaderDelegate::NETWORK_ERROR) { 732 if (reason == ProfileDownloaderDelegate::NETWORK_ERROR) {
728 BrowserThread::PostDelayedTask( 733 BrowserThread::PostDelayedTask(
729 BrowserThread::UI, 734 BrowserThread::UI,
730 FROM_HERE, 735 FROM_HERE,
731 base::Bind(&UserImageManagerImpl::DownloadProfileDataRetry, 736 base::Bind(&UserImageManagerImpl::DownloadProfileDataRetry,
732 base::Unretained(this), 737 base::Unretained(this),
733 downloading_profile_image_), 738 downloading_profile_image_),
734 base::TimeDelta::FromSeconds(kProfileDataDownloadRetryIntervalSec)); 739 base::TimeDelta::FromSeconds(kProfileDataDownloadRetryIntervalSec));
735 } 740 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 if (prefs_images_update->GetDictionaryWithoutPathExpansion( 779 if (prefs_images_update->GetDictionaryWithoutPathExpansion(
775 username, &image_properties)) { 780 username, &image_properties)) {
776 std::string image_path; 781 std::string image_path;
777 image_properties->GetString(kImagePathNodeName, &image_path); 782 image_properties->GetString(kImagePathNodeName, &image_path);
778 prefs_images_update->RemoveWithoutPathExpansion(username, NULL); 783 prefs_images_update->RemoveWithoutPathExpansion(username, NULL);
779 DeleteImageFile(image_path); 784 DeleteImageFile(image_path);
780 } 785 }
781 } 786 }
782 787
783 } // namespace chromeos 788 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698