Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/options2/desktop_background_observer.h" | |
| 6 | |
| 7 #include "ash/shell.h" | |
| 8 #include "ash/desktop_background/desktop_background_controller.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 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 DesktopBackgroundObserver::DesktopBackgroundObserver() { | |
| 17 #if defined(USE_AURA) | |
| 18 registrar_.Add( | |
| 19 this, | |
| 20 chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED, | |
| 21 content::NotificationService::AllSources()); | |
| 22 #endif | |
| 23 #if defined(OS_CHROMEOS) | |
| 24 registrar_.Add( | |
| 25 this, | |
| 26 chrome::NOTIFICATION_SESSION_STARTED, | |
| 27 content::NotificationService::AllSources()); | |
| 28 #endif | |
| 29 } | |
| 30 | |
| 31 DesktopBackgroundObserver::~DesktopBackgroundObserver() { | |
| 32 } | |
| 33 | |
| 34 void DesktopBackgroundObserver::Observe(int type, | |
| 35 const content::NotificationSource& source, | |
| 36 const content::NotificationDetails& details) { | |
| 37 switch (type) { | |
| 38 case chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED: { | |
| 39 int index = *content::Details<int>(details).ptr(); | |
| 40 ash::Shell::GetInstance()->desktop_background_controller() | |
| 41 ->OnDesktopBackgroundChange(index); | |
| 42 break; | |
| 43 } | |
| 44 case chrome::NOTIFICATION_SESSION_STARTED: { | |
| 45 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | |
| 46 const chromeos::User& user = user_manager->logged_in_user(); | |
| 47 int index = user_manager->GetUserWallpaper(user.email()); | |
| 48 ash::Shell::GetInstance()->desktop_background_controller() | |
| 49 ->OnDesktopBackgroundChange(index); | |
| 50 break; | |
| 51 } | |
| 52 default: | |
| 53 NOTREACHED() << "Unexpected notification " << type; | |
|
flackr
2012/03/05 16:16:03
Remove text message, reason for hitting the NOTREA
bshe
2012/03/06 01:33:27
Done.
| |
| 54 } | |
| 55 } | |
| 56 | |
| 57 } // namespace chromeos | |
| OLD | NEW |