summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/accelerators/accelerator_controller.cc8
-rw-r--r--ash/desktop_background/desktop_background_controller.cc20
-rw-r--r--ash/desktop_background/desktop_background_controller.h9
-rw-r--r--ash/shell.cc5
-rw-r--r--chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc4
-rw-r--r--chrome/browser/chromeos/login/mock_user_manager.cc4
-rw-r--r--chrome/browser/chromeos/login/mock_user_manager.h6
-rw-r--r--chrome/browser/chromeos/login/user_manager.h10
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.cc18
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.h2
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc2
11 files changed, 38 insertions, 50 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 72a43ec..c4f21ba 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -155,10 +155,12 @@ bool HandleToggleDesktopBackgroundMode() {
ash::DesktopBackgroundController* desktop_background_controller =
ash::Shell::GetInstance()->desktop_background_controller();
if (desktop_background_controller->desktop_background_mode() ==
- ash::DesktopBackgroundController::BACKGROUND_IMAGE)
+ ash::DesktopBackgroundController::BACKGROUND_IMAGE) {
desktop_background_controller->SetDesktopBackgroundSolidColorMode();
- else
- desktop_background_controller->SetLoggedInUserWallpaper();
+ } else {
+ ash::Shell::GetInstance()->user_wallpaper_delegate()->
+ SetLoggedInUserWallpaper();
+ }
return true;
}
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index 5994bf2..31be9c8 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -102,6 +102,13 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index) {
if (previous_index_ == index)
return;
+ // We should not change background when index is invalid. For instance, at
+ // login screen or stub_user login.
+ if (index == ash::GetInvalidWallpaperIndex()) {
+ CreateEmptyWallpaper();
+ return;
+ }
+
CancelPendingWallpaperOperation();
wallpaper_op_ = new WallpaperOperation(index);
@@ -131,19 +138,6 @@ void DesktopBackgroundController::CancelPendingWallpaperOperation() {
weak_ptr_factory_.InvalidateWeakPtrs();
}
-void DesktopBackgroundController::SetLoggedInUserWallpaper() {
- int index = Shell::GetInstance()->user_wallpaper_delegate()->
- GetUserWallpaperIndex();
- // We should not change background when index is invalid. For instance, at
- // login screen or stub_user login.
- if (index == ash::GetInvalidWallpaperIndex()) {
- CreateEmptyWallpaper();
- return;
- }
-
- SetDefaultWallpaper(index);
-}
-
void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode() {
// Set a solid black background.
// TODO(derat): Remove this in favor of having the compositor only clear the
diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h
index b0ae8cf..7e8620b 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -25,8 +25,9 @@ class UserWallpaperDelegate {
public:
virtual ~UserWallpaperDelegate() {}
- // Gets the index of user selected wallpaper.
- virtual const int GetUserWallpaperIndex() = 0;
+ // Loads logged in user wallpaper asynchronously and sets to current wallpaper
+ // after loaded.
+ virtual void SetLoggedInUserWallpaper() = 0;
// Opens the set wallpaper page in the browser.
virtual void OpenSetWallpaperPage() = 0;
@@ -65,10 +66,6 @@ class ASH_EXPORT DesktopBackgroundController {
// Cancels the current wallpaper loading operation.
void CancelPendingWallpaperOperation();
- // Loads logged in user wallpaper asynchronously and sets to current wallpaper
- // after loaded.
- void SetLoggedInUserWallpaper();
-
// Sets the desktop background to solid color mode and creates a solid color
// layout.
void SetDesktopBackgroundSolidColorMode();
diff --git a/ash/shell.cc b/ash/shell.cc
index 9d667d8..db7d6e6 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -244,8 +244,7 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
virtual ~DummyUserWallpaperDelegate() {}
- virtual const int GetUserWallpaperIndex() OVERRIDE {
- return -1;
+ virtual void SetLoggedInUserWallpaper() OVERRIDE {
}
virtual void OpenSetWallpaperPage() OVERRIDE {
@@ -806,7 +805,7 @@ void Shell::Init() {
// It needs to be created after OnWindowResized has been called, otherwise the
// widget will not paint when restoring after a browser crash.
- desktop_background_controller_->SetLoggedInUserWallpaper();
+ user_wallpaper_delegate_->SetLoggedInUserWallpaper();
window_modality_controller_.reset(new internal::WindowModalityController);
AddRootWindowEventFilter(window_modality_controller_.get());
diff --git a/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc b/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc
index b098dc4..bef27b4 100644
--- a/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc
+++ b/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc
@@ -27,8 +27,8 @@ class UserWallpaperDelegate: public ash::UserWallpaperDelegate {
virtual ~UserWallpaperDelegate() {
}
- virtual const int GetUserWallpaperIndex() OVERRIDE {
- return chromeos::UserManager::Get()->GetLoggedInUserWallpaperIndex();
+ virtual void SetLoggedInUserWallpaper() OVERRIDE {
+ chromeos::UserManager::Get()->SetLoggedInUserWallpaper();
}
virtual void OpenSetWallpaperPage() OVERRIDE {
diff --git a/chrome/browser/chromeos/login/mock_user_manager.cc b/chrome/browser/chromeos/login/mock_user_manager.cc
index 178d7bf..f4e700f 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.cc
+++ b/chrome/browser/chromeos/login/mock_user_manager.cc
@@ -20,10 +20,6 @@ User& MockUserManager::GetLoggedInUser() {
return *user_;
}
-int MockUserManager::GetLoggedInUserWallpaperIndex() {
- return -1;
-}
-
// Creates a new User instance.
void MockUserManager::SetLoggedInUser(const std::string& email, bool guest) {
delete user_;
diff --git a/chrome/browser/chromeos/login/mock_user_manager.h b/chrome/browser/chromeos/login/mock_user_manager.h
index ee520c3..7540b82 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.h
+++ b/chrome/browser/chromeos/login/mock_user_manager.h
@@ -24,6 +24,7 @@ class MockUserManager : public UserManager {
MOCK_METHOD0(DemoUserLoggedIn, void(void));
MOCK_METHOD0(GuestUserLoggedIn, void(void));
MOCK_METHOD1(EphemeralUserLoggedIn, void(const std::string&));
+ MOCK_METHOD0(SetLoggedInUserWallpaper, void(void));
MOCK_METHOD1(UserSelected, void(const std::string&));
MOCK_METHOD0(SessionStarted, void(void));
MOCK_METHOD2(RemoveUser, void(const std::string&, RemoveUserDelegate*));
@@ -76,11 +77,6 @@ class MockUserManager : public UserManager {
// Sets a new User instance.
void SetLoggedInUser(const std::string& email, bool guest);
- // Return an invalid user wallpaper index. No need to load a real wallpaper.
- // When loading wallpaper asynchronously, it may actually cause a crash if
- // test finished before wallpaper loaded.
- virtual int GetLoggedInUserWallpaperIndex() OVERRIDE;
-
User* user_;
};
diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager.h
index e183b28..d6ac5a3 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager.h
@@ -101,6 +101,11 @@ class UserManager {
// Indicates that a user just logged in as ephemeral.
virtual void EphemeralUserLoggedIn(const std::string& email) = 0;
+ // Loads logged in user wallpaper asynchronously and sets to current wallpaper
+ // after loaded. If not logged in or logged in as stub user, uses an empty
+ // wallpaper.
+ virtual void SetLoggedInUserWallpaper() = 0;
+
// Called when user pod with |email| is selected.
virtual void UserSelected(const std::string& email) = 0;
@@ -152,11 +157,6 @@ class UserManager {
virtual std::string GetUserDisplayEmail(
const std::string& username) const = 0;
- // Returns the index of the default wallpapers saved in local state for login
- // user if it is known (was previously set by |SaveWallpaperToLocalState|
- // call). Otherwise, returns the default wallpaper index.
- virtual int GetLoggedInUserWallpaperIndex() = 0;
-
// Sets |type| and |index| to the value saved in local state for logged in
// user.
virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type,
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
index a5df44f..846790c 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -358,6 +358,17 @@ void UserManagerImpl::StubUserLoggedIn() {
kStubDefaultImageIndex);
}
+void UserManagerImpl::SetLoggedInUserWallpaper() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!IsUserLoggedIn() || IsLoggedInAsStub()) {
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ SetDefaultWallpaper(ash::GetInvalidWallpaperIndex());
+ return;
+ }
+ UserSelected(GetLoggedInUser().email());
+}
+
void UserManagerImpl::UserSelected(const std::string& email) {
if (IsKnownUser(email)) {
User::WallpaperType type;
@@ -957,13 +968,6 @@ void UserManagerImpl::MigrateWallpaperData() {
}
}
-int UserManagerImpl::GetLoggedInUserWallpaperIndex() {
- User::WallpaperType type;
- int index;
- GetLoggedInUserWallpaperProperties(&type, &index);
- return index;
-}
-
void UserManagerImpl::GetLoggedInUserWallpaperProperties(
User::WallpaperType* type,
int* index) {
diff --git a/chrome/browser/chromeos/login/user_manager_impl.h b/chrome/browser/chromeos/login/user_manager_impl.h
index 04e5f57..5cc1d05 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -47,6 +47,7 @@ class UserManagerImpl : public UserManager,
virtual void DemoUserLoggedIn() OVERRIDE;
virtual void GuestUserLoggedIn() OVERRIDE;
virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE;
+ virtual void SetLoggedInUserWallpaper() OVERRIDE;
virtual void UserSelected(const std::string& email) OVERRIDE;
virtual void SessionStarted() OVERRIDE;
virtual void RemoveUser(const std::string& email,
@@ -65,7 +66,6 @@ class UserManagerImpl : public UserManager,
const std::string& display_email) OVERRIDE;
virtual std::string GetUserDisplayEmail(
const std::string& username) const OVERRIDE;
- virtual int GetLoggedInUserWallpaperIndex() OVERRIDE;
virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type,
int* index) OVERRIDE;
virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type,
diff --git a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
index 2b113b1..8c27ac2 100644
--- a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
@@ -219,7 +219,7 @@ void SetWallpaperOptionsHandler::HandleDefaultWallpaper(const ListValue* args) {
if (IsDefaultWallpaperURL(image_url, &user_image_index)) {
UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DEFAULT,
user_image_index);
- ash::Shell::GetInstance()->desktop_background_controller()->
+ ash::Shell::GetInstance()->user_wallpaper_delegate()->
SetLoggedInUserWallpaper();
}
}