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" |
11 #include "ash/desktop_background/user_wallpaper_delegate.h" | 11 #include "ash/desktop_background/user_wallpaper_delegate.h" |
12 #include "ash/desktop_background/wallpaper_resizer.h" | 12 #include "ash/desktop_background/wallpaper_resizer.h" |
13 #include "ash/display/display_info.h" | 13 #include "ash/display/display_info.h" |
14 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
15 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "ash/shell_factory.h" | 17 #include "ash/shell_factory.h" |
18 #include "ash/shell_window_ids.h" | 18 #include "ash/shell_window_ids.h" |
19 #include "ash/wm/root_window_layout_manager.h" | 19 #include "ash/wm/root_window_layout_manager.h" |
20 #include "base/bind.h" | 20 #include "base/bind.h" |
21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
22 #include "base/file_util.h" | 22 #include "base/file_util.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/synchronization/cancellation_flag.h" | 24 #include "base/synchronization/cancellation_flag.h" |
25 #include "base/threading/worker_pool.h" | 25 #include "base/threading/worker_pool.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "grit/ash_resources.h" | |
28 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
29 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
30 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
31 #include "ui/gfx/codec/jpeg_codec.h" | 30 #include "ui/gfx/codec/jpeg_codec.h" |
32 #include "ui/gfx/image/image_skia.h" | 31 #include "ui/gfx/image/image_skia.h" |
33 #include "ui/gfx/rect.h" | 32 #include "ui/gfx/rect.h" |
34 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
35 | 34 |
36 using ash::internal::DesktopBackgroundWidgetController; | 35 using ash::internal::DesktopBackgroundWidgetController; |
37 using content::BrowserThread; | 36 using content::BrowserThread; |
38 | 37 |
39 namespace ash { | 38 namespace ash { |
40 namespace { | 39 namespace { |
41 | 40 |
42 // How long to wait reloading the wallpaper after the max display has | 41 // How long to wait reloading the wallpaper after the max display has |
43 // changed? | 42 // changed? |
44 const int kWallpaperReloadDelayMs = 2000; | 43 const int kWallpaperReloadDelayMs = 2000; |
45 | 44 |
46 } // namespace | 45 } // namespace |
47 | 46 |
48 const int kSmallWallpaperMaxWidth = 1366; | |
49 const int kSmallWallpaperMaxHeight = 800; | |
50 const int kLargeWallpaperMaxWidth = 2560; | |
51 const int kLargeWallpaperMaxHeight = 1700; | |
52 const int kWallpaperThumbnailWidth = 108; | |
53 const int kWallpaperThumbnailHeight = 68; | |
54 | |
55 // DesktopBackgroundController::WallpaperLoader wraps background wallpaper | |
56 // loading. | |
57 class DesktopBackgroundController::WallpaperLoader | |
58 : public base::RefCountedThreadSafe< | |
59 DesktopBackgroundController::WallpaperLoader> { | |
60 public: | |
61 // If set, |file_path| must be a trusted (i.e. read-only, | |
62 // non-user-controlled) file containing a JPEG image. | |
63 WallpaperLoader(const base::FilePath& file_path, | |
64 WallpaperLayout file_layout, | |
65 int resource_id, | |
66 WallpaperLayout resource_layout) | |
67 : file_path_(file_path), | |
68 file_layout_(file_layout), | |
69 resource_id_(resource_id), | |
70 resource_layout_(resource_layout) { | |
71 } | |
72 | |
73 void LoadOnWorkerPoolThread() { | |
74 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
75 if (cancel_flag_.IsSet()) | |
76 return; | |
77 | |
78 if (!file_path_.empty()) { | |
79 VLOG(1) << "Loading " << file_path_.value(); | |
80 file_bitmap_ = LoadSkBitmapFromJPEGFile(file_path_); | |
81 } | |
82 | |
83 if (cancel_flag_.IsSet()) | |
84 return; | |
85 | |
86 if (file_bitmap_) { | |
87 gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(*file_bitmap_); | |
88 wallpaper_resizer_.reset(new WallpaperResizer( | |
89 image, GetMaxDisplaySizeInNative(), file_layout_)); | |
90 } else { | |
91 wallpaper_resizer_.reset(new WallpaperResizer( | |
92 resource_id_, GetMaxDisplaySizeInNative(), resource_layout_)); | |
93 } | |
94 } | |
95 | |
96 const base::FilePath& file_path() const { return file_path_; } | |
97 int resource_id() const { return resource_id_; } | |
98 | |
99 void Cancel() { | |
100 cancel_flag_.Set(); | |
101 } | |
102 | |
103 bool IsCanceled() { | |
104 return cancel_flag_.IsSet(); | |
105 } | |
106 | |
107 WallpaperResizer* ReleaseWallpaperResizer() { | |
108 return wallpaper_resizer_.release(); | |
109 } | |
110 | |
111 private: | |
112 friend class base::RefCountedThreadSafe< | |
113 DesktopBackgroundController::WallpaperLoader>; | |
114 | |
115 // Loads a JPEG image from |path|, a trusted file -- note that the image | |
116 // is not loaded in a sandboxed process. Returns an empty pointer on | |
117 // error. | |
118 static scoped_ptr<SkBitmap> LoadSkBitmapFromJPEGFile( | |
119 const base::FilePath& path) { | |
120 std::string data; | |
121 if (!base::ReadFileToString(path, &data)) { | |
122 LOG(ERROR) << "Unable to read data from " << path.value(); | |
123 return scoped_ptr<SkBitmap>(); | |
124 } | |
125 | |
126 scoped_ptr<SkBitmap> bitmap(gfx::JPEGCodec::Decode( | |
127 reinterpret_cast<const unsigned char*>(data.data()), data.size())); | |
128 if (!bitmap) | |
129 LOG(ERROR) << "Unable to decode JPEG data from " << path.value(); | |
130 return bitmap.Pass(); | |
131 } | |
132 | |
133 ~WallpaperLoader() {} | |
134 | |
135 base::CancellationFlag cancel_flag_; | |
136 | |
137 // Bitmap loaded from |file_path_|. | |
138 scoped_ptr<SkBitmap> file_bitmap_; | |
139 | |
140 scoped_ptr<WallpaperResizer> wallpaper_resizer_; | |
141 | |
142 // Path to a trusted JPEG file. | |
143 base::FilePath file_path_; | |
144 | |
145 // Layout to be used when displaying the image from |file_path_|. | |
146 WallpaperLayout file_layout_; | |
147 | |
148 // ID of an image resource to use if |file_path_| is empty or unloadable. | |
149 int resource_id_; | |
150 | |
151 // Layout to be used when displaying |resource_id_|. | |
152 WallpaperLayout resource_layout_; | |
153 | |
154 DISALLOW_COPY_AND_ASSIGN(WallpaperLoader); | |
155 }; | |
156 | |
157 DesktopBackgroundController::DesktopBackgroundController() | 47 DesktopBackgroundController::DesktopBackgroundController() |
158 : command_line_for_testing_(NULL), | 48 : locked_(false), |
159 locked_(false), | |
160 desktop_background_mode_(BACKGROUND_NONE), | 49 desktop_background_mode_(BACKGROUND_NONE), |
161 current_default_wallpaper_resource_id_(-1), | |
162 weak_ptr_factory_(this), | |
163 wallpaper_reload_delay_(kWallpaperReloadDelayMs) { | 50 wallpaper_reload_delay_(kWallpaperReloadDelayMs) { |
164 Shell::GetInstance()->display_controller()->AddObserver(this); | 51 Shell::GetInstance()->display_controller()->AddObserver(this); |
165 } | 52 } |
166 | 53 |
167 DesktopBackgroundController::~DesktopBackgroundController() { | 54 DesktopBackgroundController::~DesktopBackgroundController() { |
168 CancelDefaultWallpaperLoader(); | |
169 Shell::GetInstance()->display_controller()->RemoveObserver(this); | 55 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
170 } | 56 } |
171 | 57 |
172 gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { | 58 gfx::ImageSkia DesktopBackgroundController::GetWallpaper() const { |
173 if (current_wallpaper_) | 59 if (current_wallpaper_) |
174 return current_wallpaper_->image(); | 60 return current_wallpaper_->image(); |
175 return gfx::ImageSkia(); | 61 return gfx::ImageSkia(); |
176 } | 62 } |
177 | 63 |
178 void DesktopBackgroundController::AddObserver( | 64 void DesktopBackgroundController::AddObserver( |
(...skipping 22 matching lines...) Expand all Loading... | |
201 if (current_max_display_size_ != max_display_size) { | 87 if (current_max_display_size_ != max_display_size) { |
202 current_max_display_size_ = max_display_size; | 88 current_max_display_size_ = max_display_size; |
203 if (desktop_background_mode_ == BACKGROUND_IMAGE && | 89 if (desktop_background_mode_ == BACKGROUND_IMAGE && |
204 current_wallpaper_.get()) | 90 current_wallpaper_.get()) |
205 UpdateWallpaper(); | 91 UpdateWallpaper(); |
206 } | 92 } |
207 | 93 |
208 InstallDesktopController(root_window); | 94 InstallDesktopController(root_window); |
209 } | 95 } |
210 | 96 |
211 bool DesktopBackgroundController::SetDefaultWallpaper(bool is_guest) { | 97 bool DesktopBackgroundController::SetWallpaper(const gfx::ImageSkia& image, |
212 VLOG(1) << "SetDefaultWallpaper: is_guest=" << is_guest; | 98 WallpaperLayout layout) { |
213 const bool use_large = | 99 VLOG(1) << "SetWallpaper: image_id=" << WallpaperResizer::GetImageId(image) |
214 GetAppropriateResolution() == WALLPAPER_RESOLUTION_LARGE; | 100 << " layout=" << layout; |
215 | 101 |
216 base::FilePath file_path; | 102 if (WallpaperIsAlreadyLoaded(&image, -1, layout)) { |
217 WallpaperLayout file_layout = use_large ? WALLPAPER_LAYOUT_CENTER_CROPPED : | 103 VLOG(1) << "Wallpaper is already loaded"; |
218 WALLPAPER_LAYOUT_CENTER; | |
219 int resource_id = use_large ? IDR_AURA_WALLPAPER_DEFAULT_LARGE : | |
220 IDR_AURA_WALLPAPER_DEFAULT_SMALL; | |
221 WallpaperLayout resource_layout = WALLPAPER_LAYOUT_TILE; | |
222 | |
223 CommandLine* command_line = command_line_for_testing_ ? | |
224 command_line_for_testing_ : CommandLine::ForCurrentProcess(); | |
225 const char* switch_name = NULL; | |
226 if (is_guest) { | |
227 switch_name = use_large ? switches::kAshGuestWallpaperLarge : | |
228 switches::kAshGuestWallpaperSmall; | |
229 } else { | |
230 switch_name = use_large ? switches::kAshDefaultWallpaperLarge : | |
231 switches::kAshDefaultWallpaperSmall; | |
232 } | |
233 file_path = command_line->GetSwitchValuePath(switch_name); | |
234 | |
235 if (DefaultWallpaperIsAlreadyLoadingOrLoaded(file_path, resource_id)) { | |
236 VLOG(1) << "Default wallpaper is already loading or loaded"; | |
237 return false; | 104 return false; |
238 } | 105 } |
239 | 106 |
240 CancelDefaultWallpaperLoader(); | 107 current_wallpaper_.reset( |
241 default_wallpaper_loader_ = new WallpaperLoader( | 108 new WallpaperResizer(image, GetMaxDisplaySizeInNative(), layout)); |
242 file_path, file_layout, resource_id, resource_layout); | 109 current_wallpaper_->StartResize(); |
243 base::WorkerPool::PostTaskAndReply( | 110 |
244 FROM_HERE, | 111 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, |
245 base::Bind(&WallpaperLoader::LoadOnWorkerPoolThread, | 112 observers_, |
246 default_wallpaper_loader_), | 113 OnWallpaperDataChanged()); |
247 base::Bind(&DesktopBackgroundController::OnDefaultWallpaperLoadCompleted, | 114 SetDesktopBackgroundImageMode(); |
248 weak_ptr_factory_.GetWeakPtr(), | |
249 default_wallpaper_loader_), | |
250 true /* task_is_slow */); | |
251 return true; | 115 return true; |
252 } | 116 } |
253 | 117 |
254 void DesktopBackgroundController::SetCustomWallpaper( | 118 bool DesktopBackgroundController::SetWallpaper(int resource_id, |
255 const gfx::ImageSkia& image, | 119 WallpaperLayout layout) { |
256 WallpaperLayout layout) { | 120 VLOG(1) << "SetWallpaper: resource_id=" << resource_id |
257 VLOG(1) << "SetCustomWallpaper: image_id=" | 121 << " layout=" << layout; |
258 << WallpaperResizer::GetImageId(image) << " layout=" << layout; | |
259 CancelDefaultWallpaperLoader(); | |
260 | 122 |
261 if (CustomWallpaperIsAlreadyLoaded(image)) { | 123 if (WallpaperIsAlreadyLoaded(NULL, resource_id, layout)) { |
262 VLOG(1) << "Custom wallpaper is already loaded"; | 124 VLOG(1) << "Wallpaper is already loaded"; |
263 return; | 125 return false; |
264 } | 126 } |
265 | 127 current_wallpaper_.reset( |
266 current_wallpaper_.reset(new WallpaperResizer( | 128 new WallpaperResizer(resource_id, GetMaxDisplaySizeInNative(), layout)); |
267 image, GetMaxDisplaySizeInNative(), layout)); | |
268 current_wallpaper_->StartResize(); | 129 current_wallpaper_->StartResize(); |
269 | 130 |
270 current_default_wallpaper_path_ = base::FilePath(); | |
271 current_default_wallpaper_resource_id_ = -1; | |
272 | |
273 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, | 131 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, |
274 OnWallpaperDataChanged()); | 132 OnWallpaperDataChanged()); |
275 SetDesktopBackgroundImageMode(); | 133 SetDesktopBackgroundImageMode(); |
276 } | 134 return true; |
277 | |
278 void DesktopBackgroundController::CancelDefaultWallpaperLoader() { | |
279 // Set canceled flag of previous request to skip unneeded loading. | |
280 if (default_wallpaper_loader_.get()) | |
281 default_wallpaper_loader_->Cancel(); | |
282 | |
283 // Cancel reply callback for previous request. | |
284 weak_ptr_factory_.InvalidateWeakPtrs(); | |
285 } | 135 } |
286 | 136 |
287 void DesktopBackgroundController::CreateEmptyWallpaper() { | 137 void DesktopBackgroundController::CreateEmptyWallpaper() { |
288 current_wallpaper_.reset(NULL); | 138 current_wallpaper_.reset(NULL); |
289 SetDesktopBackgroundImageMode(); | 139 SetDesktopBackgroundImageMode(); |
290 } | 140 } |
291 | 141 |
292 WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { | |
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
294 gfx::Size size = GetMaxDisplaySizeInNative(); | |
295 return (size.width() > kSmallWallpaperMaxWidth || | |
296 size.height() > kSmallWallpaperMaxHeight) ? | |
297 WALLPAPER_RESOLUTION_LARGE : WALLPAPER_RESOLUTION_SMALL; | |
298 } | |
299 | |
300 bool DesktopBackgroundController::MoveDesktopToLockedContainer() { | 142 bool DesktopBackgroundController::MoveDesktopToLockedContainer() { |
301 if (locked_) | 143 if (locked_) |
302 return false; | 144 return false; |
303 locked_ = true; | 145 locked_ = true; |
304 return ReparentBackgroundWidgets(GetBackgroundContainerId(false), | 146 return ReparentBackgroundWidgets(GetBackgroundContainerId(false), |
305 GetBackgroundContainerId(true)); | 147 GetBackgroundContainerId(true)); |
306 } | 148 } |
307 | 149 |
308 bool DesktopBackgroundController::MoveDesktopToUnlockedContainer() { | 150 bool DesktopBackgroundController::MoveDesktopToUnlockedContainer() { |
309 if (!locked_) | 151 if (!locked_) |
(...skipping 11 matching lines...) Expand all Loading... | |
321 current_wallpaper_.get()) { | 163 current_wallpaper_.get()) { |
322 timer_.Stop(); | 164 timer_.Stop(); |
323 timer_.Start(FROM_HERE, | 165 timer_.Start(FROM_HERE, |
324 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), | 166 base::TimeDelta::FromMilliseconds(wallpaper_reload_delay_), |
325 this, | 167 this, |
326 &DesktopBackgroundController::UpdateWallpaper); | 168 &DesktopBackgroundController::UpdateWallpaper); |
327 } | 169 } |
328 } | 170 } |
329 } | 171 } |
330 | 172 |
331 bool DesktopBackgroundController::DefaultWallpaperIsAlreadyLoadingOrLoaded( | 173 // static |
332 const base::FilePath& image_file, | 174 gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() { |
333 int image_resource_id) const { | 175 int width = 0; |
334 return (default_wallpaper_loader_.get() && | 176 int height = 0; |
335 !default_wallpaper_loader_->IsCanceled() && | 177 std::vector<gfx::Display> displays = Shell::GetScreen()->GetAllDisplays(); |
336 default_wallpaper_loader_->file_path() == image_file && | 178 internal::DisplayManager* display_manager = |
337 default_wallpaper_loader_->resource_id() == image_resource_id) || | 179 Shell::GetInstance()->display_manager(); |
338 (current_wallpaper_.get() && | 180 |
339 current_default_wallpaper_path_ == image_file && | 181 for (std::vector<gfx::Display>::iterator iter = displays.begin(); |
340 current_default_wallpaper_resource_id_ == image_resource_id); | 182 iter != displays.end(); |
183 ++iter) { | |
184 // Don't use size_in_pixel because we want to use the native pixel size. | |
185 gfx::Size size_in_pixel = | |
186 display_manager->GetDisplayInfo(iter->id()).bounds_in_native().size(); | |
187 if (iter->rotation() == gfx::Display::ROTATE_90 || | |
188 iter->rotation() == gfx::Display::ROTATE_270) { | |
189 size_in_pixel = gfx::Size(size_in_pixel.height(), size_in_pixel.width()); | |
190 } | |
191 width = std::max(size_in_pixel.width(), width); | |
192 height = std::max(size_in_pixel.height(), height); | |
193 } | |
194 return gfx::Size(width, height); | |
341 } | 195 } |
342 | 196 |
343 bool DesktopBackgroundController::CustomWallpaperIsAlreadyLoaded( | 197 bool DesktopBackgroundController::WallpaperIsAlreadyLoaded( |
344 const gfx::ImageSkia& image) const { | 198 const gfx::ImageSkia* image, |
345 return current_wallpaper_.get() && | 199 int resource_id, |
346 (WallpaperResizer::GetImageId(image) == | 200 WallpaperLayout layout) const { |
347 current_wallpaper_->original_image_id()); | 201 if (!current_wallpaper_.get()) |
202 return false; | |
203 | |
204 if (layout != current_wallpaper_->layout()) | |
205 return false; | |
206 | |
207 if (image != NULL) | |
Daniel Erat
2014/04/04 02:45:49
nit: "if (image)"; also use curly brackets since t
Alexander Alekseev
2014/04/05 03:35:13
Done.
| |
208 return WallpaperResizer::GetImageId(*image) == | |
209 current_wallpaper_->original_image_id(); | |
210 | |
211 return current_wallpaper_->resource_id() == resource_id; | |
348 } | 212 } |
349 | 213 |
350 void DesktopBackgroundController::SetDesktopBackgroundImageMode() { | 214 void DesktopBackgroundController::SetDesktopBackgroundImageMode() { |
351 desktop_background_mode_ = BACKGROUND_IMAGE; | 215 desktop_background_mode_ = BACKGROUND_IMAGE; |
352 InstallDesktopControllerForAllWindows(); | 216 InstallDesktopControllerForAllWindows(); |
353 } | 217 } |
354 | 218 |
355 void DesktopBackgroundController::OnDefaultWallpaperLoadCompleted( | |
356 scoped_refptr<WallpaperLoader> loader) { | |
357 VLOG(1) << "OnDefaultWallpaperLoadCompleted"; | |
358 current_wallpaper_.reset(loader->ReleaseWallpaperResizer()); | |
359 current_wallpaper_->StartResize(); | |
360 current_default_wallpaper_path_ = loader->file_path(); | |
361 current_default_wallpaper_resource_id_ = loader->resource_id(); | |
362 FOR_EACH_OBSERVER(DesktopBackgroundControllerObserver, observers_, | |
363 OnWallpaperDataChanged()); | |
364 | |
365 SetDesktopBackgroundImageMode(); | |
366 | |
367 DCHECK(loader.get() == default_wallpaper_loader_.get()); | |
368 default_wallpaper_loader_ = NULL; | |
369 } | |
370 | |
371 void DesktopBackgroundController::InstallDesktopController( | 219 void DesktopBackgroundController::InstallDesktopController( |
372 aura::Window* root_window) { | 220 aura::Window* root_window) { |
373 internal::DesktopBackgroundWidgetController* component = NULL; | 221 internal::DesktopBackgroundWidgetController* component = NULL; |
374 int container_id = GetBackgroundContainerId(locked_); | 222 int container_id = GetBackgroundContainerId(locked_); |
375 | 223 |
376 switch (desktop_background_mode_) { | 224 switch (desktop_background_mode_) { |
377 case BACKGROUND_IMAGE: { | 225 case BACKGROUND_IMAGE: { |
378 views::Widget* widget = internal::CreateDesktopBackground(root_window, | 226 views::Widget* widget = internal::CreateDesktopBackground(root_window, |
379 container_id); | 227 container_id); |
380 component = new internal::DesktopBackgroundWidgetController(widget); | 228 component = new internal::DesktopBackgroundWidgetController(widget); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 return moved; | 286 return moved; |
439 } | 287 } |
440 | 288 |
441 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { | 289 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
442 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : | 290 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : |
443 internal::kShellWindowId_DesktopBackgroundContainer; | 291 internal::kShellWindowId_DesktopBackgroundContainer; |
444 } | 292 } |
445 | 293 |
446 void DesktopBackgroundController::UpdateWallpaper() { | 294 void DesktopBackgroundController::UpdateWallpaper() { |
447 current_wallpaper_.reset(NULL); | 295 current_wallpaper_.reset(NULL); |
448 current_default_wallpaper_path_ = base::FilePath(); | |
449 current_default_wallpaper_resource_id_ = -1; | |
450 ash::Shell::GetInstance()->user_wallpaper_delegate()-> | 296 ash::Shell::GetInstance()->user_wallpaper_delegate()-> |
451 UpdateWallpaper(true /* clear cache */); | 297 UpdateWallpaper(true /* clear cache */); |
452 } | 298 } |
453 | 299 |
454 // static | |
455 gfx::Size DesktopBackgroundController::GetMaxDisplaySizeInNative() { | |
456 int width = 0; | |
457 int height = 0; | |
458 std::vector<gfx::Display> displays = Shell::GetScreen()->GetAllDisplays(); | |
459 internal::DisplayManager* display_manager = | |
460 Shell::GetInstance()->display_manager(); | |
461 | |
462 for (std::vector<gfx::Display>::iterator iter = displays.begin(); | |
463 iter != displays.end(); ++iter) { | |
464 // Don't use size_in_pixel because we want to use the native pixel size. | |
465 gfx::Size size_in_pixel = | |
466 display_manager->GetDisplayInfo(iter->id()).bounds_in_native().size(); | |
467 if (iter->rotation() == gfx::Display::ROTATE_90 || | |
468 iter->rotation() == gfx::Display::ROTATE_270) { | |
469 size_in_pixel = gfx::Size(size_in_pixel.height(), size_in_pixel.width()); | |
470 } | |
471 width = std::max(size_in_pixel.width(), width); | |
472 height = std::max(size_in_pixel.height(), height); | |
473 } | |
474 return gfx::Size(width, height); | |
475 } | |
476 | |
477 } // namespace ash | 300 } // namespace ash |
OLD | NEW |