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

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

Issue 10384079: Reland "Implement random wallpaper feature" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
11 #include "ash/desktop_background/desktop_background_resources.h"
12 #include "base/bind.h" 11 #include "base/bind.h"
13 #include "base/chromeos/chromeos_version.h" 12 #include "base/chromeos/chromeos_version.h"
14 #include "base/command_line.h" 13 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
16 #include "base/file_path.h" 15 #include "base/file_path.h"
17 #include "base/file_util.h" 16 #include "base/file_util.h"
18 #include "base/logging.h" 17 #include "base/logging.h"
19 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
20 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
21 #include "base/path_service.h" 20 #include "base/path_service.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // depends on that and it's hard to figure out what). 69 // depends on that and it's hard to figure out what).
71 const char kGuestUser[] = ""; 70 const char kGuestUser[] = "";
72 71
73 // Stub user email (for test paths). 72 // Stub user email (for test paths).
74 const char kStubUser[] = "stub-user@example.com"; 73 const char kStubUser[] = "stub-user@example.com";
75 74
76 // Names of nodes with info about user image. 75 // Names of nodes with info about user image.
77 const char kImagePathNodeName[] = "path"; 76 const char kImagePathNodeName[] = "path";
78 const char kImageIndexNodeName[] = "index"; 77 const char kImageIndexNodeName[] = "index";
79 78
79 const char kWallpaperTypeNodeName[] = "type";
80 const char kWallpaperIndexNodeName[] = "index";
81
80 // Index of the default image used for the |kStubUser| user. 82 // Index of the default image used for the |kStubUser| user.
81 const int kStubDefaultImageIndex = 0; 83 const int kStubDefaultImageIndex = 0;
82 84
83 // 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.
84 const long kProfileImageDownloadDelayMs = 10000; 86 const long kProfileImageDownloadDelayMs = 10000;
85 87
86 // Enum for reporting histograms about profile picture download. 88 // Enum for reporting histograms about profile picture download.
87 enum ProfileDownloadResult { 89 enum ProfileDownloadResult {
88 kDownloadSuccessChanged, 90 kDownloadSuccessChanged,
89 kDownloadSuccess, 91 kDownloadSuccess,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // If we're not running on ChromeOS, and are not showing the login manager 300 // If we're not running on ChromeOS, and are not showing the login manager
299 // or attempting a command line login? Then login the stub user. 301 // or attempting a command line login? Then login the stub user.
300 CommandLine* command_line = CommandLine::ForCurrentProcess(); 302 CommandLine* command_line = CommandLine::ForCurrentProcess();
301 if (!base::chromeos::IsRunningOnChromeOS() && 303 if (!base::chromeos::IsRunningOnChromeOS() &&
302 !command_line->HasSwitch(switches::kLoginManager) && 304 !command_line->HasSwitch(switches::kLoginManager) &&
303 !command_line->HasSwitch(switches::kLoginPassword) && 305 !command_line->HasSwitch(switches::kLoginPassword) &&
304 !command_line->HasSwitch(switches::kGuestSession)) { 306 !command_line->HasSwitch(switches::kGuestSession)) {
305 StubUserLoggedIn(); 307 StubUserLoggedIn();
306 } 308 }
307 309
310 MigrateWallpaperData();
311
308 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 312 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
309 content::NotificationService::AllSources()); 313 content::NotificationService::AllSources());
310 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, 314 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
311 content::NotificationService::AllSources()); 315 content::NotificationService::AllSources());
312 RetrieveTrustedDevicePolicies(); 316 RetrieveTrustedDevicePolicies();
313 } 317 }
314 318
315 UserManagerImpl::~UserManagerImpl() { 319 UserManagerImpl::~UserManagerImpl() {
316 // Can't use STLDeleteElements because of the private destructor of User. 320 // Can't use STLDeleteElements because of the private destructor of User.
317 for (size_t i = 0; i < users_.size();++i) 321 for (size_t i = 0; i < users_.size();++i)
318 delete users_[i]; 322 delete users_[i];
319 users_.clear(); 323 users_.clear();
320 if (is_current_user_ephemeral_) 324 if (is_current_user_ephemeral_)
321 delete logged_in_user_; 325 delete logged_in_user_;
322 } 326 }
323 327
324 const UserList& UserManagerImpl::GetUsers() const { 328 const UserList& UserManagerImpl::GetUsers() const {
325 const_cast<UserManagerImpl*>(this)->EnsureUsersLoaded(); 329 const_cast<UserManagerImpl*>(this)->EnsureUsersLoaded();
326 return users_; 330 return users_;
327 } 331 }
328 332
329 void UserManagerImpl::UserLoggedIn(const std::string& email) { 333 void UserManagerImpl::UserLoggedIn(const std::string& email) {
330 // Get a random wallpaper each time a user logged in.
331 current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
332
333 // Remove the stub user if it is still around. 334 // Remove the stub user if it is still around.
334 if (logged_in_user_) { 335 if (logged_in_user_) {
335 DCHECK(IsLoggedInAsStub()); 336 DCHECK(IsLoggedInAsStub());
336 delete logged_in_user_; 337 delete logged_in_user_;
337 logged_in_user_ = NULL; 338 logged_in_user_ = NULL;
338 is_current_user_ephemeral_ = false; 339 is_current_user_ephemeral_ = false;
339 } 340 }
340 341
341 if (email == kGuestUser) { 342 if (email == kGuestUser) {
342 GuestUserLoggedIn(); 343 GuestUserLoggedIn();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 is_current_user_new_ = true; 423 is_current_user_new_ = true;
423 is_current_user_ephemeral_ = true; 424 is_current_user_ephemeral_ = true;
424 logged_in_user_ = new User(kDemoUser, false); 425 logged_in_user_ = new User(kDemoUser, false);
425 SetInitialUserImage(kDemoUser); 426 SetInitialUserImage(kDemoUser);
426 SetInitialUserWallpaper(kDemoUser); 427 SetInitialUserWallpaper(kDemoUser);
427 NotifyOnLogin(); 428 NotifyOnLogin();
428 } 429 }
429 430
430 void UserManagerImpl::GuestUserLoggedIn() { 431 void UserManagerImpl::GuestUserLoggedIn() {
431 is_current_user_ephemeral_ = true; 432 is_current_user_ephemeral_ = true;
432 // Guest user always uses the same wallpaper.
433 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
434 logged_in_user_ = new User(kGuestUser, true); 433 logged_in_user_ = new User(kGuestUser, true);
435 NotifyOnLogin(); 434 NotifyOnLogin();
436 } 435 }
437 436
438 void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) { 437 void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) {
439 is_current_user_new_ = true; 438 is_current_user_new_ = true;
440 is_current_user_ephemeral_ = true; 439 is_current_user_ephemeral_ = true;
441 logged_in_user_ = CreateUser(email); 440 logged_in_user_ = CreateUser(email);
442 SetInitialUserImage(email); 441 SetInitialUserImage(email);
443 SetInitialUserWallpaper(email); 442 SetInitialUserWallpaper(email);
444 NotifyOnLogin(); 443 NotifyOnLogin();
445 } 444 }
446 445
447 void UserManagerImpl::StubUserLoggedIn() { 446 void UserManagerImpl::StubUserLoggedIn() {
448 is_current_user_ephemeral_ = true; 447 is_current_user_ephemeral_ = true;
449 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
450 logged_in_user_ = new User(kStubUser, false); 448 logged_in_user_ = new User(kStubUser, false);
451 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex), 449 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex),
452 kStubDefaultImageIndex); 450 kStubDefaultImageIndex);
453 } 451 }
454 452
455 void UserManagerImpl::UserSelected(const std::string& email) { 453 void UserManagerImpl::UserSelected(const std::string& email) {
456 if (IsKnownUser(email)) { 454 if (IsKnownUser(email)) {
455 int index;
456 User::WallpaperType type;
457 GetUserWallpaperProperties(email, type, index);
458 if (type == User::RANDOM) {
459 // Generate a new random wallpaper index if the selected user chose
460 // RANDOM wallpaper.
461 index = ash::GetRandomWallpaperIndex();
462 SaveUserWallpaperProperties(email, User::RANDOM, index);
463 }
457 ash::Shell::GetInstance()->desktop_background_controller()-> 464 ash::Shell::GetInstance()->desktop_background_controller()->
458 SetDefaultWallpaper(FindUserWallpaperIndex(email)); 465 SetDefaultWallpaper(index);
459 } 466 }
460 } 467 }
461 468
462 void UserManagerImpl::SessionStarted() { 469 void UserManagerImpl::SessionStarted() {
463 session_started_ = true; 470 session_started_ = true;
464 content::NotificationService::current()->Notify( 471 content::NotificationService::current()->Notify(
465 chrome::NOTIFICATION_SESSION_STARTED, 472 chrome::NOTIFICATION_SESSION_STARTED,
466 content::NotificationService::AllSources(), 473 content::NotificationService::AllSources(),
467 content::NotificationService::NoDetails()); 474 content::NotificationService::NoDetails());
468 } 475 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 905
899 const User* UserManagerImpl::FindUserInList(const std::string& email) const { 906 const User* UserManagerImpl::FindUserInList(const std::string& email) const {
900 const UserList& users = GetUsers(); 907 const UserList& users = GetUsers();
901 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 908 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
902 if ((*it)->email() == email) 909 if ((*it)->email() == email)
903 return *it; 910 return *it;
904 } 911 }
905 return NULL; 912 return NULL;
906 } 913 }
907 914
908 int UserManagerImpl::FindUserWallpaperIndex(const std::string& email) {
909 PrefService* local_state = g_browser_process->local_state();
910 const DictionaryValue* user_wallpapers =
911 local_state->GetDictionary(UserManager::kUserWallpapers);
912 int index;
913 if (!user_wallpapers->GetIntegerWithoutPathExpansion(email, &index))
914 index = current_user_wallpaper_index_;
915 if (index < 0 || index >= ash::GetWallpaperCount()) {
916 index = ash::GetDefaultWallpaperIndex();
917 SaveUserWallpaperIndex(index);
918 }
919 return index;
920 }
921
922 void UserManagerImpl::NotifyOnLogin() { 915 void UserManagerImpl::NotifyOnLogin() {
923 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 916 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
924 content::NotificationService::current()->Notify( 917 content::NotificationService::current()->Notify(
925 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 918 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
926 content::Source<UserManagerImpl>(this), 919 content::Source<UserManagerImpl>(this),
927 content::Details<const User>(logged_in_user_)); 920 content::Details<const User>(logged_in_user_));
928 921
929 LoadKeyStore(); 922 LoadKeyStore();
930 923
931 // Schedules current user ownership check on file thread. 924 // Schedules current user ownership check on file thread.
(...skipping 29 matching lines...) Expand all
961 key_store_loaded_ = true; 954 key_store_loaded_ = true;
962 } 955 }
963 956
964 void UserManagerImpl::SetInitialUserImage(const std::string& username) { 957 void UserManagerImpl::SetInitialUserImage(const std::string& username) {
965 // Choose a random default image. 958 // Choose a random default image.
966 int image_id = base::RandInt(0, kDefaultImagesCount - 1); 959 int image_id = base::RandInt(0, kDefaultImagesCount - 1);
967 SaveUserDefaultImageIndex(username, image_id); 960 SaveUserDefaultImageIndex(username, image_id);
968 } 961 }
969 962
970 void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) { 963 void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) {
964 current_user_wallpaper_type_ = User::DEFAULT;
971 // TODO(bshe): Ideally, wallpaper should start to load as soon as user click 965 // TODO(bshe): Ideally, wallpaper should start to load as soon as user click
972 // "Add user". 966 // "Add user".
973 if (username == kGuestUser) 967 if (username == kGuestUser)
974 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex(); 968 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
975 else 969 else
976 current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex(); 970 current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
977 SaveUserWallpaperIndex(current_user_wallpaper_index_); 971
972 SaveUserWallpaperProperties(username,
973 current_user_wallpaper_type_,
974 current_user_wallpaper_index_);
975
978 // Some browser tests do not have shell instance. And it is not necessary to 976 // Some browser tests do not have shell instance. And it is not necessary to
979 // create a wallpaper for these tests. Add HasInstance check to prevent tests 977 // create a wallpaper for these tests. Add HasInstance check to prevent tests
980 // crash and speed up the tests by avoid loading wallpaper. 978 // crash and speed up the tests by avoid loading wallpaper.
981 if (ash::Shell::HasInstance()) { 979 if (ash::Shell::HasInstance()) {
982 ash::Shell::GetInstance()->desktop_background_controller()-> 980 ash::Shell::GetInstance()->desktop_background_controller()->
983 SetDefaultWallpaper(current_user_wallpaper_index_); 981 SetDefaultWallpaper(current_user_wallpaper_index_);
984 } 982 }
985 } 983 }
986 984
987 int UserManagerImpl::GetUserWallpaperIndex() { 985 void UserManagerImpl::MigrateWallpaperData() {
986 PrefService* local_state = g_browser_process->local_state();
987 if (local_state) {
988 const DictionaryValue* user_wallpapers =
989 local_state->GetDictionary(kUserWallpapers);
990 int index;
991 if (user_wallpapers) {
992 const UserList& users = GetUsers();
993 for (UserList::const_iterator it = users.begin();
994 it != users.end();
995 ++it) {
996 std::string username = (*it)->email();
997 if (user_wallpapers->GetIntegerWithoutPathExpansion((username),
998 &index)) {
999 DictionaryPrefUpdate prefs_wallpapers_update(local_state,
1000 kUserWallpapers);
1001 prefs_wallpapers_update->RemoveWithoutPathExpansion(username, NULL);
1002 SaveUserWallpaperProperties(username, User::DEFAULT, index);
1003 }
1004 }
1005 }
1006 }
1007 }
1008
1009 int UserManagerImpl::GetLoggedInUserWallpaperIndex() {
1010 int index;
1011 User::WallpaperType type;
1012 GetLoggedInUserWallpaperProperties(type, index);
1013 return index;
1014 }
1015
1016 void UserManagerImpl::GetLoggedInUserWallpaperProperties(
1017 User::WallpaperType& type, int& index) {
988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1018 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
989 1019
990 // If at login screen, use an invalid index to prevent any wallpaper 1020 if (!IsUserLoggedIn() || IsLoggedInAsStub()) {
991 // operation. 1021 index = ash::GetInvalidWallpaperIndex();
992 if (!IsUserLoggedIn() || IsLoggedInAsStub()) 1022 current_user_wallpaper_index_ = index;
993 return ash::GetInvalidWallpaperIndex(); 1023 current_user_wallpaper_type_ = User::DEFAULT;
1024 return;
1025 }
1026
994 // If logged in as other ephemeral users (Demo/Stub/Normal user with 1027 // If logged in as other ephemeral users (Demo/Stub/Normal user with
995 // ephemeral policy enabled/Guest), use the index in memory. 1028 // ephemeral policy enabled/Guest), use the index in memory.
996 if (IsCurrentUserEphemeral()) 1029 if (IsCurrentUserEphemeral()) {
997 return current_user_wallpaper_index_; 1030 type = current_user_wallpaper_type_;
1031 index = current_user_wallpaper_index_;
1032 return;
1033 }
998 1034
999 const chromeos::User& user = GetLoggedInUser(); 1035 const chromeos::User& user = GetLoggedInUser();
1000 std::string username = user.email(); 1036 std::string username = user.email();
1001 DCHECK(!username.empty()); 1037 DCHECK(!username.empty());
1002 return FindUserWallpaperIndex(username); 1038
1039 GetUserWallpaperProperties(username, type, index);
1003 } 1040 }
1004 1041
1005 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) { 1042 void UserManagerImpl::SaveLoggedInUserWallpaperProperties(
1043 User::WallpaperType type, int index) {
1006 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1044 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1007 1045
1008 current_user_wallpaper_index_ = wallpaper_index; 1046 current_user_wallpaper_type_ = type;
1047 current_user_wallpaper_index_ = index;
1009 // Ephemeral users can not save data to local state. We just cache the index 1048 // Ephemeral users can not save data to local state. We just cache the index
1010 // in memory for them. 1049 // in memory for them.
1011 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) { 1050 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) {
1012 return; 1051 return;
1013 } 1052 }
1014 1053
1015 const chromeos::User& user = GetLoggedInUser(); 1054 const chromeos::User& user = GetLoggedInUser();
1016 std::string username = user.email(); 1055 std::string username = user.email();
1017 DCHECK(!username.empty()); 1056 DCHECK(!username.empty());
1018 1057
1019 PrefService* local_state = g_browser_process->local_state(); 1058 SaveUserWallpaperProperties(username, type, index);
1020 DictionaryPrefUpdate wallpapers_update(local_state,
1021 UserManager::kUserWallpapers);
1022 wallpapers_update->SetWithoutPathExpansion(username,
1023 new base::FundamentalValue(wallpaper_index));
1024 } 1059 }
1025 1060
1026 void UserManagerImpl::SetUserImage(const std::string& username, 1061 void UserManagerImpl::SetUserImage(const std::string& username,
1027 int image_index, 1062 int image_index,
1028 const SkBitmap& image) { 1063 const SkBitmap& image) {
1029 User* user = const_cast<User*>(FindUser(username)); 1064 User* user = const_cast<User*>(FindUser(username));
1030 // User may have been removed by now. 1065 // User may have been removed by now.
1031 if (user) { 1066 if (user) {
1032 // For existing users, a valid image index should have been set upon loading 1067 // For existing users, a valid image index should have been set upon loading
1033 // them from Local State. 1068 // them from Local State.
(...skipping 12 matching lines...) Expand all
1046 // Unless this is first-time setting with |SetInitialUserImage|, 1081 // Unless this is first-time setting with |SetInitialUserImage|,
1047 // send a notification about image change. 1082 // send a notification about image change.
1048 content::NotificationService::current()->Notify( 1083 content::NotificationService::current()->Notify(
1049 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 1084 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
1050 content::Source<UserManagerImpl>(this), 1085 content::Source<UserManagerImpl>(this),
1051 content::Details<const User>(user)); 1086 content::Details<const User>(user));
1052 } 1087 }
1053 } 1088 }
1054 } 1089 }
1055 1090
1091 void UserManagerImpl::GetUserWallpaperProperties(const std::string& username,
1092 User::WallpaperType& type,
1093 int& index) {
1094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1095
1096 PrefService* local_state = g_browser_process->local_state();
1097
1098 const DictionaryValue* user_wallpapers =
1099 local_state->GetDictionary(UserManager::kUserWallpapersProperties);
1100
1101 type = User::DEFAULT;
1102 index = ash::GetDefaultWallpaperIndex();
1103
1104 if (user_wallpapers) {
1105 base::DictionaryValue* wallpaper_properties;
1106 user_wallpapers->GetDictionaryWithoutPathExpansion(username,
1107 &wallpaper_properties);
1108 if (wallpaper_properties) {
1109 int saved_type = User::UNKNOWN;
1110 wallpaper_properties->GetInteger(kWallpaperTypeNodeName, &saved_type);
1111 type = static_cast<User::WallpaperType>(saved_type);
1112 wallpaper_properties->GetInteger(kWallpaperIndexNodeName, &index);
1113 }
1114 }
1115 }
1116
1117 void UserManagerImpl::SaveUserWallpaperProperties(const std::string& username,
1118 User::WallpaperType type,
1119 int index) {
1120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1121
1122 current_user_wallpaper_type_ = type;
1123 current_user_wallpaper_index_ = index;
1124 // Ephemeral users can not save data to local state. We just cache the index
1125 // in memory for them.
1126 if (IsCurrentUserEphemeral()) {
1127 return;
1128 }
1129
1130 PrefService* local_state = g_browser_process->local_state();
1131 DictionaryPrefUpdate wallpaper_update(local_state,
1132 UserManager::kUserWallpapersProperties);
1133
1134 base::DictionaryValue* wallpaper_properties = new base::DictionaryValue();
1135 wallpaper_properties->Set(kWallpaperTypeNodeName,
1136 new base::FundamentalValue(type));
1137 wallpaper_properties->Set(kWallpaperIndexNodeName,
1138 new base::FundamentalValue(index));
1139 wallpaper_update->SetWithoutPathExpansion(username, wallpaper_properties);
1140 }
1141
1056 void UserManagerImpl::SaveUserImageInternal(const std::string& username, 1142 void UserManagerImpl::SaveUserImageInternal(const std::string& username,
1057 int image_index, 1143 int image_index,
1058 const SkBitmap& image) { 1144 const SkBitmap& image) {
1059 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1060 1146
1061 SetUserImage(username, image_index, image); 1147 SetUserImage(username, image_index, image);
1062 1148
1063 // Ignore for ephemeral users. 1149 // Ignore for ephemeral users.
1064 if (IsEphemeralUser(username)) 1150 if (IsEphemeralUser(username))
1065 return; 1151 return;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { 1359 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) {
1274 std::string user_email = (*it)->email(); 1360 std::string user_email = (*it)->email();
1275 // Skip user that we would like to delete. 1361 // Skip user that we would like to delete.
1276 if (email != user_email) 1362 if (email != user_email)
1277 prefs_users_update->Append(Value::CreateStringValue(user_email)); 1363 prefs_users_update->Append(Value::CreateStringValue(user_email));
1278 else 1364 else
1279 user_to_remove = it; 1365 user_to_remove = it;
1280 } 1366 }
1281 1367
1282 DictionaryPrefUpdate prefs_wallpapers_update(prefs, 1368 DictionaryPrefUpdate prefs_wallpapers_update(prefs,
1283 kUserWallpapers); 1369 kUserWallpapersProperties);
1284 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); 1370 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL);
1285 1371
1286 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); 1372 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages);
1287 std::string image_path_string; 1373 std::string image_path_string;
1288 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); 1374 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string);
1289 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); 1375 prefs_images_update->RemoveWithoutPathExpansion(email, NULL);
1290 1376
1291 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); 1377 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus);
1292 int oauth_status; 1378 int oauth_status;
1293 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); 1379 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status);
(...skipping 15 matching lines...) Expand all
1309 BrowserThread::PostTask( 1395 BrowserThread::PostTask(
1310 BrowserThread::FILE, 1396 BrowserThread::FILE,
1311 FROM_HERE, 1397 FROM_HERE,
1312 base::Bind(&UserManagerImpl::DeleteUserImage, 1398 base::Bind(&UserManagerImpl::DeleteUserImage,
1313 base::Unretained(this), 1399 base::Unretained(this),
1314 image_path)); 1400 image_path));
1315 } 1401 }
1316 } 1402 }
1317 1403
1318 } // namespace chromeos 1404 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698