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

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

Issue 10207030: Asynchronously load wallpapers when user pod is selected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 441 }
442 442
443 void UserManagerImpl::StubUserLoggedIn() { 443 void UserManagerImpl::StubUserLoggedIn() {
444 is_current_user_ephemeral_ = true; 444 is_current_user_ephemeral_ = true;
445 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex(); 445 current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
446 logged_in_user_ = new User(kStubUser, false); 446 logged_in_user_ = new User(kStubUser, false);
447 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex), 447 logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex),
448 kStubDefaultImageIndex); 448 kStubDefaultImageIndex);
449 } 449 }
450 450
451 void UserManagerImpl::UserSelected(const std::string& email) {
452 if (email == kGuestUser) {
Nikita (slow) 2012/04/25 16:47:48 At this point we might ignore email == kGuestUser
bshe 2012/04/25 23:54:43 Done.
453 ash::Shell::GetInstance()->desktop_background_controller()->
454 SetGuestWallpaper();
455 } else if (IsKnownUser(email)) {
456 ash::Shell::GetInstance()->desktop_background_controller()->
457 SetDefaultWallpaper(FindUserWallpaperIndex(email));
458 }
459 }
460
451 void UserManagerImpl::RemoveUser(const std::string& email, 461 void UserManagerImpl::RemoveUser(const std::string& email,
452 RemoveUserDelegate* delegate) { 462 RemoveUserDelegate* delegate) {
453 if (!IsKnownUser(email)) 463 if (!IsKnownUser(email))
454 return; 464 return;
455 465
456 // Sanity check: we must not remove single user. This check may seem 466 // Sanity check: we must not remove single user. This check may seem
457 // redundant at a first sight because this single user must be an owner and 467 // redundant at a first sight because this single user must be an owner and
458 // we perform special check later in order not to remove an owner. However 468 // we perform special check later in order not to remove an owner. However
459 // due to non-instant nature of ownership assignment this later check may 469 // due to non-instant nature of ownership assignment this later check may
460 // sometimes fail. See http://crosbug.com/12723 470 // sometimes fail. See http://crosbug.com/12723
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 885
876 const User* UserManagerImpl::FindUserInList(const std::string& email) const { 886 const User* UserManagerImpl::FindUserInList(const std::string& email) const {
877 const UserList& users = GetUsers(); 887 const UserList& users = GetUsers();
878 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 888 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
879 if ((*it)->email() == email) 889 if ((*it)->email() == email)
880 return *it; 890 return *it;
881 } 891 }
882 return NULL; 892 return NULL;
883 } 893 }
884 894
895 int UserManagerImpl::FindUserWallpaperIndex(const std::string& email) {
896 PrefService* local_state = g_browser_process->local_state();
897 const DictionaryValue* user_wallpapers =
898 local_state->GetDictionary(UserManager::kUserWallpapers);
899 int index;
900 if (!user_wallpapers->GetIntegerWithoutPathExpansion(email, &index))
901 index = current_user_wallpaper_index_;
902 if (index < 0 || index >= ash::GetWallpaperCount()) {
903 index = ash::GetDefaultWallpaperIndex();
904 SaveUserWallpaperIndex(index);
905 }
906 return index;
907 }
908
885 void UserManagerImpl::NotifyOnLogin() { 909 void UserManagerImpl::NotifyOnLogin() {
886 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 910 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
887 content::NotificationService::current()->Notify( 911 content::NotificationService::current()->Notify(
888 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 912 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
889 content::Source<UserManagerImpl>(this), 913 content::Source<UserManagerImpl>(this),
890 content::Details<const User>(logged_in_user_)); 914 content::Details<const User>(logged_in_user_));
891 915
892 LoadKeyStore(); 916 LoadKeyStore();
893 917
894 // Schedules current user ownership check on file thread. 918 // Schedules current user ownership check on file thread.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 if (!IsUserLoggedIn()) 961 if (!IsUserLoggedIn())
938 return ash::GetGuestWallpaperIndex(); 962 return ash::GetGuestWallpaperIndex();
939 // If logged in as other ephemeral users (Demo/Stub/Normal user with 963 // If logged in as other ephemeral users (Demo/Stub/Normal user with
940 // ephemeral policy enabled/Guest), use the index in memory. 964 // ephemeral policy enabled/Guest), use the index in memory.
941 if (IsCurrentUserEphemeral()) 965 if (IsCurrentUserEphemeral())
942 return current_user_wallpaper_index_; 966 return current_user_wallpaper_index_;
943 967
944 const chromeos::User& user = GetLoggedInUser(); 968 const chromeos::User& user = GetLoggedInUser();
945 std::string username = user.email(); 969 std::string username = user.email();
946 DCHECK(!username.empty()); 970 DCHECK(!username.empty());
947 971 return FindUserWallpaperIndex(username);
948 PrefService* local_state = g_browser_process->local_state();
949 const DictionaryValue* user_wallpapers =
950 local_state->GetDictionary(UserManager::kUserWallpapers);
951 int index;
952 if (!user_wallpapers->GetIntegerWithoutPathExpansion(username, &index))
953 index = current_user_wallpaper_index_;
954
955 if (index < 0 || index >= ash::GetWallpaperCount()) {
956 index = ash::GetDefaultWallpaperIndex();
957 SaveUserWallpaperIndex(index);
958 }
959 return index;
960 } 972 }
961 973
962 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) { 974 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) {
963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 975 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
964 976
965 current_user_wallpaper_index_ = wallpaper_index; 977 current_user_wallpaper_index_ = wallpaper_index;
966 // Ephemeral users can not save data to local state. We just cache the index 978 // Ephemeral users can not save data to local state. We just cache the index
967 // in memory for them. 979 // in memory for them.
968 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) { 980 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) {
969 return; 981 return;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 BrowserThread::PostTask( 1278 BrowserThread::PostTask(
1267 BrowserThread::FILE, 1279 BrowserThread::FILE,
1268 FROM_HERE, 1280 FROM_HERE,
1269 base::Bind(&UserManagerImpl::DeleteUserImage, 1281 base::Bind(&UserManagerImpl::DeleteUserImage,
1270 base::Unretained(this), 1282 base::Unretained(this),
1271 image_path)); 1283 image_path));
1272 } 1284 }
1273 } 1285 }
1274 1286
1275 } // namespace chromeos 1287 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698