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

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

Issue 10207030: Asynchronously load wallpapers when user pod is selected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 8 years, 7 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
« no previous file with comments | « ash/desktop_background/desktop_background_resources.h ('k') | ash/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_resources.h" 5 #include "ash/desktop_background/desktop_background_resources.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers); 225 const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers);
226 const int kInvalidWallpaperIndex = -1; 226 const int kInvalidWallpaperIndex = -1;
227 227
228 // TODO(saintlou): These hardcoded indexes, although checked against the size 228 // TODO(saintlou): These hardcoded indexes, although checked against the size
229 // of the array are really hacky. 229 // of the array are really hacky.
230 #if defined(GOOGLE_CHROME_BUILD) 230 #if defined(GOOGLE_CHROME_BUILD)
231 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 231 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0
232 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 232 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6
233 #else 233 #else
234 const int kDefaultWallpaperIndex = 0; 234 // Set default wallpaper to the grey background for faster wallpaper loading
235 // time in browser tests. Otherwise, some of the tests will finish before
236 // wallpaper loaded and cause crashes.
237 const int kDefaultWallpaperIndex = 6; // IDR_AURA_WALLPAPERS_5_GRADIENT5
235 const int kGuestWallpaperIndex = kDefaultWallpaperIndex; 238 const int kGuestWallpaperIndex = kDefaultWallpaperIndex;
236 #endif 239 #endif
237 240
238 } // namespace 241 } // namespace
239 242
240 namespace ash { 243 namespace ash {
241 244
242 int GetInvalidWallpaperIndex() { 245 int GetInvalidWallpaperIndex() {
243 return kInvalidWallpaperIndex; 246 return kInvalidWallpaperIndex;
244 } 247 }
245 248
246 int GetDefaultWallpaperIndex() { 249 int GetDefaultWallpaperIndex() {
247 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); 250 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount);
248 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); 251 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1);
249 } 252 }
250 253
251 int GetGuestWallpaperIndex() { 254 int GetGuestWallpaperIndex() {
252 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); 255 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount);
253 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); 256 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1);
254 } 257 }
255 258
256 int GetWallpaperCount() { 259 int GetWallpaperCount() {
257 return kDefaultWallpaperCount; 260 return kDefaultWallpaperCount;
258 } 261 }
259 262
260 const SkBitmap& GetWallpaper(int index) { 263 const WallpaperInfo& GetWallpaperInfo(int index) {
261 DCHECK(index >= 0 && index < kDefaultWallpaperCount); 264 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
262 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
263 kDefaultWallpapers[index].id).ToSkBitmap();
264 }
265
266 const WallpaperInfo& GetWallpaperInfo(int index) {
267 return kDefaultWallpapers[index]; 265 return kDefaultWallpapers[index];
268 } 266 }
269 267
270 } // namespace ash 268 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_resources.h ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698