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/desktop_background/desktop_background_resources.h" | |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/file_path.h" | 13 #include "base/file_path.h" |
13 #include "base/file_util.h" | 14 #include "base/file_util.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/rand_util.h" | 19 #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(); | 432 UserList::iterator user_to_remove = users_.end(); |
432 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { | 433 for (UserList::iterator it = users_.begin(); it != users_.end(); ++it) { |
433 std::string user_email = (*it)->email(); | 434 std::string user_email = (*it)->email(); |
434 // Skip user that we would like to delete. | 435 // Skip user that we would like to delete. |
435 if (email != user_email) | 436 if (email != user_email) |
436 prefs_users_update->Append(Value::CreateStringValue(user_email)); | 437 prefs_users_update->Append(Value::CreateStringValue(user_email)); |
437 else | 438 else |
438 user_to_remove = it; | 439 user_to_remove = it; |
439 } | 440 } |
440 | 441 |
442 DictionaryPrefUpdate prefs_wallpapers_update(prefs, | |
443 UserManager::kUserWallpapers); | |
444 prefs_wallpapers_update->RemoveWithoutPathExpansion(email, NULL); | |
445 | |
441 DictionaryPrefUpdate prefs_images_update(prefs, UserManager::kUserImages); | 446 DictionaryPrefUpdate prefs_images_update(prefs, UserManager::kUserImages); |
442 std::string image_path_string; | 447 std::string image_path_string; |
443 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); | 448 prefs_images_update->GetStringWithoutPathExpansion(email, &image_path_string); |
444 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); | 449 prefs_images_update->RemoveWithoutPathExpansion(email, NULL); |
445 | 450 |
446 DictionaryPrefUpdate prefs_oauth_update(prefs, | 451 DictionaryPrefUpdate prefs_oauth_update(prefs, |
447 UserManager::kUserOAuthTokenStatus); | 452 UserManager::kUserOAuthTokenStatus); |
448 int oauth_status; | 453 int oauth_status; |
449 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 454 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
450 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); | 455 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
830 base::Bind(&UserManagerImpl::CheckOwnership, | 835 base::Bind(&UserManagerImpl::CheckOwnership, |
831 base::Unretained(this))); | 836 base::Unretained(this))); |
832 } | 837 } |
833 | 838 |
834 void UserManagerImpl::SetInitialUserImage(const std::string& username) { | 839 void UserManagerImpl::SetInitialUserImage(const std::string& username) { |
835 // Choose a random default image. | 840 // Choose a random default image. |
836 int image_id = base::RandInt(0, kDefaultImagesCount - 1); | 841 int image_id = base::RandInt(0, kDefaultImagesCount - 1); |
837 SaveUserDefaultImageIndex(username, image_id); | 842 SaveUserDefaultImageIndex(username, image_id); |
838 } | 843 } |
839 | 844 |
845 int UserManagerImpl::GetUserWallpaper(const std::string& username) { | |
846 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
847 | |
848 PrefService* local_state = g_browser_process->local_state(); | |
849 const DictionaryValue* user_wallpapers = | |
850 local_state->GetDictionary(UserManager::kUserWallpapers); | |
851 int index = ash::GetPresetWallpaperIndex(); | |
852 user_wallpapers->GetIntegerWithoutPathExpansion(username, | |
853 &index); | |
854 return index; | |
855 } | |
856 | |
857 void UserManagerImpl::SaveWallpaperDefaultIndex(const std::string& username, | |
858 int wallpaper_index) { | |
859 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
860 | |
861 PrefService* local_state = g_browser_process->local_state(); | |
862 DictionaryPrefUpdate wallpapers_update(local_state, | |
863 UserManager::kUserWallpapers); | |
864 wallpapers_update->SetWithoutPathExpansion(username, | |
865 new base::FundamentalValue(wallpaper_index)); | |
866 content::NotificationService::current()->Notify( | |
867 chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED, | |
Ben Goodger (Google)
2012/03/09 23:20:17
can you not use notifications for this at all... r
bshe
2012/03/12 00:14:25
Done.
| |
868 content::Source<UserManagerImpl>(this), | |
869 content::Details<int>(&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 |