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

Side by Side Diff: chrome/browser/chromeos/background/desktop_background_observer.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: Fix a debug build error associated with color mode switch 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 "chrome/browser/chromeos/background/desktop_background_observer.h"
6
7 #include "ash/shell.h"
8 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/desktop_background/desktop_background_resources.h"
10 #include "base/logging.h"
11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/common/chrome_notification_types.h"
13 #include "content/public/browser/notification_service.h"
14
15 namespace chromeos {
16
17 DesktopBackgroundObserver::DesktopBackgroundObserver() {
18 registrar_.Add(
19 this,
20 chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED,
21 content::NotificationService::AllSources());
22 registrar_.Add(
23 this,
24 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
25 content::NotificationService::AllSources());
26 }
27
28 DesktopBackgroundObserver::~DesktopBackgroundObserver() {
29 }
30
31 int DesktopBackgroundObserver::GetUserWallpaperIndex() {
32 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
33 const chromeos::User& user = user_manager->GetLoggedInUser();
34 DCHECK(!user.email().empty());
35 int index = user_manager->GetUserWallpaper(user.email());
36 DCHECK(index >=0 && index < ash::GetWallpaperCount());
37 return index;
38 }
39
40 void DesktopBackgroundObserver::Observe(int type,
41 const content::NotificationSource& source,
42 const content::NotificationDetails& details) {
43 switch (type) {
44 case chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED: {
45 int index = *content::Details<int>(details).ptr();
46 ash::Shell::GetInstance()->desktop_background_controller()->
47 OnDesktopBackgroundChange(index);
48 break;
49 }
50 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: {
51 ash::Shell::GetInstance()->desktop_background_controller()->
52 OnDesktopBackgroundChange(GetUserWallpaperIndex());
53 break;
54 }
55 default:
56 NOTREACHED();
57 }
58 }
59
60 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698