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