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

Unified Diff: ash/desktop_background/desktop_background_controller.cc

Issue 9580023: Enable user change background image in settings page in Aura build. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Save user choosed index to local state Created 8 years, 9 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: ash/desktop_background/desktop_background_controller.cc
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..98c8197f56bccae6b13348f25d47eb7f5f943945
--- /dev/null
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/desktop_background/desktop_background_controller.h"
+
+#include "ash/desktop_background/desktop_background_resources.h"
+#include "ash/shell.h"
+#include "base/logging.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_service.h"
+#include "ui/gfx/image/image.h"
+#include "grit/ui_resources.h"
flackr 2012/03/06 17:16:49 nit: Sort
bshe 2012/03/06 19:56:16 Done.
+#include "ui/base/resource/resource_bundle.h"
+
+namespace ash {
+
+DesktopBackgroundController::DesktopBackgroundController(){
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED,
+ content::NotificationService::AllSources());
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_LOGIN_USER_CHANGED,
+ content::NotificationService::AllSources());
+}
+
+DesktopBackgroundController::~DesktopBackgroundController() {
+}
+
+void DesktopBackgroundController::OnDesktopBackgroundChange(int index) {
+ DCHECK(index >=0 && index < kDefaultWallpaperCount);
+ Shell::GetInstance()->SetDesktopBackgroundWallpaper(
+ GetDefaultWallpaper(index));
+}
+
+void DesktopBackgroundController::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED: {
+ int index = *content::Details<int>(details).ptr();
+ Shell::GetInstance()->desktop_background_controller()
+ ->OnDesktopBackgroundChange(index);
+ break;
+ }
+ case chrome::NOTIFICATION_LOGIN_USER_CHANGED: {
+ chromeos::UserManager* user_manager = chromeos::UserManager::Get();
+ const chromeos::User& user = user_manager->logged_in_user();
+ int index = user_manager->GetUserWallpaper(user.email());
+ Shell::GetInstance()->desktop_background_controller()
flackr 2012/03/06 17:16:49 Shell::GetInstance()->desktop_background_controlle
bshe 2012/03/06 19:56:16 Done. The desktop_background_controller function i
+ ->OnDesktopBackgroundChange(index);
+ break;
+ }
+ default:
+ NOTREACHED();
+ }
+}
+
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698