| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 UserList::iterator user_to_remove = users_.end(); | 434 UserList::iterator user_to_remove = users_.end(); |
| 432 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { | 435 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
| 433 std::string user_email = (*it)->email(); | 436 std::string user_email = (*it)->email(); |
| 434 // Skip user that we would like to delete. | 437 // Skip user that we would like to delete. |
| 435 if (email != user_email) | 438 if (email != user_email) |
| 436 prefs_users_update->Append(Value::CreateStringValue(user_email)); | 439 prefs_users_update->Append(Value::CreateStringValue(user_email)); |
| 437 else | 440 else |
| 438 user_to_remove = it; | 441 user_to_remove = it; |
| 439 } | 442 } |
| 440 | 443 |
| 444 DictionaryPrefUpdate prefs_wallpapers_update(prefs, |
| 445 UserManager::kUserWallpapers); |
| 446 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); |
| 447 |
| 441 DictionaryPrefUpdate prefs_images_update(prefs, UserManager::kUserImages); | 448 DictionaryPrefUpdate prefs_images_update(prefs, UserManager::kUserImages); |
| 442 std::string image_path_string; | 449 std::string image_path_string; |
| 443 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); | 450 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); |
| 444 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); | 451 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); |
| 445 | 452 |
| 446 DictionaryPrefUpdate prefs_oauth_update(prefs, | 453 DictionaryPrefUpdate prefs_oauth_update(prefs, |
| 447 UserManager::kUserOAuthTokenStatus); | 454 UserManager::kUserOAuthTokenStatus); |
| 448 int oauth_status; | 455 int oauth_status; |
| 449 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 456 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
| 450 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); | 457 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 base::Bind(&UserManagerImpl::CheckOwnership, | 837 base::Bind(&UserManagerImpl::CheckOwnership, |
| 831 base::Unretained(this))); | 838 base::Unretained(this))); |
| 832 } | 839 } |
| 833 | 840 |
| 834 void UserManagerImpl::SetInitialUserImage(const std::string& username) { | 841 void UserManagerImpl::SetInitialUserImage(const std::string& username) { |
| 835 // Choose a random default image. | 842 // Choose a random default image. |
| 836 int image_id = base::RandInt(0, kDefaultImagesCount - 1); | 843 int image_id = base::RandInt(0, kDefaultImagesCount - 1); |
| 837 SaveUserDefaultImageIndex(username, image_id); | 844 SaveUserDefaultImageIndex(username, image_id); |
| 838 } | 845 } |
| 839 | 846 |
| 847 int UserManagerImpl::GetUserWallpaper(const std::string& username) { |
| 848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 849 |
| 850 PrefService* local_state = g_browser_process->local_state(); |
| 851 const DictionaryValue* user_wallpapers = |
| 852 local_state->GetDictionary(UserManager::kUserWallpapers); |
| 853 int index = ash::GetDefaultWallpaperIndex(); |
| 854 user_wallpapers->GetIntegerWithoutPathExpansion(username, |
| 855 &index); |
| 856 return index; |
| 857 } |
| 858 |
| 859 void UserManagerImpl::SaveWallpaperDefaultIndex(const std::string& username, |
| 860 int wallpaper_index) { |
| 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 862 |
| 863 PrefService* local_state = g_browser_process->local_state(); |
| 864 DictionaryPrefUpdate wallpapers_update(local_state, |
| 865 UserManager::kUserWallpapers); |
| 866 wallpapers_update->SetWithoutPathExpansion(username, |
| 867 new base::FundamentalValue(wallpaper_index)); |
| 868 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 869 OnDesktopBackgroundChange(wallpaper_index); |
| 870 } |
| 871 |
| 840 void UserManagerImpl::SetUserImage(const std::string& username, | 872 void UserManagerImpl::SetUserImage(const std::string& username, |
| 841 int image_index, | 873 int image_index, |
| 842 const SkBitmap& image) { | 874 const SkBitmap& image) { |
| 843 User* user = const_cast<User*>(FindUser(username)); | 875 User* user = const_cast<User*>(FindUser(username)); |
| 844 // User may have been removed by now. | 876 // User may have been removed by now. |
| 845 if (user) { | 877 if (user) { |
| 846 // For existing users, a valid image index should have been set upon loading | 878 // For existing users, a valid image index should have been set upon loading |
| 847 // them from Local State. | 879 // them from Local State. |
| 848 DCHECK(user->image_index() != User::kInvalidImageIndex || | 880 DCHECK(user->image_index() != User::kInvalidImageIndex || |
| 849 is_current_user_new_); | 881 is_current_user_new_); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 | 1095 |
| 1064 User* UserManagerImpl::CreateUser(const std::string& email) const { | 1096 User* UserManagerImpl::CreateUser(const std::string& email) const { |
| 1065 User* user = new User(email, email == kGuestUser); | 1097 User* user = new User(email, email == kGuestUser); |
| 1066 user->set_oauth_token_status(LoadUserOAuthStatus(email)); | 1098 user->set_oauth_token_status(LoadUserOAuthStatus(email)); |
| 1067 // Used to determine whether user's display name is unique. | 1099 // Used to determine whether user's display name is unique. |
| 1068 ++display_name_count_[user->GetDisplayName()]; | 1100 ++display_name_count_[user->GetDisplayName()]; |
| 1069 return user; | 1101 return user; |
| 1070 } | 1102 } |
| 1071 | 1103 |
| 1072 } // namespace chromeos | 1104 } // namespace chromeos |
| OLD | NEW |