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

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

Issue 1425093004: Revert of This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/users/avatar/user_image_manager_impl.h" 5 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 const user_manager::UserImage& user_image) { 403 const user_manager::UserImage& user_image) {
404 user_image_ = user_image; 404 user_image_ = user_image;
405 UpdateUser(); 405 UpdateUser();
406 if (save) 406 if (save)
407 SaveImageAndUpdateLocalState(); 407 SaveImageAndUpdateLocalState();
408 else 408 else
409 NotifyJobDone(); 409 NotifyJobDone();
410 } 410 }
411 411
412 void UserImageManagerImpl::Job::UpdateUser() { 412 void UserImageManagerImpl::Job::UpdateUser() {
413 user_manager::User* user = parent_->GetUserAndModify(); 413 user_manager::User* user =
414 parent_->user_manager_->FindUserAndModify(user_id());
414 if (!user) 415 if (!user)
415 return; 416 return;
416 417
417 if (!user_image_.image().isNull()) { 418 if (!user_image_.image().isNull()) {
418 user->SetImage(user_image_, image_index_); 419 user->SetImage(user_image_, image_index_);
419 } else { 420 } else {
420 user->SetStubImage( 421 user->SetStubImage(
421 user_manager::UserImage( 422 user_manager::UserImage(
422 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 423 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
423 IDR_PROFILE_PICTURE_LOADING)), 424 IDR_PROFILE_PICTURE_LOADING)),
(...skipping 19 matching lines...) Expand all
443 444
444 void UserImageManagerImpl::Job::OnSaveImageDone(bool success) { 445 void UserImageManagerImpl::Job::OnSaveImageDone(bool success) {
445 if (success || image_index_ == user_manager::User::USER_IMAGE_PROFILE) 446 if (success || image_index_ == user_manager::User::USER_IMAGE_PROFILE)
446 UpdateLocalState(); 447 UpdateLocalState();
447 NotifyJobDone(); 448 NotifyJobDone();
448 } 449 }
449 450
450 void UserImageManagerImpl::Job::UpdateLocalState() { 451 void UserImageManagerImpl::Job::UpdateLocalState() {
451 // Ignore if data stored or cached outside the user's cryptohome is to be 452 // Ignore if data stored or cached outside the user's cryptohome is to be
452 // treated as ephemeral. 453 // treated as ephemeral.
453 if (parent_->user_manager_->IsUserNonCryptohomeDataEphemeral( 454 if (parent_->user_manager_->IsUserNonCryptohomeDataEphemeral(user_id()))
454 AccountId::FromUserEmail(user_id())))
455 return; 455 return;
456 456
457 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 457 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
458 entry->Set(kImagePathNodeName, new base::StringValue(image_path_.value())); 458 entry->Set(kImagePathNodeName, new base::StringValue(image_path_.value()));
459 entry->Set(kImageIndexNodeName, new base::FundamentalValue(image_index_)); 459 entry->Set(kImageIndexNodeName, new base::FundamentalValue(image_index_));
460 if (!image_url_.is_empty()) 460 if (!image_url_.is_empty())
461 entry->Set(kImageURLNodeName, new base::StringValue(image_url_.spec())); 461 entry->Set(kImageURLNodeName, new base::StringValue(image_url_.spec()));
462 DictionaryPrefUpdate update(g_browser_process->local_state(), 462 DictionaryPrefUpdate update(g_browser_process->local_state(),
463 kUserImageProperties); 463 kUserImageProperties);
464 update->SetWithoutPathExpansion(user_id(), entry.release()); 464 update->SetWithoutPathExpansion(user_id(), entry.release());
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 762 }
763 763
764 void UserImageManagerImpl::OnProfileDownloadSuccess( 764 void UserImageManagerImpl::OnProfileDownloadSuccess(
765 ProfileDownloader* downloader) { 765 ProfileDownloader* downloader) {
766 // Ensure that the |profile_downloader_| is deleted when this method returns. 766 // Ensure that the |profile_downloader_| is deleted when this method returns.
767 scoped_ptr<ProfileDownloader> profile_downloader( 767 scoped_ptr<ProfileDownloader> profile_downloader(
768 profile_downloader_.release()); 768 profile_downloader_.release());
769 DCHECK_EQ(downloader, profile_downloader.get()); 769 DCHECK_EQ(downloader, profile_downloader.get());
770 770
771 user_manager_->UpdateUserAccountData( 771 user_manager_->UpdateUserAccountData(
772 AccountId::FromUserEmail(user_id()), 772 user_id(),
773 user_manager::UserManager::UserAccountData( 773 user_manager::UserManager::UserAccountData(
774 downloader->GetProfileFullName(), downloader->GetProfileGivenName(), 774 downloader->GetProfileFullName(),
775 downloader->GetProfileGivenName(),
775 downloader->GetProfileLocale())); 776 downloader->GetProfileLocale()));
776 if (!downloading_profile_image_) 777 if (!downloading_profile_image_)
777 return; 778 return;
778 779
779 ProfileDownloadResult result = kDownloadFailure; 780 ProfileDownloadResult result = kDownloadFailure;
780 switch (downloader->GetProfilePictureStatus()) { 781 switch (downloader->GetProfilePictureStatus()) {
781 case ProfileDownloader::PICTURE_SUCCESS: 782 case ProfileDownloader::PICTURE_SUCCESS:
782 result = kDownloadSuccess; 783 result = kDownloadSuccess;
783 break; 784 break;
784 case ProfileDownloader::PICTURE_CACHED: 785 case ProfileDownloader::PICTURE_CACHED:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // If the currently logged-in user's user image is managed, the sync observer 1010 // If the currently logged-in user's user image is managed, the sync observer
1010 // must not be started so that the policy-set image does not get synced out. 1011 // must not be started so that the policy-set image does not get synced out.
1011 if (!user_image_sync_observer_ && 1012 if (!user_image_sync_observer_ &&
1012 user && user->CanSyncImage() && 1013 user && user->CanSyncImage() &&
1013 !IsUserImageManaged()) { 1014 !IsUserImageManaged()) {
1014 user_image_sync_observer_.reset(new UserImageSyncObserver(user)); 1015 user_image_sync_observer_.reset(new UserImageSyncObserver(user));
1015 } 1016 }
1016 } 1017 }
1017 1018
1018 const user_manager::User* UserImageManagerImpl::GetUser() const { 1019 const user_manager::User* UserImageManagerImpl::GetUser() const {
1019 return user_manager_->FindUser(AccountId::FromUserEmail(user_id())); 1020 return user_manager_->FindUser(user_id());
1020 } 1021 }
1021 1022
1022 user_manager::User* UserImageManagerImpl::GetUserAndModify() const { 1023 user_manager::User* UserImageManagerImpl::GetUserAndModify() const {
1023 return user_manager_->FindUserAndModify(AccountId::FromUserEmail(user_id())); 1024 return user_manager_->FindUserAndModify(user_id());
1024 } 1025 }
1025 1026
1026 bool UserImageManagerImpl::IsUserLoggedInAndHasGaiaAccount() const { 1027 bool UserImageManagerImpl::IsUserLoggedInAndHasGaiaAccount() const {
1027 const user_manager::User* user = GetUser(); 1028 const user_manager::User* user = GetUser();
1028 if (!user) 1029 if (!user)
1029 return false; 1030 return false;
1030 return user->is_logged_in() && user->HasGaiaAccount(); 1031 return user->is_logged_in() && user->HasGaiaAccount();
1031 } 1032 }
1032 1033
1033 } // namespace chromeos 1034 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698