Chromium Code Reviews| Index: chrome/browser/chromeos/options2/desktop_background_observer.cc |
| diff --git a/chrome/browser/chromeos/options2/desktop_background_observer.cc b/chrome/browser/chromeos/options2/desktop_background_observer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..07efd874c9de5fd6eff943c69f3495531bb7ddde |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/options2/desktop_background_observer.cc |
| @@ -0,0 +1,57 @@ |
| +// 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 "chrome/browser/chromeos/options2/desktop_background_observer.h" |
| + |
| +#include "ash/shell.h" |
| +#include "ash/desktop_background/desktop_background_controller.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" |
| + |
| +namespace chromeos { |
| + |
| +DesktopBackgroundObserver::DesktopBackgroundObserver() { |
| +#if defined(USE_AURA) |
| + registrar_.Add( |
| + this, |
| + chrome::NOTIFICATION_DESKTOP_BACKGROUND_CHANGED, |
| + content::NotificationService::AllSources()); |
| +#endif |
| +#if defined(OS_CHROMEOS) |
| + registrar_.Add( |
| + this, |
| + chrome::NOTIFICATION_SESSION_STARTED, |
| + content::NotificationService::AllSources()); |
| +#endif |
| +} |
| + |
| +DesktopBackgroundObserver::~DesktopBackgroundObserver() { |
| +} |
| + |
| +void DesktopBackgroundObserver::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(); |
| + ash::Shell::GetInstance()->desktop_background_controller() |
| + ->OnDesktopBackgroundChange(index); |
| + break; |
| + } |
| + case chrome::NOTIFICATION_SESSION_STARTED: { |
| + chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| + const chromeos::User& user = user_manager->logged_in_user(); |
| + int index = user_manager->GetUserWallpaper(user.email()); |
| + ash::Shell::GetInstance()->desktop_background_controller() |
| + ->OnDesktopBackgroundChange(index); |
| + break; |
| + } |
| + default: |
| + 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.
|
| + } |
| +} |
| + |
| +} // namespace chromeos |