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

Unified 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: Add user wallpaper for first time logged in user and ephemeral users 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/user_manager_impl.cc
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index a004cc9adf88ea1ca21497bc0b12c834f340c121..4dbef649a711a3b611fe2ffbf0b2b8cf4ef329a7 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -383,6 +383,7 @@ void UserManagerImpl::UserLoggedIn(const std::string& email) {
if (is_current_user_new_) {
SetInitialUserImage(email);
+ SetInitialUserWallpaper(email);
} else {
// Download profile image if it's user image and see if it has changed.
int image_index = logged_in_user_->image_index();
@@ -421,6 +422,7 @@ void UserManagerImpl::DemoUserLoggedIn() {
is_current_user_ephemeral_ = true;
logged_in_user_ = new User(kDemoUser, false);
SetInitialUserImage(kDemoUser);
+ SetInitialUserWallpaper(kDemoUser);
NotifyOnLogin();
}
@@ -429,6 +431,7 @@ void UserManagerImpl::GuestUserLoggedIn() {
// Guest user always uses the same wallpaper.
current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
logged_in_user_ = new User(kGuestUser, true);
+ SetInitialUserWallpaper(kGuestUser);
NotifyOnLogin();
}
@@ -437,6 +440,7 @@ void UserManagerImpl::EphemeralUserLoggedIn(const std::string& email) {
is_current_user_ephemeral_ = true;
logged_in_user_ = CreateUser(email);
SetInitialUserImage(email);
+ SetInitialUserWallpaper(email);
NotifyOnLogin();
}
@@ -446,6 +450,14 @@ void UserManagerImpl::StubUserLoggedIn() {
logged_in_user_ = new User(kStubUser, false);
logged_in_user_->SetImage(GetDefaultImage(kStubDefaultImageIndex),
kStubDefaultImageIndex);
+ SetInitialUserWallpaper(kStubUser);
+}
+
+void UserManagerImpl::UserSelected(const std::string& email) {
+ if (IsKnownUser(email)) {
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ SetDefaultWallpaper(FindUserWallpaperIndex(email));
+ }
}
void UserManagerImpl::RemoveUser(const std::string& email,
@@ -882,6 +894,20 @@ const User* UserManagerImpl::FindUserInList(const std::string& email) const {
return NULL;
}
+int UserManagerImpl::FindUserWallpaperIndex(const std::string& email) {
+ PrefService* local_state = g_browser_process->local_state();
+ const DictionaryValue* user_wallpapers =
+ local_state->GetDictionary(UserManager::kUserWallpapers);
+ int index;
+ if (!user_wallpapers->GetIntegerWithoutPathExpansion(email, &index))
+ index = current_user_wallpaper_index_;
+ if (index < 0 || index >= ash::GetWallpaperCount()) {
+ index = ash::GetDefaultWallpaperIndex();
+ SaveUserWallpaperIndex(index);
+ }
+ return index;
+}
+
void UserManagerImpl::NotifyOnLogin() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
content::NotificationService::current()->Notify(
@@ -930,6 +956,16 @@ void UserManagerImpl::SetInitialUserImage(const std::string& username) {
SaveUserDefaultImageIndex(username, image_id);
}
+void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) {
+ if (username == kGuestUser)
+ current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
+ else
+ current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
Nikita (slow) 2012/05/02 09:22:23 Ideally we might start preloading some random wall
bshe 2012/05/03 01:02:00 I agree, ideally we should start loading wallpaper
+ SaveUserWallpaperIndex(current_user_wallpaper_index_);
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ SetDefaultWallpaper(current_user_wallpaper_index_);
+}
+
int UserManagerImpl::GetUserWallpaperIndex() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -944,19 +980,7 @@ int UserManagerImpl::GetUserWallpaperIndex() {
const chromeos::User& user = GetLoggedInUser();
std::string username = user.email();
DCHECK(!username.empty());
-
- PrefService* local_state = g_browser_process->local_state();
- const DictionaryValue* user_wallpapers =
- local_state->GetDictionary(UserManager::kUserWallpapers);
- int index;
- if (!user_wallpapers->GetIntegerWithoutPathExpansion(username, &index))
- index = current_user_wallpaper_index_;
-
- if (index < 0 || index >= ash::GetWallpaperCount()) {
- index = ash::GetDefaultWallpaperIndex();
- SaveUserWallpaperIndex(index);
- }
- return index;
+ return FindUserWallpaperIndex(username);
}
void UserManagerImpl::SaveUserWallpaperIndex(int wallpaper_index) {

Powered by Google App Engine
This is Rietveld 408576698