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

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: Merge to trunk 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;
226 227
227 // TODO(saintlou): These hardcoded indexes, although checked against the size 228 // TODO(saintlou): These hardcoded indexes, although checked against the size
228 // of the array are really hacky. 229 // of the array are really hacky.
229 #if defined(GOOGLE_CHROME_BUILD) 230 #if defined(GOOGLE_CHROME_BUILD)
230 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 231 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0
231 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 232 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6
232 #else 233 #else
233 const int kDefaultWallpaperIndex = 0; 234 const int kDefaultWallpaperIndex = 0;
234 const int kGuestWallpaperIndex = kDefaultWallpaperIndex; 235 const int kGuestWallpaperIndex = kDefaultWallpaperIndex;
235 #endif 236 #endif
236 237
237 } // namespace 238 } // namespace
238 239
239 namespace ash { 240 namespace ash {
240 241
242 int GetInvalidWallpaperIndex() {
243 return kInvalidWallpaperIndex;
244 }
245
241 int GetDefaultWallpaperIndex() { 246 int GetDefaultWallpaperIndex() {
242 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); 247 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount);
243 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); 248 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1);
244 } 249 }
245 250
246 int GetGuestWallpaperIndex() { 251 int GetGuestWallpaperIndex() {
247 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); 252 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount);
248 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); 253 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1);
249 } 254 }
250 255
251 int GetWallpaperCount() { 256 int GetWallpaperCount() {
252 return kDefaultWallpaperCount; 257 return kDefaultWallpaperCount;
253 } 258 }
254 259
255 const SkBitmap& GetWallpaper(int index) { 260 const SkBitmap& GetWallpaper(int index) {
256 DCHECK(index >= 0 && index < kDefaultWallpaperCount); 261 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
257 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed( 262 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
258 kDefaultWallpapers[index].id).ToSkBitmap(); 263 kDefaultWallpapers[index].id).ToSkBitmap();
259 } 264 }
260 265
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) { 266 const WallpaperInfo& GetWallpaperInfo(int index) {
268 return kDefaultWallpapers[index]; 267 return kDefaultWallpapers[index];
269 } 268 }
270 269
271 } // namespace ash 270 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698