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

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

Issue 10824359: Remove ImageSkia::empty and ImageSkia::extractSubset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "chrome/browser/chromeos/login/user_manager_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/desktop_background/desktop_background_controller.h" 9 #include "ash/desktop_background/desktop_background_controller.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
555 image_loader_->Start( 555 image_loader_->Start(
556 path.value(), login::kMaxUserImageSize, 556 path.value(), login::kMaxUserImageSize,
557 base::Bind(&UserManagerImpl::SaveUserImage, 557 base::Bind(&UserManagerImpl::SaveUserImage,
558 base::Unretained(this), username)); 558 base::Unretained(this), username));
559 } 559 }
560 560
561 void UserManagerImpl::SaveUserImageFromProfileImage( 561 void UserManagerImpl::SaveUserImageFromProfileImage(
562 const std::string& username) { 562 const std::string& username) {
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
564 if (!downloaded_profile_image_.empty()) { 564 if (!downloaded_profile_image_.isNull()) {
565 // Profile image has already been downloaded, so save it to file right now. 565 // Profile image has already been downloaded, so save it to file right now.
566 DCHECK(profile_image_url_.is_valid()); 566 DCHECK(profile_image_url_.is_valid());
567 SaveUserImageInternal( 567 SaveUserImageInternal(
568 username, 568 username,
569 User::kProfileImageIndex, profile_image_url_, 569 User::kProfileImageIndex, profile_image_url_,
570 UserImage::CreateAndEncode(downloaded_profile_image_)); 570 UserImage::CreateAndEncode(downloaded_profile_image_));
571 } else { 571 } else {
572 // No profile image - use the stub image (gray avatar). 572 // No profile image - use the stub image (gray avatar).
573 SetUserImage(username, User::kProfileImageIndex, GURL(), UserImage()); 573 SetUserImage(username, User::kProfileImageIndex, GURL(), UserImage());
574 SaveImageToLocalState(username, "", User::kProfileImageIndex, 574 SaveImageToLocalState(username, "", User::kProfileImageIndex,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 const GURL& image_url, 967 const GURL& image_url,
968 const UserImage& user_image) { 968 const UserImage& user_image) {
969 User* user = const_cast<User*>(FindUser(username)); 969 User* user = const_cast<User*>(FindUser(username));
970 // User may have been removed by now. 970 // User may have been removed by now.
971 if (user) { 971 if (user) {
972 // For existing users, a valid image index should have been set upon loading 972 // For existing users, a valid image index should have been set upon loading
973 // them from Local State. 973 // them from Local State.
974 DCHECK(user->image_index() != User::kInvalidImageIndex || 974 DCHECK(user->image_index() != User::kInvalidImageIndex ||
975 is_current_user_new_); 975 is_current_user_new_);
976 bool image_changed = user->image_index() != User::kInvalidImageIndex; 976 bool image_changed = user->image_index() != User::kInvalidImageIndex;
977 if (!user_image.image().empty()) 977 if (!user_image.image().isNull())
978 user->SetImage(user_image, image_index); 978 user->SetImage(user_image, image_index);
979 else 979 else
980 user->SetStubImage(image_index); 980 user->SetStubImage(image_index);
981 user->SetImageURL(image_url); 981 user->SetImageURL(image_url);
982 // For the logged-in user with a profile picture, initialize 982 // For the logged-in user with a profile picture, initialize
983 // |downloaded_profile_picture_|. 983 // |downloaded_profile_picture_|.
984 if (user == logged_in_user_ && image_index == User::kProfileImageIndex) 984 if (user == logged_in_user_ && image_index == User::kProfileImageIndex)
985 InitDownloadedProfileImage(); 985 InitDownloadedProfileImage();
986 if (image_changed) { 986 if (image_changed) {
987 // Unless this is first-time setting with |SetInitialUserImage|, 987 // Unless this is first-time setting with |SetInitialUserImage|,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 encoded_image->size()) == -1) { 1104 encoded_image->size()) == -1) {
1105 LOG(ERROR) << "Failed to save image to file."; 1105 LOG(ERROR) << "Failed to save image to file.";
1106 return false; 1106 return false;
1107 } 1107 }
1108 return true; 1108 return true;
1109 } 1109 }
1110 1110
1111 void UserManagerImpl::InitDownloadedProfileImage() { 1111 void UserManagerImpl::InitDownloadedProfileImage() {
1112 DCHECK(logged_in_user_); 1112 DCHECK(logged_in_user_);
1113 DCHECK_EQ(logged_in_user_->image_index(), User::kProfileImageIndex); 1113 DCHECK_EQ(logged_in_user_->image_index(), User::kProfileImageIndex);
1114 if (downloaded_profile_image_.empty() && !logged_in_user_->image_is_stub()) { 1114 if (downloaded_profile_image_.isNull() && !logged_in_user_->image_is_stub()) {
1115 VLOG(1) << "Profile image initialized"; 1115 VLOG(1) << "Profile image initialized";
1116 downloaded_profile_image_ = logged_in_user_->image(); 1116 downloaded_profile_image_ = logged_in_user_->image();
1117 downloaded_profile_image_data_url_ = 1117 downloaded_profile_image_data_url_ =
1118 web_ui_util::GetImageDataUrl(downloaded_profile_image_); 1118 web_ui_util::GetImageDataUrl(downloaded_profile_image_);
1119 profile_image_url_ = logged_in_user_->image_url(); 1119 profile_image_url_ = logged_in_user_->image_url();
1120 } 1120 }
1121 } 1121 }
1122 1122
1123 void UserManagerImpl::DownloadProfileData(const std::string& reason, 1123 void UserManagerImpl::DownloadProfileData(const std::string& reason,
1124 bool download_image) { 1124 bool download_image) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 BrowserThread::PostTask( 1373 BrowserThread::PostTask(
1374 BrowserThread::FILE, 1374 BrowserThread::FILE,
1375 FROM_HERE, 1375 FROM_HERE,
1376 base::Bind(&UserManagerImpl::DeleteUserImage, 1376 base::Bind(&UserManagerImpl::DeleteUserImage,
1377 base::Unretained(this), 1377 base::Unretained(this),
1378 image_path)); 1378 image_path));
1379 } 1379 }
1380 } 1380 }
1381 1381
1382 } // namespace chromeos 1382 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_image.cc ('k') | chrome/browser/chromeos/status/network_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698