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

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: Nit 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"
(...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 (IsKnownUser(email)) {
453 ash::Shell::GetInstance()->desktop_background_controller()->
454 SetDefaultWallpaper(FindUserWallpaperIndex(email));
455 }
456 }
457
451 void UserManagerImpl::RemoveUser(const std::string& email, 458 void UserManagerImpl::RemoveUser(const std::string& email,
452 RemoveUserDelegate* delegate) { 459 RemoveUserDelegate* delegate) {
453 if (!IsKnownUser(email)) 460 if (!IsKnownUser(email))
454 return; 461 return;
455 462
456 // Sanity check: we must not remove single user. This check may seem 463 // 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 464 // 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 465 // 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 466 // due to non-instant nature of ownership assignment this later check may
460 // sometimes fail. See http://crosbug.com/12723 467 // sometimes fail. See http://crosbug.com/12723
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 882
876 const User* UserManagerImpl::FindUserInList(const std::string& email) const { 883 const User* UserManagerImpl::FindUserInList(const std::string& email) const {
877 const UserList& users = GetUsers(); 884 const UserList& users = GetUsers();
878 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 885 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
879 if ((*it)->email() == email) 886 if ((*it)->email() == email)
880 return *it; 887 return *it;
881 } 888 }
882 return NULL; 889 return NULL;
883 } 890 }
884 891
892 int UserManagerImpl::FindUserWallpaperIndex(const std::string& email) {
893 PrefService* local_state = g_browser_process->local_state();
894 const DictionaryValue* user_wallpapers =
895 local_state->GetDictionary(UserManager::kUserWallpapers);
896 int index;
897 if (!user_wallpapers->GetIntegerWithoutPathExpansion(email, &index))
898 index = current_user_wallpaper_index_;
899 if (index < 0 || index >= ash::GetWallpaperCount()) {
900 index = ash::GetDefaultWallpaperIndex();
901 SaveUserWallpaperIndex(index);
902 }
903 return index;
904 }
905
885 void UserManagerImpl::NotifyOnLogin() { 906 void UserManagerImpl::NotifyOnLogin() {
886 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 907 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
887 content::NotificationService::current()->Notify( 908 content::NotificationService::current()->Notify(
888 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 909 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
889 content::Source<UserManagerImpl>(this), 910 content::Source<UserManagerImpl>(this),
890 content::Details<const User>(logged_in_user_)); 911 content::Details<const User>(logged_in_user_));
891 912
892 LoadKeyStore(); 913 LoadKeyStore();
893 914
894 // Schedules current user ownership check on file thread. 915 // Schedules current user ownership check on file thread.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 if (!IsUserLoggedIn()) 958 if (!IsUserLoggedIn())
938 return ash::GetGuestWallpaperIndex(); 959 return ash::GetGuestWallpaperIndex();
939 // If logged in as other ephemeral users (Demo/Stub/Normal user with 960 // If logged in as other ephemeral users (Demo/Stub/Normal user with
940 // ephemeral policy enabled/Guest), use the index in memory. 961 // ephemeral policy enabled/Guest), use the index in memory.
941 if (IsCurrentUserEphemeral()) 962 if (IsCurrentUserEphemeral())
942 return current_user_wallpaper_index_; 963 return current_user_wallpaper_index_;
943 964
944 const chromeos::User& user = GetLoggedInUser(); 965 const chromeos::User& user = GetLoggedInUser();
945 std::string username = user.email(); 966 std::string username = user.email();
946 DCHECK(!username.empty()); 967 DCHECK(!username.empty());
947 968 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 } 969 }
961 970
962 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) { 971 void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) {
963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 972 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
964 973
965 current_user_wallpaper_index_ = wallpaper_index; 974 current_user_wallpaper_index_ = wallpaper_index;
966 // Ephemeral users can not save data to local state. We just cache the index 975 // Ephemeral users can not save data to local state. We just cache the index
967 // in memory for them. 976 // in memory for them.
968 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) { 977 if (IsCurrentUserEphemeral() || !IsUserLoggedIn()) {
969 return; 978 return;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 BrowserThread::PostTask( 1275 BrowserThread::PostTask(
1267 BrowserThread::FILE, 1276 BrowserThread::FILE,
1268 FROM_HERE, 1277 FROM_HERE,
1269 base::Bind(&UserManagerImpl::DeleteUserImage, 1278 base::Bind(&UserManagerImpl::DeleteUserImage,
1270 base::Unretained(this), 1279 base::Unretained(this),
1271 image_path)); 1280 image_path));
1272 } 1281 }
1273 } 1282 }
1274 1283
1275 } // namespace chromeos 1284 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698