OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/desktop_background/desktop_background_resources.h" | 8 #include "ash/desktop_background/desktop_background_resources.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 this, | 60 this, |
61 &WallpaperManager::BatchUpdateWallpaper); | 61 &WallpaperManager::BatchUpdateWallpaper); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void WallpaperManager::SetLastSelectedUser( | 65 void WallpaperManager::SetLastSelectedUser( |
66 const std::string& last_selected_user) { | 66 const std::string& last_selected_user) { |
67 last_selected_user_ = last_selected_user; | 67 last_selected_user_ = last_selected_user; |
68 } | 68 } |
69 | 69 |
| 70 void WallpaperManager::SetWallpaperFromFile(std::string email, |
| 71 const std::string& path, |
| 72 ash::WallpaperLayout layout) { |
| 73 image_loader_->Start( |
| 74 path, 0, false, |
| 75 base::Bind(&WallpaperManager::OnCustomWallpaperLoaded, |
| 76 base::Unretained(this), email, layout)); |
| 77 } |
| 78 |
70 void WallpaperManager::UserDeselected() { | 79 void WallpaperManager::UserDeselected() { |
71 if (!UserManager::Get()->IsUserLoggedIn()) { | 80 if (!UserManager::Get()->IsUserLoggedIn()) { |
72 // This will set default login wallpaper (#fefefe). | 81 // This will set default login wallpaper (#fefefe). |
73 ash::Shell::GetInstance()->desktop_background_controller()-> | 82 ash::Shell::GetInstance()->desktop_background_controller()-> |
74 SetDefaultWallpaper(ash::GetSolidColorIndex()); | 83 SetDefaultWallpaper(ash::GetSolidColorIndex()); |
75 } | 84 } |
76 } | 85 } |
77 | 86 |
78 // WallpaperManager, private: -------------------------------------------------- | 87 // WallpaperManager, private: -------------------------------------------------- |
79 | 88 |
80 WallpaperManager::~WallpaperManager() { | 89 WallpaperManager::~WallpaperManager() { |
81 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 90 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
82 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 91 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
83 } | 92 } |
84 | 93 |
| 94 void WallpaperManager::OnCustomWallpaperLoaded(const std::string& email, |
| 95 ash::WallpaperLayout layout, |
| 96 const UserImage& user_image) { |
| 97 const SkBitmap& wallpaper = user_image.image(); |
| 98 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 99 SetCustomWallpaper(wallpaper, layout); |
| 100 } |
| 101 |
85 void WallpaperManager::BatchUpdateWallpaper() { | 102 void WallpaperManager::BatchUpdateWallpaper() { |
86 PrefService* local_state = g_browser_process->local_state(); | 103 PrefService* local_state = g_browser_process->local_state(); |
87 UserManager* user_manager = UserManager::Get(); | 104 UserManager* user_manager = UserManager::Get(); |
88 bool show_users = true; | 105 bool show_users = true; |
89 CrosSettings::Get()->GetBoolean( | 106 CrosSettings::Get()->GetBoolean( |
90 kAccountsPrefShowUserNamesOnSignIn, &show_users); | 107 kAccountsPrefShowUserNamesOnSignIn, &show_users); |
91 if (local_state) { | 108 if (local_state) { |
92 User::WallpaperType type; | 109 User::WallpaperType type; |
93 int index = 0; | 110 int index = 0; |
94 base::Time last_modification_date; | 111 base::Time last_modification_date; |
(...skipping 29 matching lines...) Expand all Loading... |
124 | 141 |
125 void WallpaperManager::SystemResumed() { | 142 void WallpaperManager::SystemResumed() { |
126 BatchUpdateWallpaper(); | 143 BatchUpdateWallpaper(); |
127 } | 144 } |
128 | 145 |
129 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { | 146 void WallpaperManager::TimezoneChanged(const icu::TimeZone& timezone) { |
130 RestartTimer(); | 147 RestartTimer(); |
131 } | 148 } |
132 | 149 |
133 } // chromeos | 150 } // chromeos |
OLD | NEW |