| 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/shell.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" |
| 11 #include "ash/desktop_background/desktop_background_resources.h" |
| 9 #include "base/bind.h" | 12 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 12 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 13 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 14 #include "base/logging.h" | 17 #include "base/logging.h" |
| 15 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 16 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 17 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 18 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 base::Bind(&UserManagerImpl::CheckOwnership, | 885 base::Bind(&UserManagerImpl::CheckOwnership, |
| 883 base::Unretained(this))); | 886 base::Unretained(this))); |
| 884 } | 887 } |
| 885 | 888 |
| 886 void UserManagerImpl::SetInitialUserImage(const std::string& username) { | 889 void UserManagerImpl::SetInitialUserImage(const std::string& username) { |
| 887 // Choose a random default image. | 890 // Choose a random default image. |
| 888 int image_id = base::RandInt(0, kDefaultImagesCount - 1); | 891 int image_id = base::RandInt(0, kDefaultImagesCount - 1); |
| 889 SaveUserDefaultImageIndex(username, image_id); | 892 SaveUserDefaultImageIndex(username, image_id); |
| 890 } | 893 } |
| 891 | 894 |
| 895 int UserManagerImpl::GetUserWallpaper(const std::string& username) { |
| 896 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 897 |
| 898 PrefService* local_state = g_browser_process->local_state(); |
| 899 const DictionaryValue* user_wallpapers = |
| 900 local_state->GetDictionary(UserManager::kUserWallpapers); |
| 901 int index = ash::GetDefaultWallpaperIndex(); |
| 902 user_wallpapers->GetIntegerWithoutPathExpansion(username, |
| 903 &index); |
| 904 return index; |
| 905 } |
| 906 |
| 907 void UserManagerImpl::SaveWallpaperDefaultIndex(const std::string& username, |
| 908 int wallpaper_index) { |
| 909 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 910 |
| 911 PrefService* local_state = g_browser_process->local_state(); |
| 912 DictionaryPrefUpdate wallpapers_update(local_state, |
| 913 UserManager::kUserWallpapers); |
| 914 wallpapers_update->SetWithoutPathExpansion(username, |
| 915 new base::FundamentalValue(wallpaper_index)); |
| 916 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 917 OnDesktopBackgroundChanged(wallpaper_index); |
| 918 } |
| 919 |
| 892 void UserManagerImpl::SetUserImage(const std::string& username, | 920 void UserManagerImpl::SetUserImage(const std::string& username, |
| 893 int image_index, | 921 int image_index, |
| 894 const SkBitmap& image) { | 922 const SkBitmap& image) { |
| 895 User* user = const_cast<User*>(FindUser(username)); | 923 User* user = const_cast<User*>(FindUser(username)); |
| 896 // User may have been removed by now. | 924 // User may have been removed by now. |
| 897 if (user) { | 925 if (user) { |
| 898 // For existing users, a valid image index should have been set upon loading | 926 // For existing users, a valid image index should have been set upon loading |
| 899 // them from Local State. | 927 // them from Local State. |
| 900 DCHECK(user->image_index() != User::kInvalidImageIndex || | 928 DCHECK(user->image_index() != User::kInvalidImageIndex || |
| 901 is_current_user_new_); | 929 is_current_user_new_); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 UserList::iterator user_to_remove = users_.end(); | 1166 UserList::iterator user_to_remove = users_.end(); |
| 1139 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { | 1167 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
| 1140 std::string user_email = (*it)->email(); | 1168 std::string user_email = (*it)->email(); |
| 1141 // Skip user that we would like to delete. | 1169 // Skip user that we would like to delete. |
| 1142 if (email != user_email) | 1170 if (email != user_email) |
| 1143 prefs_users_update->Append(Value::CreateStringValue(user_email)); | 1171 prefs_users_update->Append(Value::CreateStringValue(user_email)); |
| 1144 else | 1172 else |
| 1145 user_to_remove = it; | 1173 user_to_remove = it; |
| 1146 } | 1174 } |
| 1147 | 1175 |
| 1176 DictionaryPrefUpdate prefs_wallpapers_update(prefs, |
| 1177 kUserWallpapers); |
| 1178 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); |
| 1179 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); |
| 1180 |
| 1148 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); | 1181 DictionaryPrefUpdate prefs_images_update(prefs, kUserImages); |
| 1149 std::string image_path_string; | 1182 std::string image_path_string; |
| 1150 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); | 1183 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); |
| 1151 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); | 1184 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); |
| 1152 | 1185 |
| 1153 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); | 1186 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); |
| 1154 int oauth_status; | 1187 int oauth_status; |
| 1155 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 1188 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
| 1156 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); | 1189 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); |
| 1157 | 1190 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1171 BrowserThread::PostTask( | 1204 BrowserThread::PostTask( |
| 1172 BrowserThread::FILE, | 1205 BrowserThread::FILE, |
| 1173 FROM_HERE, | 1206 FROM_HERE, |
| 1174 base::Bind(&UserManagerImpl::DeleteUserImage, | 1207 base::Bind(&UserManagerImpl::DeleteUserImage, |
| 1175 base::Unretained(this), | 1208 base::Unretained(this), |
| 1176 image_path)); | 1209 image_path)); |
| 1177 } | 1210 } |
| 1178 } | 1211 } |
| 1179 | 1212 |
| 1180 } // namespace chromeos | 1213 } // namespace chromeos |
| OLD | NEW |