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

Side by Side 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: Address review 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/desktop_background/desktop_background_controller.h"
6
7 #include "ash/desktop_background/desktop_background_resources.h"
8 #include "ash/shell.h"
9 #include "base/logging.h"
10 #include "chrome/browser/chromeos/login/user_manager.h"
11 #include "chrome/common/chrome_notification_types.h"
12 #include "content/public/browser/notification_service.h"
13 #include "grit/ui_resources.h"
14 #include "ui/gfx/image/image.h"
15 #include "ui/base/resource/resource_bundle.h"
16
17 namespace ash {
18
19 DesktopBackgroundController::DesktopBackgroundController(){
20 registrar_.Add(
21 this,
22 chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED,
23 content::NotificationService::AllSources());
24 registrar_.Add(
25 this,
26 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
27 content::NotificationService::AllSources());
28 }
29
30 DesktopBackgroundController::~DesktopBackgroundController() {
31 }
32
33 void DesktopBackgroundController::OnDesktopBackgroundChange(int index) {
34 DCHECK(index >=0 && index < kDefaultWallpaperCount);
35 Shell::GetInstance()->SetDesktopBackgroundWallpaper(
36 GetDefaultWallpaper(index));
37 }
38
39 void DesktopBackgroundController::Observe(int type,
40 const content::NotificationSource& source,
41 const content::NotificationDetails& details) {
42 switch (type) {
43 case chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED: {
44 int index = *content::Details<int>(details).ptr();
45 OnDesktopBackgroundChange(index);
46 break;
47 }
48 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: {
49 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
50 const chromeos::User& user = user_manager->logged_in_user();
51 int index = user_manager->GetUserWallpaper(user.email());
52 OnDesktopBackgroundChange(index);
53 break;
54 }
55 default:
56 NOTREACHED();
57 }
58 }
59
60 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698