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

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

Issue 10375010: Implement user selected wallpaper feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 years, 7 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/shell.h" 9 #include "ash/shell.h"
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/sync/profile_sync_service.h" 43 #include "chrome/browser/sync/profile_sync_service.h"
44 #include "chrome/browser/sync/profile_sync_service_factory.h" 44 #include "chrome/browser/sync/profile_sync_service_factory.h"
45 #include "chrome/browser/ui/webui/web_ui_util.h" 45 #include "chrome/browser/ui/webui/web_ui_util.h"
46 #include "chrome/common/chrome_notification_types.h" 46 #include "chrome/common/chrome_notification_types.h"
47 #include "chrome/common/chrome_paths.h" 47 #include "chrome/common/chrome_paths.h"
48 #include "chrome/common/chrome_switches.h" 48 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/net/gaia/google_service_auth_error.h" 49 #include "chrome/common/net/gaia/google_service_auth_error.h"
50 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
52 #include "content/public/common/url_constants.h" 52 #include "content/public/common/url_constants.h"
53 #include "skia/ext/image_operations.h"
53 #include "third_party/skia/include/core/SkBitmap.h" 54 #include "third_party/skia/include/core/SkBitmap.h"
54 #include "ui/gfx/codec/png_codec.h" 55 #include "ui/gfx/codec/png_codec.h"
55 56
56 using content::BrowserThread; 57 using content::BrowserThread;
57 58
58 typedef GoogleServiceAuthError AuthError; 59 typedef GoogleServiceAuthError AuthError;
59 60
60 namespace chromeos { 61 namespace chromeos {
61 62
62 namespace { 63 namespace {
63 64
64 // Incognito user is represented by an empty string (since some code already 65 // Incognito user is represented by an empty string (since some code already
65 // depends on that and it's hard to figure out what). 66 // depends on that and it's hard to figure out what).
66 const char kGuestUser[] = ""; 67 const char kGuestUser[] = "";
67 68
68 // Stub user email (for test paths). 69 // Stub user email (for test paths).
69 const char kStubUser[] = "stub-user@example.com"; 70 const char kStubUser[] = "stub-user@example.com";
70 71
71 // Names of nodes with info about user image. 72 // Names of nodes with info about user image.
72 const char kImagePathNodeName[] = "path"; 73 const char kImagePathNodeName[] = "path";
73 const char kImageIndexNodeName[] = "index"; 74 const char kImageIndexNodeName[] = "index";
74 75
75 const char kWallpaperTypeNodeName[] = "type"; 76 const char kWallpaperTypeNodeName[] = "type";
76 const char kWallpaperIndexNodeName[] = "index"; 77 const char kWallpaperIndexNodeName[] = "index";
77 78
79 const int kThumbnailWidth = 128;
80 const int kThumbnailHeight = 80;
81
78 // Index of the default image used for the |kStubUser| user. 82 // Index of the default image used for the |kStubUser| user.
79 const int kStubDefaultImageIndex = 0; 83 const int kStubDefaultImageIndex = 0;
80 84
81 // Delay betweeen user login and attempt to update user's profile image. 85 // Delay betweeen user login and attempt to update user's profile image.
82 const long kProfileImageDownloadDelayMs = 10000; 86 const long kProfileImageDownloadDelayMs = 10000;
83 87
84 // Enum for reporting histograms about profile picture download. 88 // Enum for reporting histograms about profile picture download.
85 enum ProfileDownloadResult { 89 enum ProfileDownloadResult {
86 kDownloadSuccessChanged, 90 kDownloadSuccessChanged,
87 kDownloadSuccess, 91 kDownloadSuccess,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void UserManagerImpl::UserSelected(const std::string& email) { 358 void UserManagerImpl::UserSelected(const std::string& email) {
355 if (IsKnownUser(email)) { 359 if (IsKnownUser(email)) {
356 User::WallpaperType type; 360 User::WallpaperType type;
357 int index; 361 int index;
358 GetUserWallpaperProperties(email, &type, &index); 362 GetUserWallpaperProperties(email, &type, &index);
359 if (type == User::RANDOM) { 363 if (type == User::RANDOM) {
360 // Generate a new random wallpaper index if the selected user chose 364 // Generate a new random wallpaper index if the selected user chose
361 // RANDOM wallpaper. 365 // RANDOM wallpaper.
362 index = ash::GetRandomWallpaperIndex(); 366 index = ash::GetRandomWallpaperIndex();
363 SaveUserWallpaperProperties(email, User::RANDOM, index); 367 SaveUserWallpaperProperties(email, User::RANDOM, index);
368 } else if (type == User::CUSTOMIZED) {
369 std::string wallpaper_path =
370 GetWallpaperPathForUser(email, false).value();
371 // In customized mode, we use index pref to save the user selected
372 // wallpaper layout. See function SaveWallpaperToLocalState().
373 ash::WallpaperLayout layout = static_cast<ash::WallpaperLayout>(index);
374 // Load user image asynchronously.
375 image_loader_->Start(
376 wallpaper_path, 0,
377 base::Bind(&UserManagerImpl::LoadCustomWallpaperThumbnail,
378 base::Unretained(this), email, layout));
379 return;
364 } 380 }
365 ash::Shell::GetInstance()->desktop_background_controller()-> 381 ash::Shell::GetInstance()->desktop_background_controller()->
366 SetDefaultWallpaper(index); 382 SetDefaultWallpaper(index);
367 } 383 }
368 } 384 }
369 385
370 void UserManagerImpl::SessionStarted() { 386 void UserManagerImpl::SessionStarted() {
371 session_started_ = true; 387 session_started_ = true;
372 content::NotificationService::current()->Notify( 388 content::NotificationService::current()->Notify(
373 chrome::NOTIFICATION_SESSION_STARTED, 389 chrome::NOTIFICATION_SESSION_STARTED,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 DCHECK(image_index >= 0 && image_index < kDefaultImagesCount); 519 DCHECK(image_index >= 0 && image_index < kDefaultImagesCount);
504 SetUserImage(username, image_index, GetDefaultImage(image_index)); 520 SetUserImage(username, image_index, GetDefaultImage(image_index));
505 SaveImageToLocalState(username, "", image_index, false); 521 SaveImageToLocalState(username, "", image_index, false);
506 } 522 }
507 523
508 void UserManagerImpl::SaveUserImage(const std::string& username, 524 void UserManagerImpl::SaveUserImage(const std::string& username,
509 const SkBitmap& image) { 525 const SkBitmap& image) {
510 SaveUserImageInternal(username, User::kExternalImageIndex, image); 526 SaveUserImageInternal(username, User::kExternalImageIndex, image);
511 } 527 }
512 528
529 void UserManagerImpl::SetLoggedInUserCustomWallpaperLayout(
530 ash::WallpaperLayout layout) {
531 // TODO(bshe): We current disabled the customized wallpaper feature for
532 // Ephemeral user. As we dont want to keep a copy of customized wallpaper in
533 // memory. Need a smarter way to solve this.
534 if (IsCurrentUserEphemeral())
535 return;
536 const chromeos::User& user = GetLoggedInUser();
537 std::string username = user.email();
538 DCHECK(!username.empty());
539
540 std::string file_path = GetWallpaperPathForUser(username, false).value();
541 SaveWallpaperToLocalState(username, file_path, layout, User::CUSTOMIZED);
542 // Load wallpaper from file.
543 UserSelected(username);
544 }
545
513 void UserManagerImpl::SaveUserImageFromFile(const std::string& username, 546 void UserManagerImpl::SaveUserImageFromFile(const std::string& username,
514 const FilePath& path) { 547 const FilePath& path) {
515 image_loader_->Start( 548 image_loader_->Start(
516 path.value(), login::kUserImageSize, 549 path.value(), login::kUserImageSize,
517 base::Bind(&UserManagerImpl::SaveUserImage, 550 base::Bind(&UserManagerImpl::SaveUserImage,
518 base::Unretained(this), username)); 551 base::Unretained(this), username));
519 } 552 }
520 553
554 void UserManagerImpl::SaveUserWallpaperFromFile(const std::string& username,
555 const FilePath& path,
556 ash::WallpaperLayout layout,
557 WallpaperDelegate* delegate) {
558 // For wallpapers, save the image without resizing.
559 image_loader_->Start(
560 path.value(), 0 /* Original size */,
561 base::Bind(&UserManagerImpl::SaveUserWallpaperInternal,
562 base::Unretained(this), username, layout, User::CUSTOMIZED,
563 delegate));
564 }
565
521 void UserManagerImpl::SaveUserImageFromProfileImage( 566 void UserManagerImpl::SaveUserImageFromProfileImage(
522 const std::string& username) { 567 const std::string& username) {
523 if (!downloaded_profile_image_.empty()) { 568 if (!downloaded_profile_image_.empty()) {
524 // Profile image has already been downloaded, so save it to file right now. 569 // Profile image has already been downloaded, so save it to file right now.
525 SaveUserImageInternal(username, User::kProfileImageIndex, 570 SaveUserImageInternal(username, User::kProfileImageIndex,
526 downloaded_profile_image_); 571 downloaded_profile_image_);
527 } else { 572 } else {
528 // No profile image - use the stub image (gray avatar). 573 // No profile image - use the stub image (gray avatar).
529 SetUserImage(username, User::kProfileImageIndex, SkBitmap()); 574 SetUserImage(username, User::kProfileImageIndex, SkBitmap());
530 SaveImageToLocalState(username, "", User::kProfileImageIndex, false); 575 SaveImageToLocalState(username, "", User::kProfileImageIndex, false);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 LocalStateChanged(this)); 693 LocalStateChanged(this));
649 } 694 }
650 695
651 FilePath UserManagerImpl::GetImagePathForUser(const std::string& username) { 696 FilePath UserManagerImpl::GetImagePathForUser(const std::string& username) {
652 std::string filename = username + ".png"; 697 std::string filename = username + ".png";
653 FilePath user_data_dir; 698 FilePath user_data_dir;
654 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 699 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
655 return user_data_dir.AppendASCII(filename); 700 return user_data_dir.AppendASCII(filename);
656 } 701 }
657 702
703 FilePath UserManagerImpl::GetWallpaperPathForUser(const std::string& username,
704 bool is_thumbnail) {
705 std::string filename = username +
706 (is_thumbnail ? "_wallpaper_thumb.png" : "_wallpaper.png");
707 FilePath user_data_dir;
708 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
709 return user_data_dir.AppendASCII(filename);
710 }
711
658 void UserManagerImpl::EnsureUsersLoaded() { 712 void UserManagerImpl::EnsureUsersLoaded() {
659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
660 if (!users_.empty()) 714 if (!users_.empty())
661 return; 715 return;
662 if (!g_browser_process) 716 if (!g_browser_process)
663 return; 717 return;
664 718
665 PrefService* local_state = g_browser_process->local_state(); 719 PrefService* local_state = g_browser_process->local_state();
666 const ListValue* prefs_users = 720 const ListValue* prefs_users =
667 local_state->GetList(UserManager::kLoggedInUsers); 721 local_state->GetList(UserManager::kLoggedInUsers);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 } 889 }
836 890
837 void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) { 891 void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) {
838 current_user_wallpaper_type_ = User::DEFAULT; 892 current_user_wallpaper_type_ = User::DEFAULT;
839 // TODO(bshe): Ideally, wallpaper should start to load as soon as user click 893 // TODO(bshe): Ideally, wallpaper should start to load as soon as user click
840 // "Add user". 894 // "Add user".
841 if (username == kGuestUser) 895 if (username == kGuestUser)
842 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex(); 896 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
843 else 897 else
844 current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex(); 898 current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
845
846 SaveUserWallpaperProperties(username, 899 SaveUserWallpaperProperties(username,
847 current_user_wallpaper_type_, 900 current_user_wallpaper_type_,
848 current_user_wallpaper_index_); 901 current_user_wallpaper_index_);
849 902
850 // Some browser tests do not have shell instance. And it is not necessary to 903 // Some browser tests do not have shell instance. And it is not necessary to
851 // create a wallpaper for these tests. Add HasInstance check to prevent tests 904 // create a wallpaper for these tests. Add HasInstance check to prevent tests
852 // crash and speed up the tests by avoid loading wallpaper. 905 // crash and speed up the tests by avoid loading wallpaper.
853 if (ash::Shell::HasInstance()) { 906 if (ash::Shell::HasInstance()) {
854 ash::Shell::GetInstance()->desktop_background_controller()-> 907 ash::Shell::GetInstance()->desktop_background_controller()->
855 SetDefaultWallpaper(current_user_wallpaper_index_); 908 SetDefaultWallpaper(current_user_wallpaper_index_);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 last_image_set_async_ = true; 1060 last_image_set_async_ = true;
1008 1061
1009 BrowserThread::PostTask( 1062 BrowserThread::PostTask(
1010 BrowserThread::FILE, 1063 BrowserThread::FILE,
1011 FROM_HERE, 1064 FROM_HERE,
1012 base::Bind(&UserManagerImpl::SaveImageToFile, 1065 base::Bind(&UserManagerImpl::SaveImageToFile,
1013 base::Unretained(this), 1066 base::Unretained(this),
1014 username, image, image_path, image_index)); 1067 username, image, image_path, image_index));
1015 } 1068 }
1016 1069
1070 void UserManagerImpl::SaveUserWallpaperInternal(const std::string& username,
1071 ash::WallpaperLayout layout,
1072 User::WallpaperType type,
1073 WallpaperDelegate* delegate,
1074 const SkBitmap& wallpaper) {
1075 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1076
1077 BrowserThread::PostTask(
1078 BrowserThread::FILE,
1079 FROM_HERE,
1080 base::Bind(&UserManagerImpl::GenerateUserWallpaperThumbnail,
1081 base::Unretained(this), username, type, delegate, wallpaper));
1082
1083 ash::Shell::GetInstance()->desktop_background_controller()->
1084 SetCustomWallpaper(wallpaper, layout);
1085
1086 // Ignore for ephemeral users.
1087 if (IsEphemeralUser(username))
1088 return;
1089
1090 FilePath wallpaper_path = GetWallpaperPathForUser(username, false);
1091 DVLOG(1) << "Saving user image to " << wallpaper_path.value();
1092
1093 last_image_set_async_ = true;
1094
1095 BrowserThread::PostTask(
1096 BrowserThread::FILE,
1097 FROM_HERE,
1098 base::Bind(&UserManagerImpl::SaveWallpaperToFile,
1099 base::Unretained(this), username, wallpaper, wallpaper_path,
1100 layout, User::CUSTOMIZED));
1101 }
1102
1103 void UserManagerImpl::LoadCustomWallpaperThumbnail(const std::string& email,
1104 ash::WallpaperLayout layout,
1105 const SkBitmap& wallpaper) {
1106 ash::Shell::GetInstance()->desktop_background_controller()->
1107 SetCustomWallpaper(wallpaper, layout);
1108 // Load wallpaper thumbnail
1109 std::string wallpaper_path = GetWallpaperPathForUser(email, true).value();
1110 image_loader_->Start(
1111 wallpaper_path, 0,
1112 base::Bind(&UserManagerImpl::OnCustomWallpaperThumbnailLoaded,
1113 base::Unretained(this), email));
1114 }
1115
1116 void UserManagerImpl::OnCustomWallpaperThumbnailLoaded(
1117 const std::string& email,
1118 const SkBitmap& wallpaper) {
1119 User* user = const_cast<User*>(FindUser(email));
1120 // User may have been removed by now.
1121 if (user && !wallpaper.empty())
1122 user->SetWallpaperThumbnail(wallpaper);
1123 }
1124
1125 void UserManagerImpl::OnThumbnailUpdated(WallpaperDelegate* delegate) {
1126 if (delegate)
1127 delegate->SetCustomWallpaperThumbnail();
1128 }
1129
1130 void UserManagerImpl::GenerateUserWallpaperThumbnail(
1131 const std::string& username,
1132 User::WallpaperType type,
1133 WallpaperDelegate* delegate,
1134 const SkBitmap& wallpaper) {
1135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
1136 SkBitmap thumbnail =
1137 skia::ImageOperations::Resize(wallpaper,
1138 skia::ImageOperations::RESIZE_LANCZOS3,
1139 kThumbnailWidth, kThumbnailHeight);
1140 logged_in_user_->SetWallpaperThumbnail(thumbnail);
1141
1142 // Notify thumbnail is ready.
1143 BrowserThread::PostTask(
1144 BrowserThread::UI,
1145 FROM_HERE,
1146 base::Bind(&UserManagerImpl::OnThumbnailUpdated,
1147 base::Unretained(this), delegate));
1148
1149 // Ignore for ephemeral users.
1150 if (IsEphemeralUser(username))
1151 return;
1152
1153 FilePath thumbnail_path = GetWallpaperPathForUser(username, true);
1154 SaveBitmapToFile(thumbnail, thumbnail_path);
1155 }
1156
1017 void UserManagerImpl::SaveImageToFile(const std::string& username, 1157 void UserManagerImpl::SaveImageToFile(const std::string& username,
1018 const SkBitmap& image, 1158 const SkBitmap& image,
1019 const FilePath& image_path, 1159 const FilePath& image_path,
1020 int image_index) { 1160 int image_index) {
1021 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 1161 if (!SaveBitmapToFile(image, image_path))
1022
1023 std::vector<unsigned char> encoded_image;
1024 if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, false, &encoded_image)) {
1025 LOG(ERROR) << "Failed to PNG encode the image.";
1026 return; 1162 return;
1027 }
1028
1029 if (file_util::WriteFile(image_path,
1030 reinterpret_cast<char*>(&encoded_image[0]),
1031 encoded_image.size()) == -1) {
1032 LOG(ERROR) << "Failed to save image to file.";
1033 return;
1034 }
1035 1163
1036 BrowserThread::PostTask( 1164 BrowserThread::PostTask(
1037 BrowserThread::UI, 1165 BrowserThread::UI,
1038 FROM_HERE, 1166 FROM_HERE,
1039 base::Bind(&UserManagerImpl::SaveImageToLocalState, 1167 base::Bind(&UserManagerImpl::SaveImageToLocalState,
1040 base::Unretained(this), 1168 base::Unretained(this),
1041 username, image_path.value(), image_index, true)); 1169 username, image_path.value(), image_index, true));
1042 } 1170 }
1043 1171
1172 void UserManagerImpl::SaveWallpaperToFile(const std::string& username,
1173 const SkBitmap& wallpaper,
1174 const FilePath& wallpaper_path,
1175 ash::WallpaperLayout layout,
1176 User::WallpaperType type) {
1177 // TODO(bshe): We should save the original file unchanged instead of
1178 // re-encoding it and saving it.
1179 if (!SaveBitmapToFile(wallpaper, wallpaper_path))
1180 return;
1181
1182 BrowserThread::PostTask(
1183 BrowserThread::UI,
1184 FROM_HERE,
1185 base::Bind(&UserManagerImpl::SaveWallpaperToLocalState,
1186 base::Unretained(this),
1187 username, wallpaper_path.value(), layout, type));
1188 }
1189
1044 void UserManagerImpl::SaveImageToLocalState(const std::string& username, 1190 void UserManagerImpl::SaveImageToLocalState(const std::string& username,
1045 const std::string& image_path, 1191 const std::string& image_path,
1046 int image_index, 1192 int image_index,
1047 bool is_async) { 1193 bool is_async) {
1048 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1049 1195
1050 // Ignore for ephemeral users. 1196 // Ignore for ephemeral users.
1051 if (IsEphemeralUser(username)) 1197 if (IsEphemeralUser(username))
1052 return; 1198 return;
1053 1199
(...skipping 13 matching lines...) Expand all
1067 base::DictionaryValue* image_properties = new base::DictionaryValue(); 1213 base::DictionaryValue* image_properties = new base::DictionaryValue();
1068 image_properties->Set(kImagePathNodeName, new StringValue(image_path)); 1214 image_properties->Set(kImagePathNodeName, new StringValue(image_path));
1069 image_properties->Set(kImageIndexNodeName, 1215 image_properties->Set(kImageIndexNodeName,
1070 new base::FundamentalValue(image_index)); 1216 new base::FundamentalValue(image_index));
1071 images_update->SetWithoutPathExpansion(username, image_properties); 1217 images_update->SetWithoutPathExpansion(username, image_properties);
1072 DVLOG(1) << "Saving path to user image in Local State."; 1218 DVLOG(1) << "Saving path to user image in Local State.";
1073 1219
1074 NotifyLocalStateChanged(); 1220 NotifyLocalStateChanged();
1075 } 1221 }
1076 1222
1223 void UserManagerImpl::SaveWallpaperToLocalState(const std::string& username,
1224 const std::string& wallpaper_path,
1225 ash::WallpaperLayout layout,
1226 User::WallpaperType type) {
1227 // TODO(bshe): We probably need to save wallpaper_path instead of index.
1228 SaveUserWallpaperProperties(username, type, layout);
1229 }
1230
1231 bool UserManagerImpl::SaveBitmapToFile(const SkBitmap& image,
1232 const FilePath& image_path) {
1233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
1234
1235 std::vector<unsigned char> encoded_image;
1236 if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, false, &encoded_image)) {
1237 LOG(ERROR) << "Failed to PNG encode the image.";
1238 return false;
1239 }
1240
1241 if (file_util::WriteFile(image_path,
1242 reinterpret_cast<char*>(&encoded_image[0]),
1243 encoded_image.size()) == -1) {
1244 LOG(ERROR) << "Failed to save image to file.";
1245 return false;
1246 }
1247 return true;
1248 }
1249
1077 void UserManagerImpl::InitDownloadedProfileImage() { 1250 void UserManagerImpl::InitDownloadedProfileImage() {
1078 DCHECK(logged_in_user_); 1251 DCHECK(logged_in_user_);
1079 if (downloaded_profile_image_.empty() && !logged_in_user_->image_is_stub()) { 1252 if (downloaded_profile_image_.empty() && !logged_in_user_->image_is_stub()) {
1080 VLOG(1) << "Profile image initialized"; 1253 VLOG(1) << "Profile image initialized";
1081 downloaded_profile_image_ = logged_in_user_->image(); 1254 downloaded_profile_image_ = logged_in_user_->image();
1082 downloaded_profile_image_data_url_ = 1255 downloaded_profile_image_data_url_ =
1083 web_ui_util::GetImageDataUrl(downloaded_profile_image_); 1256 web_ui_util::GetImageDataUrl(downloaded_profile_image_);
1084 } 1257 }
1085 } 1258 }
1086 1259
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 if (email != user_email) 1386 if (email != user_email)
1214 prefs_users_update->Append(Value::CreateStringValue(user_email)); 1387 prefs_users_update->Append(Value::CreateStringValue(user_email));
1215 else 1388 else
1216 user_to_remove = it; 1389 user_to_remove = it;
1217 } 1390 }
1218 1391
1219 DictionaryPrefUpdate prefs_wallpapers_update(prefs, 1392 DictionaryPrefUpdate prefs_wallpapers_update(prefs,
1220 kUserWallpapersProperties); 1393 kUserWallpapersProperties);
1221 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); 1394 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL);
1222 1395
1396 // Remove user wallpaper thumbnail
1397 FilePath wallpaper_thumb_path = GetWallpaperPathForUser(email, true);
1398 BrowserThread::PostTask(
1399 BrowserThread::FILE,
1400 FROM_HERE,
1401 base::Bind(&UserManagerImpl::DeleteUserImage,
1402 base::Unretained(this),
1403 wallpaper_thumb_path));
1404 // Remove user wallpaper
1405 FilePath wallpaper_path = GetWallpaperPathForUser(email, false);
1406 BrowserThread::PostTask(
1407 BrowserThread::FILE,
1408 FROM_HERE,
1409 base::Bind(&UserManagerImpl::DeleteUserImage,
1410 base::Unretained(this),
1411 wallpaper_path));
1412
1223 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); 1413 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
1224 std::string image_path_string; 1414 std::string image_path_string;
1225 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); 1415 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
1226 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); 1416 prefs_images_update->RemoveWithoutPathExpansion(email, NULL);
1227 1417
1228 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); 1418 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
1229 int oauth_status; 1419 int oauth_status;
1230 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); 1420 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status);
1231 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); 1421 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL);
1232 1422
(...skipping 13 matching lines...) Expand all
1246 BrowserThread::PostTask( 1436 BrowserThread::PostTask(
1247 BrowserThread::FILE, 1437 BrowserThread::FILE,
1248 FROM_HERE, 1438 FROM_HERE,
1249 base::Bind(&UserManagerImpl::DeleteUserImage, 1439 base::Bind(&UserManagerImpl::DeleteUserImage,
1250 base::Unretained(this), 1440 base::Unretained(this),
1251 image_path)); 1441 image_path));
1252 } 1442 }
1253 } 1443 }
1254 1444
1255 } // namespace chromeos 1445 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698