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

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

Issue 10384079: Reland "Implement random wallpaper feature" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 }, 222 },
223 }; 223 };
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 kLastRandomWallpaperIndex = 19; // The first 20 are random.
232 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 233 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6
233 #else 234 #else
234 // Set default wallpaper to the grey background for faster wallpaper loading 235 // 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 // time in browser tests. Otherwise, some of the tests will finish before
236 // wallpaper loaded and cause crashes. 237 // wallpaper loaded and cause crashes.
237 const int kDefaultWallpaperIndex = 6; // IDR_AURA_WALLPAPERS_5_GRADIENT5 238 const int kDefaultWallpaperIndex = 6; // IDR_AURA_WALLPAPERS_5_GRADIENT5
239 const int kLastRandomWallpaperIndex = 8;
238 const int kGuestWallpaperIndex = kDefaultWallpaperIndex; 240 const int kGuestWallpaperIndex = kDefaultWallpaperIndex;
239 #endif 241 #endif
240 242
241 } // namespace 243 } // namespace
242 244
243 namespace ash { 245 namespace ash {
244 246
245 int GetInvalidWallpaperIndex() { 247 int GetInvalidWallpaperIndex() {
246 return kInvalidWallpaperIndex; 248 return kInvalidWallpaperIndex;
247 } 249 }
248 250
249 int GetDefaultWallpaperIndex() { 251 int GetDefaultWallpaperIndex() {
250 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); 252 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount);
251 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); 253 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1);
252 } 254 }
253 255
254 int GetGuestWallpaperIndex() { 256 int GetGuestWallpaperIndex() {
255 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); 257 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount);
256 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); 258 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1);
257 } 259 }
258 260
261 int GetRandomWallpaperIndex() {
262 DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount);
263 return base::RandInt(0,
264 std::min(kLastRandomWallpaperIndex, kDefaultWallpaperCount - 1));
265 }
266
259 int GetWallpaperCount() { 267 int GetWallpaperCount() {
260 return kDefaultWallpaperCount; 268 return kDefaultWallpaperCount;
261 } 269 }
262 270
263 const WallpaperInfo& GetWallpaperInfo(int index) { 271 const WallpaperInfo& GetWallpaperInfo(int index) {
264 DCHECK(index >= 0 && index < kDefaultWallpaperCount); 272 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
265 return kDefaultWallpapers[index]; 273 return kDefaultWallpapers[index];
266 } 274 }
267 275
268 } // namespace ash 276 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_resources.h ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698