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_view.h" | 7 #include "ash/desktop_background/desktop_background_view.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_factory.h" | 9 #include "ash/shell_factory.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 DesktopBackgroundController::~DesktopBackgroundController() { | 97 DesktopBackgroundController::~DesktopBackgroundController() { |
98 CancelPendingWallpaperOperation(); | 98 CancelPendingWallpaperOperation(); |
99 } | 99 } |
100 | 100 |
101 void DesktopBackgroundController::SetDefaultWallpaper(int index) { | 101 void DesktopBackgroundController::SetDefaultWallpaper(int index) { |
102 // We should not change background when index is invalid. For instance, at | 102 // We should not change background when index is invalid. For instance, at |
103 // login screen or stub_user login. | 103 // login screen or stub_user login. |
104 if (index == ash::GetInvalidWallpaperIndex()) { | 104 if (index == ash::GetInvalidWallpaperIndex()) { |
105 CreateEmptyWallpaper(); | 105 CreateEmptyWallpaper(); |
106 return; | 106 return; |
| 107 } else if (index == ash::GetSolidColorIndex()) { |
| 108 SetDesktopBackgroundSolidColorMode(kLoginWallpaperColor); |
| 109 return; |
107 } | 110 } |
108 | 111 |
109 if (previous_index_ == index) | 112 if (previous_index_ == index) |
110 return; | 113 return; |
111 | 114 |
112 CancelPendingWallpaperOperation(); | 115 CancelPendingWallpaperOperation(); |
113 | 116 |
114 wallpaper_op_ = new WallpaperOperation(index); | 117 wallpaper_op_ = new WallpaperOperation(index); |
115 base::WorkerPool::PostTaskAndReply( | 118 base::WorkerPool::PostTaskAndReply( |
116 FROM_HERE, | 119 FROM_HERE, |
(...skipping 14 matching lines...) Expand all Loading... |
131 | 134 |
132 void DesktopBackgroundController::CancelPendingWallpaperOperation() { | 135 void DesktopBackgroundController::CancelPendingWallpaperOperation() { |
133 // Set canceled flag of previous request to skip unneeded loading. | 136 // Set canceled flag of previous request to skip unneeded loading. |
134 if (wallpaper_op_.get()) | 137 if (wallpaper_op_.get()) |
135 wallpaper_op_->Cancel(); | 138 wallpaper_op_->Cancel(); |
136 | 139 |
137 // Cancel reply callback for previous request. | 140 // Cancel reply callback for previous request. |
138 weak_ptr_factory_.InvalidateWeakPtrs(); | 141 weak_ptr_factory_.InvalidateWeakPtrs(); |
139 } | 142 } |
140 | 143 |
141 void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode() { | 144 void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode( |
| 145 SkColor color) { |
142 // Set a solid black background. | 146 // Set a solid black background. |
143 // TODO(derat): Remove this in favor of having the compositor only clear the | 147 // TODO(derat): Remove this in favor of having the compositor only clear the |
144 // viewport when there are regions not covered by a layer: | 148 // viewport when there are regions not covered by a layer: |
145 // http://crbug.com/113445 | 149 // http://crbug.com/113445 |
146 ui::Layer* background_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); | 150 ui::Layer* background_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); |
147 background_layer->SetColor(SK_ColorBLACK); | 151 background_layer->SetColor(color); |
148 root_window_->GetChildById( | 152 root_window_->GetChildById( |
149 internal::kShellWindowId_DesktopBackgroundContainer)-> | 153 internal::kShellWindowId_DesktopBackgroundContainer)-> |
150 layer()->Add(background_layer); | 154 layer()->Add(background_layer); |
151 GetRootWindowLayoutManager(root_window_)->SetBackgroundLayer( | 155 GetRootWindowLayoutManager(root_window_)->SetBackgroundLayer( |
152 background_layer); | 156 background_layer); |
153 GetRootWindowLayoutManager(root_window_)->SetBackgroundWidget(NULL); | 157 GetRootWindowLayoutManager(root_window_)->SetBackgroundWidget(NULL); |
154 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; | 158 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; |
155 } | 159 } |
156 | 160 |
157 void DesktopBackgroundController::SetDesktopBackgroundImageMode( | 161 void DesktopBackgroundController::SetDesktopBackgroundImageMode( |
(...skipping 15 matching lines...) Expand all Loading... |
173 wallpaper_op_ = NULL; | 177 wallpaper_op_ = NULL; |
174 } | 178 } |
175 | 179 |
176 void DesktopBackgroundController::CreateEmptyWallpaper() { | 180 void DesktopBackgroundController::CreateEmptyWallpaper() { |
177 gfx::ImageSkia dummy; | 181 gfx::ImageSkia dummy; |
178 internal::CreateDesktopBackground(dummy, CENTER, root_window_); | 182 internal::CreateDesktopBackground(dummy, CENTER, root_window_); |
179 desktop_background_mode_ = BACKGROUND_IMAGE; | 183 desktop_background_mode_ = BACKGROUND_IMAGE; |
180 } | 184 } |
181 | 185 |
182 } // namespace ash | 186 } // namespace ash |
OLD | NEW |