| 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 "ash/wallpaper/wallpaper_controller.h" | 5 #include "ash/wallpaper/wallpaper_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 InstallDesktopControllerForAllWindows(); | 161 InstallDesktopControllerForAllWindows(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void WallpaperController::CreateEmptyWallpaper() { | 164 void WallpaperController::CreateEmptyWallpaper() { |
| 165 SetProminentColor(kInvalidColor); | 165 SetProminentColor(kInvalidColor); |
| 166 current_wallpaper_.reset(); | 166 current_wallpaper_.reset(); |
| 167 wallpaper_mode_ = WALLPAPER_IMAGE; | 167 wallpaper_mode_ = WALLPAPER_IMAGE; |
| 168 InstallDesktopControllerForAllWindows(); | 168 InstallDesktopControllerForAllWindows(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool WallpaperController::MoveToLockedContainer() { | |
| 172 if (locked_) | |
| 173 return false; | |
| 174 locked_ = true; | |
| 175 return ReparentWallpaper(GetWallpaperContainerId(true)); | |
| 176 } | |
| 177 | |
| 178 bool WallpaperController::MoveToUnlockedContainer() { | |
| 179 if (!locked_) | |
| 180 return false; | |
| 181 locked_ = false; | |
| 182 return ReparentWallpaper(GetWallpaperContainerId(false)); | |
| 183 } | |
| 184 | |
| 185 void WallpaperController::OnDisplayConfigurationChanged() { | 171 void WallpaperController::OnDisplayConfigurationChanged() { |
| 186 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); | 172 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); |
| 187 if (current_max_display_size_ != max_display_size) { | 173 if (current_max_display_size_ != max_display_size) { |
| 188 current_max_display_size_ = max_display_size; | 174 current_max_display_size_ = max_display_size; |
| 189 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) { | 175 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) { |
| 190 timer_.Stop(); | 176 timer_.Stop(); |
| 191 timer_.Start(FROM_HERE, | 177 timer_.Start(FROM_HERE, |
| 192 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), | 178 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), |
| 193 base::Bind(&WallpaperController::UpdateWallpaper, | 179 base::Bind(&WallpaperController::UpdateWallpaper, |
| 194 base::Unretained(this), false /* clear cache */)); | 180 base::Unretained(this), false /* clear cache */)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 208 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) | 194 if (wallpaper_mode_ == WALLPAPER_IMAGE && current_wallpaper_) |
| 209 UpdateWallpaper(true /* clear cache */); | 195 UpdateWallpaper(true /* clear cache */); |
| 210 } | 196 } |
| 211 | 197 |
| 212 InstallDesktopController(root_window); | 198 InstallDesktopController(root_window); |
| 213 } | 199 } |
| 214 | 200 |
| 215 void WallpaperController::OnSessionStateChanged( | 201 void WallpaperController::OnSessionStateChanged( |
| 216 session_manager::SessionState state) { | 202 session_manager::SessionState state) { |
| 217 CalculateWallpaperColors(); | 203 CalculateWallpaperColors(); |
| 204 |
| 205 if (state == session_manager::SessionState::ACTIVE) |
| 206 MoveToUnlockedContainer(); |
| 207 else |
| 208 MoveToLockedContainer(); |
| 218 } | 209 } |
| 219 | 210 |
| 220 // static | 211 // static |
| 221 gfx::Size WallpaperController::GetMaxDisplaySizeInNative() { | 212 gfx::Size WallpaperController::GetMaxDisplaySizeInNative() { |
| 222 // Return an empty size for test environments where the screen is null. | 213 // Return an empty size for test environments where the screen is null. |
| 223 if (!display::Screen::GetScreen()) | 214 if (!display::Screen::GetScreen()) |
| 224 return gfx::Size(); | 215 return gfx::Size(); |
| 225 | 216 |
| 226 // Note that |shell_port| is null when this is called from Chrome running in | 217 // Note that |shell_port| is null when this is called from Chrome running in |
| 227 // Mash. | 218 // Mash. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 } | 385 } |
| 395 | 386 |
| 396 bool WallpaperController::ShouldCalculateColors() const { | 387 bool WallpaperController::ShouldCalculateColors() const { |
| 397 gfx::ImageSkia image = GetWallpaper(); | 388 gfx::ImageSkia image = GetWallpaper(); |
| 398 return IsShelfColoringEnabled() && | 389 return IsShelfColoringEnabled() && |
| 399 Shell::Get()->session_controller()->GetSessionState() == | 390 Shell::Get()->session_controller()->GetSessionState() == |
| 400 session_manager::SessionState::ACTIVE && | 391 session_manager::SessionState::ACTIVE && |
| 401 !image.isNull(); | 392 !image.isNull(); |
| 402 } | 393 } |
| 403 | 394 |
| 395 bool WallpaperController::MoveToLockedContainer() { |
| 396 if (locked_) |
| 397 return false; |
| 398 |
| 399 locked_ = true; |
| 400 return ReparentWallpaper(GetWallpaperContainerId(true)); |
| 401 } |
| 402 |
| 403 bool WallpaperController::MoveToUnlockedContainer() { |
| 404 if (!locked_) |
| 405 return false; |
| 406 |
| 407 locked_ = false; |
| 408 return ReparentWallpaper(GetWallpaperContainerId(false)); |
| 409 } |
| 410 |
| 404 } // namespace ash | 411 } // namespace ash |
| OLD | NEW |