Chromium Code Reviews| Index: ash/desktop_background/desktop_background_controller.cc |
| diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc |
| index de3a1211b8871c2f4fdcb0b1e7ad644799172445..e2c5c213afc125677f03d7c659109ca9d02709f0 100644 |
| --- a/ash/desktop_background/desktop_background_controller.cc |
| +++ b/ash/desktop_background/desktop_background_controller.cc |
| @@ -150,6 +150,19 @@ void DesktopBackgroundController::OnRootWindowAdded( |
| InstallComponent(root_window); |
| } |
| +void DesktopBackgroundController::CacheDefaultWallpaper(int index) { |
| + if (index < 0) |
|
sky
2012/08/07 20:44:18
Should this be a DCHECK?
bshe
2012/08/07 22:00:01
Done
On 2012/08/07 20:44:18, sky wrote:
|
| + return; |
| + |
| + WallpaperResolution resolution = GetAppropriateResolution(); |
| + scoped_refptr<WallpaperOperation> wallpaper_op = |
| + new WallpaperOperation(index, resolution); |
| + base::WorkerPool::PostTask( |
| + FROM_HERE, |
| + base::Bind(&WallpaperOperation::Run, wallpaper_op), |
| + true); |
| +} |
| + |
| void DesktopBackgroundController::SetDefaultWallpaper(int index, |
| bool force_reload) { |
| // We should not change background when index is invalid. For instance, at |
| @@ -168,15 +181,7 @@ void DesktopBackgroundController::SetDefaultWallpaper(int index, |
| CancelPendingWallpaperOperation(); |
| - WallpaperResolution resolution = SMALL; |
| - Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| - for (Shell::RootWindowList::iterator iter = root_windows.begin(); |
| - iter != root_windows.end(); ++iter) { |
| - gfx::Size root_window_size = (*iter)->GetHostSize(); |
| - if (root_window_size.width() > kSmallWallpaperMaximalWidth || |
| - root_window_size.height() > kSmallWallpaperMaximalHeight) |
| - resolution = LARGE; |
| - } |
| + WallpaperResolution resolution = GetAppropriateResolution(); |
| wallpaper_op_ = new WallpaperOperation(index, resolution); |
| base::WorkerPool::PostTaskAndReply( |
| @@ -354,4 +359,17 @@ int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { |
| internal::kShellWindowId_DesktopBackgroundContainer; |
| } |
| +WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() { |
| + WallpaperResolution resolution = SMALL; |
| + Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
|
sky
2012/08/07 20:44:18
None of the ui code is thread safe.
bshe
2012/08/07 22:00:01
Sorry. do you mean the code that I add is not thre
|
| + for (Shell::RootWindowList::iterator iter = root_windows.begin(); |
| + iter != root_windows.end(); ++iter) { |
| + gfx::Size root_window_size = (*iter)->GetHostSize(); |
| + if (root_window_size.width() > kSmallWallpaperMaximalWidth || |
| + root_window_size.height() > kSmallWallpaperMaximalHeight) |
| + resolution = LARGE; |
| + } |
| + return resolution; |
| +} |
| + |
| } // namespace ash |