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

Unified Diff: chrome/browser/chromeos/login/user_image_manager_impl.cc

Issue 13088002: Use only IJG decoding path to decode profile pictures on login screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/login/user_image_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/user_image_manager_impl.cc
diff --git a/chrome/browser/chromeos/login/user_image_manager_impl.cc b/chrome/browser/chromeos/login/user_image_manager_impl.cc
index 8db43bd55dab48f46597bb2f18827a90d039074b..3db64c087aca0cc4a2d0e48289c38f5b39293160 100644
--- a/chrome/browser/chromeos/login/user_image_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_image_manager_impl.cc
@@ -238,10 +238,19 @@ void UserImageManagerImpl::LoadUserImages(const UserList& users) {
user->SetStubImage(image_index, true);
user->SetImageURL(image_gurl);
if (!image_path.empty()) {
- // Load user image asynchronously.
- UserImageLoader* loader =
- safe_source ? image_loader_.get() : unsafe_image_loader_.get();
- loader->Start(
+ if (needs_migration) {
+ // Non-JPG image will be migrated once user logs in.
+ // Stub image will be used for now.
+ return;
+ }
+ DCHECK(safe_source);
+ if (!safe_source)
+ return;
+
+ // Load user image asynchronously - at this point we are able to use
+ // JPEG image loaded since image comes from safe pref source
+ // i.e. converted to JPEG.
+ image_loader_->Start(
image_path, 0 /* no resize */,
base::Bind(&UserImageManagerImpl::SetUserImage,
base::Unretained(this),
@@ -260,11 +269,12 @@ void UserImageManagerImpl::UserLoggedIn(const std::string& email,
if (user_is_new) {
SetInitialUserImage(email);
} else {
- int image_index = UserManager::Get()->GetLoggedInUser()->image_index();
+ User* user = UserManager::Get()->GetLoggedInUser();
if (!user_is_local) {
// If current user image is profile image, it needs to be refreshed.
- bool download_profile_image = image_index == User::kProfileImageIndex;
+ bool download_profile_image =
+ user->image_index() == User::kProfileImageIndex;
if (download_profile_image)
InitDownloadedProfileImage();
@@ -281,17 +291,39 @@ void UserImageManagerImpl::UserLoggedIn(const std::string& email,
}
UMA_HISTOGRAM_ENUMERATION("UserImage.LoggedIn",
- ImageIndexToHistogramIndex(image_index),
+ ImageIndexToHistogramIndex(user->image_index()),
kHistogramImagesCount);
if (users_to_migrate_.count(email)) {
- // User needs image format migration.
- BrowserThread::PostDelayedTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(&UserImageManagerImpl::MigrateUserImage,
- base::Unretained(this)),
- base::TimeDelta::FromSeconds(user_image_migration_delay_sec));
+ const DictionaryValue* prefs_images_unsafe =
+ g_browser_process->local_state()->GetDictionary(kUserImages);
+ const base::DictionaryValue* image_properties = NULL;
+ if (prefs_images_unsafe->GetDictionaryWithoutPathExpansion(
+ user->email(), &image_properties)) {
+ std::string image_path;
+ image_properties->GetString(kImagePathNodeName, &image_path);
+ if (!image_path.empty()) {
+ // User needs image format migration but
+ // first we need to load and decode that image.
+ LOG(INFO) << "Waiting for user image to load before migration";
+ migrate_current_user_on_load_ = true;
+ unsafe_image_loader_->Start(
+ image_path, 0 /* no resize */,
+ base::Bind(&UserImageManagerImpl::SetUserImage,
+ base::Unretained(this),
+ user->email(),
+ user->image_index(),
+ user->image_url()));
+ } else {
+ // Otherwise migrate user image properties right away.
+ BrowserThread::PostDelayedTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&UserImageManagerImpl::MigrateUserImage,
+ base::Unretained(this)),
+ base::TimeDelta::FromSeconds(user_image_migration_delay_sec));
+ }
+ }
}
}
« no previous file with comments | « chrome/browser/chromeos/login/user_image_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698