summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 18:22:23 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 18:22:23 +0000
commitd2b09c6c1166330bfbfb841f27f8b4aa8312d325 (patch)
tree7fa19b033181d407f4ccc9fcf624cd33c75b37e5
parentd7db4f62b576074b5b5f62d156e335855dc51bdb (diff)
downloadchromium_src-d2b09c6c1166330bfbfb841f27f8b4aa8312d325.zip
chromium_src-d2b09c6c1166330bfbfb841f27f8b4aa8312d325.tar.gz
chromium_src-d2b09c6c1166330bfbfb841f27f8b4aa8312d325.tar.bz2
Revert 140312 - Load user custom wallpaper after browser crash.
BUG=129810 TEST= 1. Login 2. Set custom wallpaper for desktop background 3. Trigger a chrome crash (about://inducebrowsercrashforrealz) 4. Observe the desktop wallpaper 5. Go to "Set wallpaper" settings dialog and look for the custom added wallpaper thumbnail Verify that custom wallpaper restored after chrome crash. Review URL: https://chromiumcodereview.appspot.com/10459003 TBR=bshe@chromium.org Review URL: https://chromiumcodereview.appspot.com/10511014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140329 0039d316-1c4b-4281-b951-d872f2087c98
-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, 50 insertions, 38 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index c4f21ba..72a43ec 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -155,12 +155,10 @@ 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 {
- ash::Shell::GetInstance()->user_wallpaper_delegate()->
- SetLoggedInUserWallpaper();
- }
+ else
+ desktop_background_controller->SetLoggedInUserWallpaper();
return true;
}
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index 31be9c8..5994bf2 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -102,13 +102,6 @@ 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);
@@ -138,6 +131,19 @@ 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 7e8620b..b0ae8cf 100644
--- a/ash/desktop_background/desktop_background_controller.h
+++ b/ash/desktop_background/desktop_background_controller.h
@@ -25,9 +25,8 @@ class UserWallpaperDelegate {
public:
virtual ~UserWallpaperDelegate() {}
- // Loads logged in user wallpaper asynchronously and sets to current wallpaper
- // after loaded.
- virtual void SetLoggedInUserWallpaper() = 0;
+ // Gets the index of user selected wallpaper.
+ virtual const int GetUserWallpaperIndex() = 0;
// Opens the set wallpaper page in the browser.
virtual void OpenSetWallpaperPage() = 0;
@@ -66,6 +65,10 @@ 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 db7d6e6..9d667d8 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -244,7 +244,8 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
virtual ~DummyUserWallpaperDelegate() {}
- virtual void SetLoggedInUserWallpaper() OVERRIDE {
+ virtual const int GetUserWallpaperIndex() OVERRIDE {
+ return -1;
}
virtual void OpenSetWallpaperPage() OVERRIDE {
@@ -805,7 +806,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.
- user_wallpaper_delegate_->SetLoggedInUserWallpaper();
+ desktop_background_controller_->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 bef27b4..b098dc4 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 void SetLoggedInUserWallpaper() OVERRIDE {
- chromeos::UserManager::Get()->SetLoggedInUserWallpaper();
+ virtual const int GetUserWallpaperIndex() OVERRIDE {
+ return chromeos::UserManager::Get()->GetLoggedInUserWallpaperIndex();
}
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 f4e700f..178d7bf 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.cc
+++ b/chrome/browser/chromeos/login/mock_user_manager.cc
@@ -20,6 +20,10 @@ 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 7540b82..ee520c3 100644
--- a/chrome/browser/chromeos/login/mock_user_manager.h
+++ b/chrome/browser/chromeos/login/mock_user_manager.h
@@ -24,7 +24,6 @@ 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*));
@@ -77,6 +76,11 @@ 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 d6ac5a3..e183b28 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager.h
@@ -101,11 +101,6 @@ 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;
@@ -157,6 +152,11 @@ 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 846790c..a5df44f 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc
@@ -358,17 +358,6 @@ 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;
@@ -968,6 +957,13 @@ 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 5cc1d05..04e5f57 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -47,7 +47,6 @@ 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,
@@ -66,6 +65,7 @@ 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 8c27ac2..2b113b1 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()->user_wallpaper_delegate()->
+ ash::Shell::GetInstance()->desktop_background_controller()->
SetLoggedInUserWallpaper();
}
}