OLD | NEW |
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
564 if (!downloaded_profile_image_.empty()) { | 564 if (!downloaded_profile_image_.empty()) { |
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, | 573 SetUserImage(username, User::kProfileImageIndex, GURL(), UserImage()); |
574 GURL(), UserImage::CreateAndEncode(SkBitmap())); | |
575 SaveImageToLocalState(username, "", User::kProfileImageIndex, | 574 SaveImageToLocalState(username, "", User::kProfileImageIndex, |
576 GURL(), false); | 575 GURL(), false); |
577 } | 576 } |
578 } | 577 } |
579 | 578 |
580 void UserManagerImpl::DownloadProfileImage(const std::string& reason) { | 579 void UserManagerImpl::DownloadProfileImage(const std::string& reason) { |
581 DownloadProfileData(reason, true); | 580 DownloadProfileData(reason, true); |
582 } | 581 } |
583 | 582 |
584 void UserManagerImpl::Observe(int type, | 583 void UserManagerImpl::Observe(int type, |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 reinterpret_cast<const char*>(&(*encoded_image)[0]), | 1099 reinterpret_cast<const char*>(&(*encoded_image)[0]), |
1101 encoded_image->size()) == -1) { | 1100 encoded_image->size()) == -1) { |
1102 LOG(ERROR) << "Failed to save image to file."; | 1101 LOG(ERROR) << "Failed to save image to file."; |
1103 return false; | 1102 return false; |
1104 } | 1103 } |
1105 return true; | 1104 return true; |
1106 } | 1105 } |
1107 | 1106 |
1108 void UserManagerImpl::InitDownloadedProfileImage() { | 1107 void UserManagerImpl::InitDownloadedProfileImage() { |
1109 DCHECK(logged_in_user_); | 1108 DCHECK(logged_in_user_); |
| 1109 DCHECK_EQ(logged_in_user_->image_index(), User::kProfileImageIndex); |
1110 if (downloaded_profile_image_.empty() && !logged_in_user_->image_is_stub()) { | 1110 if (downloaded_profile_image_.empty() && !logged_in_user_->image_is_stub()) { |
1111 VLOG(1) << "Profile image initialized"; | 1111 VLOG(1) << "Profile image initialized"; |
1112 downloaded_profile_image_ = logged_in_user_->image(); | 1112 downloaded_profile_image_ = logged_in_user_->image(); |
1113 downloaded_profile_image_data_url_ = | 1113 downloaded_profile_image_data_url_ = |
1114 web_ui_util::GetImageDataUrl(gfx::ImageSkia(downloaded_profile_image_)); | 1114 web_ui_util::GetImageDataUrl(gfx::ImageSkia(downloaded_profile_image_)); |
1115 profile_image_url_ = logged_in_user_->image_url(); | 1115 profile_image_url_ = logged_in_user_->image_url(); |
1116 } | 1116 } |
1117 } | 1117 } |
1118 | 1118 |
1119 void UserManagerImpl::DownloadProfileData(const std::string& reason, | 1119 void UserManagerImpl::DownloadProfileData(const std::string& reason, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 BrowserThread::PostTask( | 1372 BrowserThread::PostTask( |
1373 BrowserThread::FILE, | 1373 BrowserThread::FILE, |
1374 FROM_HERE, | 1374 FROM_HERE, |
1375 base::Bind(&UserManagerImpl::DeleteUserImage, | 1375 base::Bind(&UserManagerImpl::DeleteUserImage, |
1376 base::Unretained(this), | 1376 base::Unretained(this), |
1377 image_path)); | 1377 image_path)); |
1378 } | 1378 } |
1379 } | 1379 } |
1380 | 1380 |
1381 } // namespace chromeos | 1381 } // namespace chromeos |
OLD | NEW |