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

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

Issue 1412813003: 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: Fix Win GN build. 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 = 413 user_manager::User* user = parent_->GetUserAndModify();
414 parent_->user_manager_->FindUserAndModify(user_id());
415 if (!user) 414 if (!user)
416 return; 415 return;
417 416
418 if (!user_image_.image().isNull()) { 417 if (!user_image_.image().isNull()) {
419 user->SetImage(user_image_, image_index_); 418 user->SetImage(user_image_, image_index_);
420 } else { 419 } else {
421 user->SetStubImage( 420 user->SetStubImage(
422 user_manager::UserImage( 421 user_manager::UserImage(
423 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 422 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
424 IDR_PROFILE_PICTURE_LOADING)), 423 IDR_PROFILE_PICTURE_LOADING)),
(...skipping 19 matching lines...) Expand all
444 443
445 void UserImageManagerImpl::Job::OnSaveImageDone(bool success) { 444 void UserImageManagerImpl::Job::OnSaveImageDone(bool success) {
446 if (success || image_index_ == user_manager::User::USER_IMAGE_PROFILE) 445 if (success || image_index_ == user_manager::User::USER_IMAGE_PROFILE)
447 UpdateLocalState(); 446 UpdateLocalState();
448 NotifyJobDone(); 447 NotifyJobDone();
449 } 448 }
450 449
451 void UserImageManagerImpl::Job::UpdateLocalState() { 450 void UserImageManagerImpl::Job::UpdateLocalState() {
452 // Ignore if data stored or cached outside the user's cryptohome is to be 451 // Ignore if data stored or cached outside the user's cryptohome is to be
453 // treated as ephemeral. 452 // treated as ephemeral.
454 if (parent_->user_manager_->IsUserNonCryptohomeDataEphemeral(user_id())) 453 if (parent_->user_manager_->IsUserNonCryptohomeDataEphemeral(
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 user_id(), 772 AccountId::FromUserEmail(user_id()),
773 user_manager::UserManager::UserAccountData( 773 user_manager::UserManager::UserAccountData(
774 downloader->GetProfileFullName(), 774 downloader->GetProfileFullName(), downloader->GetProfileGivenName(),
775 downloader->GetProfileGivenName(),
776 downloader->GetProfileLocale())); 775 downloader->GetProfileLocale()));
777 if (!downloading_profile_image_) 776 if (!downloading_profile_image_)
778 return; 777 return;
779 778
780 ProfileDownloadResult result = kDownloadFailure; 779 ProfileDownloadResult result = kDownloadFailure;
781 switch (downloader->GetProfilePictureStatus()) { 780 switch (downloader->GetProfilePictureStatus()) {
782 case ProfileDownloader::PICTURE_SUCCESS: 781 case ProfileDownloader::PICTURE_SUCCESS:
783 result = kDownloadSuccess; 782 result = kDownloadSuccess;
784 break; 783 break;
785 case ProfileDownloader::PICTURE_CACHED: 784 case ProfileDownloader::PICTURE_CACHED:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 // If the currently logged-in user's user image is managed, the sync observer 1009 // If the currently logged-in user's user image is managed, the sync observer
1011 // must not be started so that the policy-set image does not get synced out. 1010 // must not be started so that the policy-set image does not get synced out.
1012 if (!user_image_sync_observer_ && 1011 if (!user_image_sync_observer_ &&
1013 user && user->CanSyncImage() && 1012 user && user->CanSyncImage() &&
1014 !IsUserImageManaged()) { 1013 !IsUserImageManaged()) {
1015 user_image_sync_observer_.reset(new UserImageSyncObserver(user)); 1014 user_image_sync_observer_.reset(new UserImageSyncObserver(user));
1016 } 1015 }
1017 } 1016 }
1018 1017
1019 const user_manager::User* UserImageManagerImpl::GetUser() const { 1018 const user_manager::User* UserImageManagerImpl::GetUser() const {
1020 return user_manager_->FindUser(user_id()); 1019 return user_manager_->FindUser(AccountId::FromUserEmail(user_id()));
1021 } 1020 }
1022 1021
1023 user_manager::User* UserImageManagerImpl::GetUserAndModify() const { 1022 user_manager::User* UserImageManagerImpl::GetUserAndModify() const {
1024 return user_manager_->FindUserAndModify(user_id()); 1023 return user_manager_->FindUserAndModify(AccountId::FromUserEmail(user_id()));
1025 } 1024 }
1026 1025
1027 bool UserImageManagerImpl::IsUserLoggedInAndHasGaiaAccount() const { 1026 bool UserImageManagerImpl::IsUserLoggedInAndHasGaiaAccount() const {
1028 const user_manager::User* user = GetUser(); 1027 const user_manager::User* user = GetUser();
1029 if (!user) 1028 if (!user)
1030 return false; 1029 return false;
1031 return user->is_logged_in() && user->HasGaiaAccount(); 1030 return user->is_logged_in() && user->HasGaiaAccount();
1032 } 1031 }
1033 1032
1034 } // namespace chromeos 1033 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698