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/desktop_background/desktop_background_controller_observer.h" | 7 #include "ash/desktop_background/desktop_background_controller_observer.h" |
| 8 #include "ash/desktop_background/desktop_background_view.h" | 8 #include "ash/desktop_background/desktop_background_view.h" |
| 9 #include "ash/desktop_background/desktop_background_widget_controller.h" | 9 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 10 #include "ash/desktop_background/user_wallpaper_delegate.h" | 10 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 | 125 |
| 126 scoped_ptr<WallpaperData> wallpaper_data_; | 126 scoped_ptr<WallpaperData> wallpaper_data_; |
| 127 | 127 |
| 128 const WallpaperInfo info_; | 128 const WallpaperInfo info_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(WallpaperLoader); | 130 DISALLOW_COPY_AND_ASSIGN(WallpaperLoader); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 DesktopBackgroundController::DesktopBackgroundController() | 133 DesktopBackgroundController::DesktopBackgroundController() |
| 134 : locked_(false), | 134 : locked_(false), |
| 135 desktop_background_mode_(BACKGROUND_SOLID_COLOR), | 135 desktop_background_mode_(BACKGROUND_NONE), |
| 136 background_color_(kTransparentColor), | 136 background_color_(kTransparentColor), |
| 137 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 137 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 138 } | 138 } |
| 139 | 139 |
| 140 DesktopBackgroundController::~DesktopBackgroundController() { | 140 DesktopBackgroundController::~DesktopBackgroundController() { |
| 141 CancelPendingWallpaperOperation(); | 141 CancelPendingWallpaperOperation(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { | 144 gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { |
| 145 if (current_wallpaper_.get()) | 145 if (current_wallpaper_.get()) |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 173 if (wallpaper_loader_.get()) | 173 if (wallpaper_loader_.get()) |
| 174 return wallpaper_loader_->idr(); | 174 return wallpaper_loader_->idr(); |
| 175 else if (current_wallpaper_.get()) | 175 else if (current_wallpaper_.get()) |
| 176 return current_wallpaper_->wallpaper_info.idr; | 176 return current_wallpaper_->wallpaper_info.idr; |
| 177 else | 177 else |
| 178 return -1; | 178 return -1; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void DesktopBackgroundController::OnRootWindowAdded( | 181 void DesktopBackgroundController::OnRootWindowAdded( |
| 182 aura::RootWindow* root_window) { | 182 aura::RootWindow* root_window) { |
| 183 // The background hasn't set yet. | |
|
bshe
2013/01/25 21:46:34
Just curiosity, if we skip the installation here,
oshima
2013/01/25 21:51:49
This can be called during the boot, before the bac
Daniel Erat
2013/01/26 15:52:30
nit: s/hasn't set/hasn't been set/
oshima
2013/01/26 23:10:42
Done.
| |
| 184 if (desktop_background_mode_ == BACKGROUND_NONE) | |
| 185 return; | |
| 186 | |
| 183 // Handle resolution change for "built-in" images. | 187 // Handle resolution change for "built-in" images. |
| 184 if (BACKGROUND_IMAGE == desktop_background_mode_ && | 188 if (BACKGROUND_IMAGE == desktop_background_mode_ && |
| 185 current_wallpaper_.get()) { | 189 current_wallpaper_.get()) { |
| 186 gfx::Size root_window_size = root_window->GetHostSize(); | 190 gfx::Size root_window_size = root_window->GetHostSize(); |
| 187 // Loads a higher resolution wallpaper if new root window is larger than | 191 // Loads a higher resolution wallpaper if new root window is larger than |
| 188 // small screen. | 192 // small screen. |
| 189 if (kSmallWallpaperMaxWidth < root_window_size.width() || | 193 if (kSmallWallpaperMaxWidth < root_window_size.width() || |
| 190 kSmallWallpaperMaxHeight < root_window_size.height()) { | 194 kSmallWallpaperMaxHeight < root_window_size.height()) { |
| 191 current_wallpaper_.reset(NULL); | 195 current_wallpaper_.reset(NULL); |
| 192 ash::Shell::GetInstance()->user_wallpaper_delegate()-> | 196 ash::Shell::GetInstance()->user_wallpaper_delegate()-> |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 component = new internal::DesktopBackgroundWidgetController(widget); | 344 component = new internal::DesktopBackgroundWidgetController(widget); |
| 341 break; | 345 break; |
| 342 } | 346 } |
| 343 case BACKGROUND_SOLID_COLOR: { | 347 case BACKGROUND_SOLID_COLOR: { |
| 344 ui::Layer* layer = SetColorLayerForContainer(background_color_, | 348 ui::Layer* layer = SetColorLayerForContainer(background_color_, |
| 345 root_window, | 349 root_window, |
| 346 container_id); | 350 container_id); |
| 347 component = new internal::DesktopBackgroundWidgetController(layer); | 351 component = new internal::DesktopBackgroundWidgetController(layer); |
| 348 break; | 352 break; |
| 349 } | 353 } |
| 350 default: { | 354 case BACKGROUND_NONE: |
|
oshima
2013/01/25 21:22:52
removing default as desktop_background_mode_ is en
|
bshe
2013/01/25 21:46:34
nit: Could you wrap the following with {} to be co
oshima
2013/01/25 21:51:49
{} is necessary when you create variables, which d
Daniel Erat
2013/01/26 15:52:30
I'd vote for leaving out the curly brackets.
|
| 351 NOTREACHED(); | 355 NOTREACHED(); |
| 352 } | 356 return; |
| 353 } | 357 } |
| 354 // Ensure we're only observing the root window once. Don't rely on a window | 358 // Ensure we're only observing the root window once. Don't rely on a window |
| 355 // property check as those can be cleared by tests resetting the background. | 359 // property check as those can be cleared by tests resetting the background. |
| 356 if (!root_window->HasObserver(this)) | 360 if (!root_window->HasObserver(this)) |
| 357 root_window->AddObserver(this); | 361 root_window->AddObserver(this); |
| 358 | 362 |
| 359 internal::AnimatingDesktopController* animating_controller = | 363 internal::AnimatingDesktopController* animating_controller = |
| 360 root_window->GetProperty(kAnimatingDesktopController); | 364 root_window->GetProperty(kAnimatingDesktopController); |
| 361 if (animating_controller) | 365 if (animating_controller) |
| 362 animating_controller->StopAnimating(); | 366 animating_controller->StopAnimating(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 } | 410 } |
| 407 return moved; | 411 return moved; |
| 408 } | 412 } |
| 409 | 413 |
| 410 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 414 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| 411 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : | 415 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : |
| 412 internal::kShellWindowId_DesktopBackgroundContainer; | 416 internal::kShellWindowId_DesktopBackgroundContainer; |
| 413 } | 417 } |
| 414 | 418 |
| 415 } // namespace ash | 419 } // namespace ash |
| OLD | NEW |