Chromium Code Reviews| Index: ash/shell.cc |
| diff --git a/ash/shell.cc b/ash/shell.cc |
| index 1041a3dca9a50ecf3f495b991bf89648d1935c41..e70ebc167a6de063bace4c6bfb13484a75ca87f1 100644 |
| --- a/ash/shell.cc |
| +++ b/ash/shell.cc |
| @@ -8,6 +8,9 @@ |
| #include "ash/app_list/app_list.h" |
| #include "ash/ash_switches.h" |
| +#include "ash/desktop_background/desktop_background_controller.h" |
| +#include "ash/desktop_background/desktop_background_resources.h" |
| +#include "ash/desktop_background/desktop_background_view.h" |
| #include "ash/drag_drop/drag_drop_controller.h" |
| #include "ash/focus_cycler.h" |
| #include "ash/ime/input_method_event_filter.h" |
| @@ -478,6 +481,7 @@ void Shell::Init() { |
| AddRootWindowEventFilter(tooltip_controller_.get()); |
| drag_drop_controller_.reset(new internal::DragDropController); |
| + desktop_background_controller_.reset(new DesktopBackgroundController); |
| power_button_controller_.reset(new PowerButtonController); |
| video_detector_.reset(new VideoDetector); |
| window_cycle_controller_.reset(new WindowCycleController); |
| @@ -538,25 +542,35 @@ void Shell::ToggleAppList() { |
| app_list_->SetVisible(!app_list_->IsVisible()); |
| } |
| -void Shell::SetDesktopBackgroundMode(BackgroundMode mode) { |
| - if (mode == BACKGROUND_SOLID_COLOR) { |
| - // Set a solid black background. |
| - // TODO(derat): Remove this in favor of having the compositor only clear the |
| - // viewport when there are regions not covered by a layer: |
| - // http://crbug.com/113445 |
| - ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); |
| - background_layer->SetColor(SK_ColorBLACK); |
| - GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> |
| - layer()->Add(background_layer); |
| - root_window_layout_->SetBackgroundLayer(background_layer); |
| - root_window_layout_->SetBackgroundWidget(NULL); |
| - } else { |
| - // Create the desktop background image. |
| - root_window_layout_->SetBackgroundLayer(NULL); |
| - root_window_layout_->SetBackgroundWidget( |
| - internal::CreateDesktopBackground()); |
| - } |
| - desktop_background_mode_ = mode; |
| +void Shell::SetDesktopBackgroundWallpaper(const SkBitmap& wallpaper) { |
| + if (desktop_background_mode_ == BACKGROUND_SOLID_COLOR) |
| + return; |
| + |
| + DCHECK(root_window_layout_->background_widget()); |
| + static_cast<internal::DesktopBackgroundView*>( |
| + root_window_layout_->background_widget()->widget_delegate())-> |
| + SetWallpaper(wallpaper); |
| +} |
| + |
| +void Shell::SetDesktopBackgroundImageMode(const SkBitmap& wallpaper) { |
| + root_window_layout_->SetBackgroundLayer(NULL); |
| + root_window_layout_->SetBackgroundWidget( |
| + internal::CreateDesktopBackground(wallpaper)); |
| + desktop_background_mode_ = BACKGROUND_IMAGE; |
| +} |
| + |
| +void Shell::SetDesktopBackgroundSolidColorMode() { |
| + // Set a solid black background. |
| + // TODO(derat): Remove this in favor of having the compositor only clear the |
| + // viewport when there are regions not covered by a layer: |
| + // http://crbug.com/113445 |
| + ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR); |
| + background_layer->SetColor(SK_ColorBLACK); |
| + GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> |
| + layer()->Add(background_layer); |
| + root_window_layout_->SetBackgroundLayer(background_layer); |
| + root_window_layout_->SetBackgroundWidget(NULL); |
| + desktop_background_mode_ = BACKGROUND_SOLID_COLOR; |
| } |
| bool Shell::IsScreenLocked() const { |
| @@ -635,7 +649,7 @@ void Shell::SetupCompactWindowMode() { |
| launcher_->widget()->Hide(); |
| // Set a solid black background. |
| - SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); |
| + SetDesktopBackgroundSolidColorMode(); |
| } |
| void Shell::SetupManagedWindowMode() { |
| @@ -664,7 +678,8 @@ void Shell::SetupManagedWindowMode() { |
| launcher_->widget()->Show(); |
| // Create the desktop background image. |
| - SetDesktopBackgroundMode(BACKGROUND_IMAGE); |
| + SetDesktopBackgroundImageMode(desktop_background_controller_-> |
| + GetPresetWallpaper()); |
|
flackr
2012/03/08 01:19:59
Indent 4 more spaces as this isn't another argumen
bshe
2012/03/08 03:19:24
Done.
|
| } |
| void Shell::ResetLayoutManager(int container_id) { |