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

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

Issue 8634007: [cros] Users without no profile image get a gray avatar when Local State is loaded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 base::Bind(&UserManager::SetUserImage, 596 base::Bind(&UserManager::SetUserImage,
597 base::Unretained(this), email, image_index)); 597 base::Unretained(this), email, image_index));
598 } 598 }
599 } else if (prefs_images->GetDictionaryWithoutPathExpansion( 599 } else if (prefs_images->GetDictionaryWithoutPathExpansion(
600 email, &image_properties)) { 600 email, &image_properties)) {
601 int image_index = User::kInvalidImageIndex; 601 int image_index = User::kInvalidImageIndex;
602 image_properties->GetString(kImagePathNodeName, &image_path); 602 image_properties->GetString(kImagePathNodeName, &image_path);
603 image_properties->GetInteger(kImageIndexNodeName, &image_index); 603 image_properties->GetInteger(kImageIndexNodeName, &image_index);
604 if (image_index >= 0 && image_index < kDefaultImagesCount) { 604 if (image_index >= 0 && image_index < kDefaultImagesCount) {
605 user->SetImage(GetDefaultImage(image_index), image_index); 605 user->SetImage(GetDefaultImage(image_index), image_index);
606 } else if (image_index == User::kExternalImageIndex || 606 } else if (image_index == User::kExternalImageIndex) {
607 image_index == User::kProfileImageIndex) { 607 DCHECK(!image_path.empty());
608 // Until image has been loaded, use a stub.
609 user->SetImage(GetDefaultImage(kStubDefaultImageIndex),
610 User::kExternalImageIndex);
611 // Load user image asynchronously.
612 image_loader_->Start(
613 image_path, 0,
614 base::Bind(&UserManager::SetUserImage,
615 base::Unretained(this), email, image_index));
616 } else if (image_index == User::kProfileImageIndex) {
617 // Until image has been loaded, use the default gray avatar.
whywhat 2011/11/22 13:55:39 Let's use gray avatar in both cases.
Ivan Korotkov 2011/11/22 15:11:07 Makes sense.
618 user->SetImage(*ResourceBundle::GetSharedInstance().
619 GetBitmapNamed(IDR_PROFILE_PICTURE_LOADING),
620 User::kProfileImageIndex);
608 // Path may be empty for profile images (meaning that the image 621 // Path may be empty for profile images (meaning that the image
609 // hasn't been downloaded for the first time yet, in which case a 622 // hasn't been downloaded for the first time yet, in which case a
610 // download will be scheduled for |kProfileImageDownloadDelayMs| 623 // download will be scheduled for |kProfileImageDownloadDelayMs|
611 // after user logs in). 624 // after user logs in).
612 DCHECK(!image_path.empty() ||
613 image_index == User::kProfileImageIndex);
614 // Until image has been loaded, use a stub.
615 user->SetImage(GetDefaultImage(kStubDefaultImageIndex),
616 image_index);
617 if (!image_path.empty()) { 625 if (!image_path.empty()) {
618 // Load user image asynchronously. 626 // Load user image asynchronously.
619 image_loader_->Start( 627 image_loader_->Start(
620 image_path, 0, 628 image_path, 0,
621 base::Bind(&UserManager::SetUserImage, 629 base::Bind(&UserManager::SetUserImage,
622 base::Unretained(this), email, image_index)); 630 base::Unretained(this), email, image_index));
623 } 631 }
624 } else { 632 } else {
625 NOTREACHED(); 633 NOTREACHED();
626 } 634 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 901
894 User* UserManager::CreateUser(const std::string& email) const { 902 User* UserManager::CreateUser(const std::string& email) const {
895 User* user = new User(email); 903 User* user = new User(email);
896 user->set_oauth_token_status(GetUserOAuthStatus(email)); 904 user->set_oauth_token_status(GetUserOAuthStatus(email));
897 // Used to determine whether user's display name is unique. 905 // Used to determine whether user's display name is unique.
898 ++display_name_count_[user->GetDisplayName()]; 906 ++display_name_count_[user->GetDisplayName()];
899 return user; 907 return user;
900 } 908 }
901 909
902 } // namespace chromeos 910 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698