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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 desktop_background_mode_(BACKGROUND_NONE), | 122 desktop_background_mode_(BACKGROUND_NONE), |
123 background_color_(kTransparentColor), | 123 background_color_(kTransparentColor), |
124 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 124 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
125 } | 125 } |
126 | 126 |
127 DesktopBackgroundController::~DesktopBackgroundController() { | 127 DesktopBackgroundController::~DesktopBackgroundController() { |
128 CancelPendingWallpaperOperation(); | 128 CancelPendingWallpaperOperation(); |
129 } | 129 } |
130 | 130 |
131 gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { | 131 gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { |
132 if (current_wallpaper_.get()) | 132 if (current_wallpaper_) |
133 return current_wallpaper_->wallpaper_image(); | 133 return current_wallpaper_->wallpaper_image(); |
134 return gfx::ImageSkia(); | 134 return gfx::ImageSkia(); |
135 } | 135 } |
136 | 136 |
137 void DesktopBackgroundController::AddObserver( | 137 void DesktopBackgroundController::AddObserver( |
138 DesktopBackgroundControllerObserver* observer) { | 138 DesktopBackgroundControllerObserver* observer) { |
139 observers_.AddObserver(observer); | 139 observers_.AddObserver(observer); |
140 } | 140 } |
141 | 141 |
142 void DesktopBackgroundController::RemoveObserver( | 142 void DesktopBackgroundController::RemoveObserver( |
143 DesktopBackgroundControllerObserver* observer) { | 143 DesktopBackgroundControllerObserver* observer) { |
144 observers_.RemoveObserver(observer); | 144 observers_.RemoveObserver(observer); |
145 } | 145 } |
146 | 146 |
147 WallpaperLayout DesktopBackgroundController::GetWallpaperLayout() const { | 147 WallpaperLayout DesktopBackgroundController::GetWallpaperLayout() const { |
148 if (current_wallpaper_.get()) | 148 if (current_wallpaper_) |
149 return current_wallpaper_->wallpaper_info().layout; | 149 return current_wallpaper_->wallpaper_info().layout; |
150 return WALLPAPER_LAYOUT_CENTER_CROPPED; | 150 return WALLPAPER_LAYOUT_CENTER_CROPPED; |
151 } | 151 } |
152 | 152 |
153 gfx::ImageSkia DesktopBackgroundController::GetCurrentWallpaperImage() { | 153 gfx::ImageSkia DesktopBackgroundController::GetCurrentWallpaperImage() { |
154 if (desktop_background_mode_ != BACKGROUND_IMAGE) | 154 if (desktop_background_mode_ != BACKGROUND_IMAGE) |
155 return gfx::ImageSkia(); | 155 return gfx::ImageSkia(); |
156 return GetWallpaper(); | 156 return GetWallpaper(); |
157 } | 157 } |
158 | 158 |
159 int DesktopBackgroundController::GetWallpaperIDR() const { | 159 int DesktopBackgroundController::GetWallpaperIDR() const { |
160 if (wallpaper_loader_.get()) | 160 if (wallpaper_loader_) |
161 return wallpaper_loader_->idr(); | 161 return wallpaper_loader_->idr(); |
162 else if (current_wallpaper_.get()) | 162 else if (current_wallpaper_) |
163 return current_wallpaper_->wallpaper_info().idr; | 163 return current_wallpaper_->wallpaper_info().idr; |
164 else | 164 else |
165 return -1; | 165 return -1; |
166 } | 166 } |
167 | 167 |
168 void DesktopBackgroundController::OnRootWindowAdded( | 168 void DesktopBackgroundController::OnRootWindowAdded( |
169 aura::RootWindow* root_window) { | 169 aura::RootWindow* root_window) { |
170 // The background hasn't been set yet. | 170 // The background hasn't been set yet. |
171 if (desktop_background_mode_ == BACKGROUND_NONE) | 171 if (desktop_background_mode_ == BACKGROUND_NONE) |
172 return; | 172 return; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 WallpaperInfo info = { -1, layout }; | 217 WallpaperInfo info = { -1, layout }; |
218 current_wallpaper_.reset(new WallpaperResizer(info, wallpaper)); | 218 current_wallpaper_.reset(new WallpaperResizer(info, wallpaper)); |
219 current_wallpaper_->StartResize(); | 219 current_wallpaper_->StartResize(); |
220 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, | 220 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, |
221 OnWallpaperDataChanged()); | 221 OnWallpaperDataChanged()); |
222 SetDesktopBackgroundImageMode(); | 222 SetDesktopBackgroundImageMode(); |
223 } | 223 } |
224 | 224 |
225 void DesktopBackgroundController::CancelPendingWallpaperOperation() { | 225 void DesktopBackgroundController::CancelPendingWallpaperOperation() { |
226 // Set canceled flag of previous request to skip unneeded loading. | 226 // Set canceled flag of previous request to skip unneeded loading. |
227 if (wallpaper_loader_.get()) | 227 if (wallpaper_loader_) |
228 wallpaper_loader_->Cancel(); | 228 wallpaper_loader_->Cancel(); |
229 | 229 |
230 // Cancel reply callback for previous request. | 230 // Cancel reply callback for previous request. |
231 weak_ptr_factory_.InvalidateWeakPtrs(); | 231 weak_ptr_factory_.InvalidateWeakPtrs(); |
232 } | 232 } |
233 | 233 |
234 void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode( | 234 void DesktopBackgroundController::SetDesktopBackgroundSolidColorMode( |
235 SkColor color) { | 235 SkColor color) { |
236 background_color_ = color; | 236 background_color_ = color; |
237 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; | 237 desktop_background_mode_ = BACKGROUND_SOLID_COLOR; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 return moved; | 405 return moved; |
406 } | 406 } |
407 | 407 |
408 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 408 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
409 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : | 409 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : |
410 internal::kShellWindowId_DesktopBackgroundContainer; | 410 internal::kShellWindowId_DesktopBackgroundContainer; |
411 } | 411 } |
412 | 412 |
413 } // namespace ash | 413 } // namespace ash |
OLD | NEW |