| 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/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/browser/profiles/profile_manager.h" | |
| 13 #include "chrome/browser/ui/browser.h" | |
| 14 #include "chrome/browser/ui/browser_list.h" | |
| 15 #include "chrome/common/chrome_notification_types.h" | |
| 16 #include "content/public/browser/notification_service.h" | |
| 17 | |
| 18 namespace chromeos { | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 class UserWallpaperDelegate: public ash::UserWallpaperDelegate { | |
| 23 public: | |
| 24 UserWallpaperDelegate() { | |
| 25 } | |
| 26 | |
| 27 virtual ~UserWallpaperDelegate() { | |
| 28 } | |
| 29 | |
| 30 virtual const int GetUserWallpaperIndex() OVERRIDE { | |
| 31 return chromeos::UserManager::Get()->GetUserWallpaperIndex(); | |
| 32 } | |
| 33 | |
| 34 virtual void OpenSetWallpaperPage() OVERRIDE { | |
| 35 Browser* browser = Browser::GetOrCreateTabbedBrowser( | |
| 36 ProfileManager::GetDefaultProfileOrOffTheRecord()); | |
| 37 browser->ShowOptionsTab("setWallpaper"); | |
| 38 } | |
| 39 | |
| 40 virtual bool CanOpenSetWallpaperPage() OVERRIDE { | |
| 41 return !chromeos::UserManager::Get()->IsLoggedInAsGuest(); | |
| 42 } | |
| 43 | |
| 44 private: | |
| 45 DISALLOW_COPY_AND_ASSIGN(UserWallpaperDelegate); | |
| 46 }; | |
| 47 | |
| 48 } // namespace | |
| 49 | |
| 50 ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { | |
| 51 return new chromeos::UserWallpaperDelegate(); | |
| 52 } | |
| 53 | |
| 54 DesktopBackgroundObserver::DesktopBackgroundObserver() { | |
| 55 registrar_.Add( | |
| 56 this, | |
| 57 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | |
| 58 content::NotificationService::AllSources()); | |
| 59 } | |
| 60 | |
| 61 DesktopBackgroundObserver::~DesktopBackgroundObserver() { | |
| 62 } | |
| 63 | |
| 64 void DesktopBackgroundObserver::Observe(int type, | |
| 65 const content::NotificationSource& source, | |
| 66 const content::NotificationDetails& details) { | |
| 67 switch (type) { | |
| 68 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | |
| 69 ash::Shell::GetInstance()->desktop_background_controller()-> | |
| 70 SetDesktopBackgroundImageMode(); | |
| 71 break; | |
| 72 } | |
| 73 default: | |
| 74 NOTREACHED(); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 } // namespace chromeos | |
| OLD | NEW |