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 "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 "ui/gfx/image/image.h" | |
| 14 #include "grit/ui_resources.h" | |
|
flackr
2012/03/06 17:16:49
nit: Sort
bshe
2012/03/06 19:56:16
Done.
| |
| 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 Shell::GetInstance()->desktop_background_controller() | |
| 46 ->OnDesktopBackgroundChange(index); | |
| 47 break; | |
| 48 } | |
| 49 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | |
| 50 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | |
| 51 const chromeos::User& user = user_manager->logged_in_user(); | |
| 52 int index = user_manager->GetUserWallpaper(user.email()); | |
| 53 Shell::GetInstance()->desktop_background_controller() | |
|
flackr
2012/03/06 17:16:49
Shell::GetInstance()->desktop_background_controlle
bshe
2012/03/06 19:56:16
Done. The desktop_background_controller function i
| |
| 54 ->OnDesktopBackgroundChange(index); | |
| 55 break; | |
| 56 } | |
| 57 default: | |
| 58 NOTREACHED(); | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 } // namespace ash | |
| OLD | NEW |