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

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: Nits 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 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 bf6709ffacb8bc9e6364e45eea206b2aa0769866..1e4818b7c18ac40d2b129755388486c074208b32 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -384,6 +384,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();
@@ -449,6 +450,13 @@ void UserManagerImpl::StubUserLoggedIn() {
kStubDefaultImageIndex);
}
+void UserManagerImpl::UserSelected(const std::string& email) {
+ if (IsKnownUser(email)) {
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ SetDefaultWallpaper(FindUserWallpaperIndex(email));
+ }
+}
+
void UserManagerImpl::SessionStarted() {
session_started_ = true;
content::NotificationService::current()->Notify(
@@ -895,6 +903,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(
@@ -943,12 +965,22 @@ void UserManagerImpl::SetInitialUserImage(const std::string& username) {
SaveUserDefaultImageIndex(username, image_id);
}
+void UserManagerImpl::SetInitialUserWallpaper(const std::string& username) {
+ // TODO(bshe): Ideally, wallpaper should start to load as soon as user click
+ // "Add user".
+ if (username == kGuestUser)
+ current_user_wallpaper_index_ = ash::GetGuestWallpaperIndex();
+ else
+ current_user_wallpaper_index_ = ash::GetDefaultWallpaperIndex();
+ SaveUserWallpaperIndex(current_user_wallpaper_index_);
+}
+
int UserManagerImpl::GetUserWallpaperIndex() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// If at login screen, use an invalid index to prevent any wallpaper
// operation.
- if (!IsUserLoggedIn())
+ if (!IsUserLoggedIn() || IsLoggedInAsStub())
return ash::GetInvalidWallpaperIndex();
// If logged in as other ephemeral users (Demo/Stub/Normal user with
// ephemeral policy enabled/Guest), use the index in memory.
@@ -958,19 +990,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) {
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_impl.h ('k') | chrome/browser/chromeos/login/webui_login_display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698