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

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

Issue 10021066: Replace the index mapping of wallpaper picker UI and hard coded wallpaper index in C++ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add enum Created 8 years, 8 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 { 216 {
217 IDR_AURA_WALLPAPERS_5_GRADIENT7, 217 IDR_AURA_WALLPAPERS_5_GRADIENT7,
218 IDR_AURA_WALLPAPERS_5_GRADIENT7_THUMB, 218 IDR_AURA_WALLPAPERS_5_GRADIENT7_THUMB,
219 ash::TILE, 219 ash::TILE,
220 "Chromium", 220 "Chromium",
221 "http://www.chromium.org" 221 "http://www.chromium.org"
222 }, 222 },
223 }; 223 };
224 224
225 const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers); 225 const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers);
226 const int kInvalidWallpaperIndex = -1;
227 enum {
sky 2012/04/20 22:39:16 Used named enums, but don't add the enum until you
228 RANDOM,
229 CUSTOMIZED,
230 DEFAULT
231 };
226 232
227 // TODO(saintlou): These hardcoded indexes, although checked against the size 233 // TODO(saintlou): These hardcoded indexes, although checked against the size
228 // of the array are really hacky. 234 // of the array are really hacky.
229 #if defined(GOOGLE_CHROME_BUILD) 235 #if defined(GOOGLE_CHROME_BUILD)
230 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 236 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0
231 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 237 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6
232 #else 238 #else
233 const int kDefaultWallpaperIndex = 0; 239 const int kDefaultWallpaperIndex = 0;
234 const int kGuestWallpaperIndex = kDefaultWallpaperIndex; 240 const int kGuestWallpaperIndex = kDefaultWallpaperIndex;
235 #endif 241 #endif
236 242
237 } // namespace 243 } // namespace
238 244
239 namespace ash { 245 namespace ash {
240 246
247 int GetInvalidWallpaperIndex() {
248 return kInvalidWallpaperIndex;
249 }
250
241 int GetDefaultWallpaperIndex() { 251 int GetDefaultWallpaperIndex() {
242 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); 252 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount);
243 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); 253 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1);
244 } 254 }
245 255
246 int GetGuestWallpaperIndex() { 256 int GetGuestWallpaperIndex() {
247 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); 257 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount);
248 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); 258 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1);
249 } 259 }
250 260
251 int GetWallpaperCount() { 261 int GetWallpaperCount() {
252 return kDefaultWallpaperCount; 262 return kDefaultWallpaperCount;
253 } 263 }
254 264
255 const SkBitmap& GetWallpaper(int index) { 265 const SkBitmap& GetWallpaper(int index) {
256 DCHECK(index >= 0 && index < kDefaultWallpaperCount); 266 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
257 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed( 267 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
258 kDefaultWallpapers[index].id).ToSkBitmap(); 268 kDefaultWallpapers[index].id).ToSkBitmap();
259 } 269 }
260 270
261 const SkBitmap& GetWallpaperThumbnail(int index) {
262 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
263 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
264 kDefaultWallpapers[index].thumb_id).ToSkBitmap();
265 }
266
267 const WallpaperInfo& GetWallpaperInfo(int index) { 271 const WallpaperInfo& GetWallpaperInfo(int index) {
268 return kDefaultWallpapers[index]; 272 return kDefaultWallpapers[index];
269 } 273 }
270 274
271 } // namespace ash 275 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698