Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: ash/desktop_background/desktop_background_controller.cc

Issue 10827154: Preload default wallpaper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use DCHECK replace if cause. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/desktop_background/desktop_background_widget_controller.h" 8 #include "ash/desktop_background/desktop_background_widget_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_factory.h" 10 #include "ash/shell_factory.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 wallpaper_height < root_window_size.height()) && 143 wallpaper_height < root_window_size.height()) &&
144 current_wallpaper_->wallpaper_index != -1 && 144 current_wallpaper_->wallpaper_index != -1 &&
145 current_wallpaper_->wallpaper_layout != TILE) 145 current_wallpaper_->wallpaper_layout != TILE)
146 SetDefaultWallpaper(current_wallpaper_->wallpaper_index, true); 146 SetDefaultWallpaper(current_wallpaper_->wallpaper_index, true);
147 } 147 }
148 } 148 }
149 149
150 InstallComponent(root_window); 150 InstallComponent(root_window);
151 } 151 }
152 152
153 void DesktopBackgroundController::CacheDefaultWallpaper(int index) {
154 DCHECK(index >= 0);
155
156 WallpaperResolution resolution = GetAppropriateResolution();
157 scoped_refptr<WallpaperOperation> wallpaper_op =
158 new WallpaperOperation(index, resolution);
159 base::WorkerPool::PostTask(
160 FROM_HERE,
161 base::Bind(&WallpaperOperation::Run, wallpaper_op),
162 true);
163 }
164
153 void DesktopBackgroundController::SetDefaultWallpaper(int index, 165 void DesktopBackgroundController::SetDefaultWallpaper(int index,
154 bool force_reload) { 166 bool force_reload) {
155 // We should not change background when index is invalid. For instance, at 167 // We should not change background when index is invalid. For instance, at
156 // login screen or stub_user login. 168 // login screen or stub_user login.
157 if (index == GetInvalidWallpaperIndex()) { 169 if (index == GetInvalidWallpaperIndex()) {
158 CreateEmptyWallpaper(); 170 CreateEmptyWallpaper();
159 return; 171 return;
160 } else if (index == GetSolidColorIndex()) { 172 } else if (index == GetSolidColorIndex()) {
161 SetDesktopBackgroundSolidColorMode(kLoginWallpaperColor); 173 SetDesktopBackgroundSolidColorMode(kLoginWallpaperColor);
162 return; 174 return;
163 } 175 }
164 176
165 if (!force_reload && current_wallpaper_.get() && 177 if (!force_reload && current_wallpaper_.get() &&
166 current_wallpaper_->wallpaper_index == index) 178 current_wallpaper_->wallpaper_index == index)
167 return; 179 return;
168 180
169 CancelPendingWallpaperOperation(); 181 CancelPendingWallpaperOperation();
170 182
171 WallpaperResolution resolution = SMALL; 183 WallpaperResolution resolution = GetAppropriateResolution();
172 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
173 for (Shell::RootWindowList::iterator iter = root_windows.begin();
174 iter != root_windows.end(); ++iter) {
175 gfx::Size root_window_size = (*iter)->GetHostSize();
176 if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
177 root_window_size.height() > kSmallWallpaperMaximalHeight)
178 resolution = LARGE;
179 }
180 184
181 wallpaper_op_ = new WallpaperOperation(index, resolution); 185 wallpaper_op_ = new WallpaperOperation(index, resolution);
182 base::WorkerPool::PostTaskAndReply( 186 base::WorkerPool::PostTaskAndReply(
183 FROM_HERE, 187 FROM_HERE,
184 base::Bind(&WallpaperOperation::Run, wallpaper_op_), 188 base::Bind(&WallpaperOperation::Run, wallpaper_op_),
185 base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted, 189 base::Bind(&DesktopBackgroundController::OnWallpaperLoadCompleted,
186 weak_ptr_factory_.GetWeakPtr(), 190 weak_ptr_factory_.GetWeakPtr(),
187 wallpaper_op_), 191 wallpaper_op_),
188 true /* task_is_slow */); 192 true /* task_is_slow */);
189 } 193 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 src_container, 351 src_container,
348 dst_container); 352 dst_container);
349 } 353 }
350 } 354 }
351 355
352 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) { 356 int DesktopBackgroundController::GetBackgroundContainerId(bool locked) {
353 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer : 357 return locked ? internal::kShellWindowId_LockScreenBackgroundContainer :
354 internal::kShellWindowId_DesktopBackgroundContainer; 358 internal::kShellWindowId_DesktopBackgroundContainer;
355 } 359 }
356 360
361 WallpaperResolution DesktopBackgroundController::GetAppropriateResolution() {
362 WallpaperResolution resolution = SMALL;
363 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
364 for (Shell::RootWindowList::iterator iter = root_windows.begin();
365 iter != root_windows.end(); ++iter) {
366 gfx::Size root_window_size = (*iter)->GetHostSize();
367 if (root_window_size.width() > kSmallWallpaperMaximalWidth ||
368 root_window_size.height() > kSmallWallpaperMaximalHeight)
369 resolution = LARGE;
370 }
371 return resolution;
372 }
373
357 } // namespace ash 374 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller.h ('k') | chrome/browser/chromeos/login/user_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698