Index: chrome/browser/chromeos/login/user_manager_impl.cc |
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc |
index 1416a2d4ba8b797c8e960c7e843abf8cff811147..611f2110800b9aa7b156a34b8e4d5e47de601a2a 100644 |
--- a/chrome/browser/chromeos/login/user_manager_impl.cc |
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc |
@@ -35,7 +35,6 @@ |
#include "chrome/browser/chromeos/login/login_display.h" |
#include "chrome/browser/chromeos/login/ownership_service.h" |
#include "chrome/browser/chromeos/login/remove_user_delegate.h" |
-#include "chrome/browser/chromeos/login/user_image.h" |
#include "chrome/browser/policy/browser_policy_connector.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/prefs/scoped_user_pref_update.h" |
@@ -355,7 +354,7 @@ void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) { |
void UserManagerImpl::StubUserLoggedIn() { |
is_current_user_ephemeral_ = true; |
logged_in_user_ = new User(kStubUser, false); |
- logged_in_user_->SetImage(UserImage(GetDefaultImage(kStubDefaultImageIndex)), |
+ logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex), |
kStubDefaultImageIndex); |
} |
@@ -377,9 +376,9 @@ void UserManagerImpl::UserSelected(const std::string& email) { |
ash::WallpaperLayout layout = static_cast<ash::WallpaperLayout>(index); |
// Load user image asynchronously. |
image_loader_->Start( |
- wallpaper_path, 0, false, |
+ wallpaper_path, 0, |
base::Bind(&UserManagerImpl::OnCustomWallpaperLoaded, |
- base::Unretained(this), email, layout)); |
+ base::Unretained(this), email, layout)); |
return; |
} |
ash::Shell::GetInstance()->desktop_background_controller()-> |
@@ -521,13 +520,13 @@ std::string UserManagerImpl::GetUserDisplayEmail( |
void UserManagerImpl::SaveUserDefaultImageIndex(const std::string& username, |
int image_index) { |
DCHECK(image_index >= 0 && image_index < kDefaultImagesCount); |
- SetUserImage(username, image_index, UserImage(GetDefaultImage(image_index))); |
+ SetUserImage(username, image_index, GetDefaultImage(image_index)); |
SaveImageToLocalState(username, "", image_index, false); |
} |
void UserManagerImpl::SaveUserImage(const std::string& username, |
- const UserImage& user_image) { |
- SaveUserImageInternal(username, User::kExternalImageIndex, user_image); |
+ const SkBitmap& image) { |
+ SaveUserImageInternal(username, User::kExternalImageIndex, image); |
} |
void UserManagerImpl::SetLoggedInUserCustomWallpaperLayout( |
@@ -550,7 +549,7 @@ void UserManagerImpl::SetLoggedInUserCustomWallpaperLayout( |
void UserManagerImpl::SaveUserImageFromFile(const std::string& username, |
const FilePath& path) { |
image_loader_->Start( |
- path.value(), login::kUserImageSize, true, |
+ path.value(), login::kUserImageSize, |
base::Bind(&UserManagerImpl::SaveUserImage, |
base::Unretained(this), username)); |
} |
@@ -561,7 +560,7 @@ void UserManagerImpl::SaveUserWallpaperFromFile(const std::string& username, |
WallpaperDelegate* delegate) { |
// For wallpapers, save the image without resizing. |
image_loader_->Start( |
- path.value(), 0 /* Original size */, false, |
+ path.value(), 0 /* Original size */, |
base::Bind(&UserManagerImpl::SaveUserWallpaperInternal, |
base::Unretained(this), username, layout, User::CUSTOMIZED, |
delegate)); |
@@ -572,10 +571,10 @@ void UserManagerImpl::SaveUserImageFromProfileImage( |
if (!downloaded_profile_image_.empty()) { |
// Profile image has already been downloaded, so save it to file right now. |
SaveUserImageInternal(username, User::kProfileImageIndex, |
- UserImage(downloaded_profile_image_)); |
+ downloaded_profile_image_); |
} else { |
// No profile image - use the stub image (gray avatar). |
- SetUserImage(username, User::kProfileImageIndex, UserImage(SkBitmap())); |
+ SetUserImage(username, User::kProfileImageIndex, SkBitmap()); |
SaveImageToLocalState(username, "", User::kProfileImageIndex, false); |
} |
} |
@@ -749,7 +748,7 @@ void UserManagerImpl::EnsureUsersLoaded() { |
if (prefs_images->GetStringWithoutPathExpansion(email, &image_path)) { |
int image_id = User::kInvalidImageIndex; |
if (IsDefaultImagePath(image_path, &image_id)) { |
- user->SetImage(UserImage(GetDefaultImage(image_id)), image_id); |
+ user->SetImage(GetDefaultImage(image_id), image_id); |
} else { |
int image_index = User::kExternalImageIndex; |
// Until image has been loaded, use the stub image. |
@@ -757,7 +756,7 @@ void UserManagerImpl::EnsureUsersLoaded() { |
DCHECK(!image_path.empty()); |
// Load user image asynchronously. |
image_loader_->Start( |
- image_path, 0, true, |
+ image_path, 0, |
base::Bind(&UserManagerImpl::SetUserImage, |
base::Unretained(this), email, image_index)); |
} |
@@ -767,8 +766,7 @@ void UserManagerImpl::EnsureUsersLoaded() { |
image_properties->GetString(kImagePathNodeName, &image_path); |
image_properties->GetInteger(kImageIndexNodeName, &image_index); |
if (image_index >= 0 && image_index < kDefaultImagesCount) { |
- user->SetImage(UserImage(GetDefaultImage(image_index)), |
- image_index); |
+ user->SetImage(GetDefaultImage(image_index), image_index); |
} else if (image_index == User::kExternalImageIndex || |
image_index == User::kProfileImageIndex) { |
// Path may be empty for profile images (meaning that the image |
@@ -782,7 +780,7 @@ void UserManagerImpl::EnsureUsersLoaded() { |
if (!image_path.empty()) { |
// Load user image asynchronously. |
image_loader_->Start( |
- image_path, 0, true, |
+ image_path, 0, |
base::Bind(&UserManagerImpl::SetUserImage, |
base::Unretained(this), email, image_index)); |
} |
@@ -988,7 +986,7 @@ void UserManagerImpl::SaveLoggedInUserWallpaperProperties( |
void UserManagerImpl::SetUserImage(const std::string& username, |
int image_index, |
- const UserImage& user_image) { |
+ const SkBitmap& image) { |
User* user = const_cast<User*>(FindUser(username)); |
// User may have been removed by now. |
if (user) { |
@@ -997,8 +995,8 @@ void UserManagerImpl::SetUserImage(const std::string& username, |
DCHECK(user->image_index() != User::kInvalidImageIndex || |
is_current_user_new_); |
bool image_changed = user->image_index() != User::kInvalidImageIndex; |
- if (!user_image.image().empty()) |
- user->SetImage(user_image, image_index); |
+ if (!image.empty()) |
+ user->SetImage(image, image_index); |
else |
user->SetStubImage(image_index); |
// For the logged-in user with a profile picture, initialize |
@@ -1071,10 +1069,10 @@ void UserManagerImpl::SaveUserWallpaperProperties(const std::string& username, |
void UserManagerImpl::SaveUserImageInternal(const std::string& username, |
int image_index, |
- const UserImage& user_image) { |
+ const SkBitmap& image) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- SetUserImage(username, image_index, user_image); |
+ SetUserImage(username, image_index, image); |
// Ignore for ephemeral users. |
if (IsEphemeralUser(username)) |
@@ -1090,17 +1088,16 @@ void UserManagerImpl::SaveUserImageInternal(const std::string& username, |
FROM_HERE, |
base::Bind(&UserManagerImpl::SaveImageToFile, |
base::Unretained(this), |
- username, user_image, image_path, image_index)); |
+ username, image, image_path, image_index)); |
} |
void UserManagerImpl::SaveUserWallpaperInternal(const std::string& username, |
ash::WallpaperLayout layout, |
User::WallpaperType type, |
WallpaperDelegate* delegate, |
- const UserImage& user_image) { |
+ const SkBitmap& wallpaper) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- const SkBitmap& wallpaper = user_image.image(); |
BrowserThread::PostTask( |
BrowserThread::FILE, |
FROM_HERE, |
@@ -1129,23 +1126,21 @@ void UserManagerImpl::SaveUserWallpaperInternal(const std::string& username, |
void UserManagerImpl::OnCustomWallpaperLoaded(const std::string& email, |
ash::WallpaperLayout layout, |
- const UserImage& user_image) { |
- const SkBitmap& wallpaper = user_image.image(); |
+ const SkBitmap& wallpaper) { |
ash::Shell::GetInstance()->desktop_background_controller()-> |
SetCustomWallpaper(wallpaper, layout); |
// Starting to load wallpaper thumbnail |
std::string wallpaper_thumbnail_path = |
GetWallpaperPathForUser(email, true).value(); |
image_loader_->Start( |
- wallpaper_thumbnail_path, 0, false, |
+ wallpaper_thumbnail_path, 0, |
base::Bind(&UserManagerImpl::OnCustomWallpaperThumbnailLoaded, |
base::Unretained(this), email)); |
} |
void UserManagerImpl::OnCustomWallpaperThumbnailLoaded( |
const std::string& email, |
- const UserImage& user_image) { |
- const SkBitmap& wallpaper = user_image.image(); |
+ const SkBitmap& wallpaper) { |
User* user = const_cast<User*>(FindUser(email)); |
// User may have been removed by now. |
if (user && !wallpaper.empty()) |
@@ -1181,14 +1176,14 @@ void UserManagerImpl::GenerateUserWallpaperThumbnail( |
return; |
FilePath thumbnail_path = GetWallpaperPathForUser(username, true); |
- SaveBitmapToFile(UserImage(thumbnail), thumbnail_path); |
+ SaveBitmapToFile(thumbnail, thumbnail_path); |
} |
void UserManagerImpl::SaveImageToFile(const std::string& username, |
- const UserImage& user_image, |
+ const SkBitmap& image, |
const FilePath& image_path, |
int image_index) { |
- if (!SaveBitmapToFile(user_image, image_path)) |
+ if (!SaveBitmapToFile(image, image_path)) |
return; |
BrowserThread::PostTask( |
@@ -1206,7 +1201,7 @@ void UserManagerImpl::SaveWallpaperToFile(const std::string& username, |
User::WallpaperType type) { |
// TODO(bshe): We should save the original file unchanged instead of |
// re-encoding it and saving it. |
- if (!SaveBitmapToFile(UserImage(wallpaper), wallpaper_path)) |
+ if (!SaveBitmapToFile(wallpaper, wallpaper_path)) |
return; |
BrowserThread::PostTask( |
@@ -1258,16 +1253,12 @@ void UserManagerImpl::SaveWallpaperToLocalState(const std::string& username, |
SaveUserWallpaperProperties(username, type, layout); |
} |
-bool UserManagerImpl::SaveBitmapToFile(const UserImage& user_image, |
+bool UserManagerImpl::SaveBitmapToFile(const SkBitmap& image, |
const FilePath& image_path) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
std::vector<unsigned char> encoded_image; |
- if (user_image.has_raw_image()) { |
- encoded_image = user_image.raw_image(); |
- } else if (!gfx::PNGCodec::EncodeBGRASkBitmap(user_image.image(), |
- false, |
- &encoded_image)) { |
+ if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, false, &encoded_image)) { |
LOG(ERROR) << "Failed to PNG encode the image."; |
return false; |
} |