Chromium Code Reviews| 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/desktop_background/desktop_background_controller.h" | 5 #include "ash/desktop_background/desktop_background_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/desktop_background/desktop_background_controller_observer.h" | 8 #include "ash/desktop_background/desktop_background_controller_observer.h" |
| 9 #include "ash/desktop_background/desktop_background_view.h" | 9 #include "ash/desktop_background/desktop_background_view.h" |
| 10 #include "ash/desktop_background/desktop_background_widget_controller.h" | 10 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 using wallpaper::WALLPAPER_LAYOUT_CENTER; | 38 using wallpaper::WALLPAPER_LAYOUT_CENTER; |
| 39 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; | 39 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; |
| 40 using wallpaper::WALLPAPER_LAYOUT_STRETCH; | 40 using wallpaper::WALLPAPER_LAYOUT_STRETCH; |
| 41 using wallpaper::WALLPAPER_LAYOUT_TILE; | 41 using wallpaper::WALLPAPER_LAYOUT_TILE; |
| 42 | 42 |
| 43 namespace ash { | 43 namespace ash { |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 // How long to wait reloading the wallpaper after the max display has | 46 // How long to wait reloading the wallpaper after the max display has |
| 47 // changed? | 47 // changed? |
| 48 const int kWallpaperReloadDelayMs = 2000; | 48 const int kWallpaperReloadDelayMs = 100; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 DesktopBackgroundController::DesktopBackgroundController() | 52 DesktopBackgroundController::DesktopBackgroundController() |
| 53 : locked_(false), | 53 : locked_(false), |
| 54 desktop_background_mode_(BACKGROUND_NONE), | 54 desktop_background_mode_(BACKGROUND_NONE), |
| 55 wallpaper_reload_delay_(kWallpaperReloadDelayMs) { | 55 wallpaper_reload_delay_(kWallpaperReloadDelayMs) { |
| 56 Shell::GetInstance()->display_controller()->AddObserver(this); | 56 Shell::GetInstance()->display_controller()->AddObserver(this); |
| 57 Shell::GetInstance()->AddShellObserver(this); | 57 Shell::GetInstance()->AddShellObserver(this); |
| 58 } | 58 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 | 129 |
| 130 void DesktopBackgroundController::OnDisplayConfigurationChanged() { | 130 void DesktopBackgroundController::OnDisplayConfigurationChanged() { |
| 131 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); | 131 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); |
| 132 if (current_max_display_size_ != max_display_size) { | 132 if (current_max_display_size_ != max_display_size) { |
| 133 current_max_display_size_ = max_display_size; | 133 current_max_display_size_ = max_display_size; |
| 134 if (desktop_background_mode_ == BACKGROUND_IMAGE && | 134 if (desktop_background_mode_ == BACKGROUND_IMAGE && |
| 135 current_wallpaper_.get()) { | 135 current_wallpaper_.get()) { |
| 136 timer_.Stop(); | 136 timer_.Stop(); |
| 137 timer_.Start(FROM_HERE, | 137 timer_.Start(FROM_HERE, |
| 138 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), | 138 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), |
| 139 this, | 139 base::Bind(&DesktopBackgroundController::UpdateWallpaper, |
| 140 &DesktopBackgroundController::UpdateWallpaper); | 140 base::Unretained(this), false /* clear cache */)); |
|
oshima
2015/05/12 22:36:23
Sorry if I wasn't clear. We shouldn't need any del
| |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) { | 145 void DesktopBackgroundController::OnRootWindowAdded(aura::Window* root_window) { |
| 146 // The background hasn't been set yet. | 146 // The background hasn't been set yet. |
| 147 if (desktop_background_mode_ == BACKGROUND_NONE) | 147 if (desktop_background_mode_ == BACKGROUND_NONE) |
| 148 return; | 148 return; |
| 149 | 149 |
| 150 // Handle resolution change for "built-in" images. | 150 // Handle resolution change for "built-in" images. |
| 151 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); | 151 gfx::Size max_display_size = GetMaxDisplaySizeInNative(); |
| 152 if (current_max_display_size_ != max_display_size) { | 152 if (current_max_display_size_ != max_display_size) { |
| 153 current_max_display_size_ = max_display_size; | 153 current_max_display_size_ = max_display_size; |
| 154 if (desktop_background_mode_ == BACKGROUND_IMAGE && | 154 if (desktop_background_mode_ == BACKGROUND_IMAGE && |
| 155 current_wallpaper_.get()) | 155 current_wallpaper_.get()) |
| 156 UpdateWallpaper(); | 156 UpdateWallpaper(true /* clear cache */); |
| 157 } | 157 } |
| 158 | 158 |
| 159 InstallDesktopController(root_window); | 159 InstallDesktopController(root_window); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // static | 162 // static |
| 163 gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() { | 163 gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() { |
| 164 int width = 0; | 164 int width = 0; |
| 165 int height = 0; | 165 int height = 0; |
| 166 std::vector<gfx::Display> displays = Shell::GetScreen()->GetAllDisplays(); | 166 std::vector<gfx::Display> displays = Shell::GetScreen()->GetAllDisplays(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 return moved; | 270 return moved; |
| 271 } | 271 } |
| 272 | 272 |
| 273 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 273 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| 274 return locked ? kShellWindowId_LockScreenBackgroundContainer | 274 return locked ? kShellWindowId_LockScreenBackgroundContainer |
| 275 : kShellWindowId_DesktopBackgroundContainer; | 275 : kShellWindowId_DesktopBackgroundContainer; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void DesktopBackgroundController::UpdateWallpaper() { | 278 void DesktopBackgroundController::UpdateWallpaper(bool clear_cache) { |
| 279 current_wallpaper_.reset(NULL); | 279 current_wallpaper_.reset(NULL); |
| 280 ash::Shell::GetInstance()->user_wallpaper_delegate()-> | 280 ash::Shell::GetInstance()->user_wallpaper_delegate()->UpdateWallpaper( |
| 281 UpdateWallpaper(true /* clear cache */); | 281 clear_cache); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace ash | 284 } // namespace ash |
| OLD | NEW |