Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // -1 reserved for random wallpaper and -2 for customized wallpaper. | |
|
sky
2012/04/20 19:51:05
This is awful. How about an enum: RANDOM, CUSTOMIZ
bshe
2012/04/20 20:42:41
The positive index value is currently correspond t
| |
| 227 const int kInvalidWallpaperIndex = -3; | |
| 226 | 228 |
| 227 // TODO(saintlou): These hardcoded indexes, although checked against the size | 229 // TODO(saintlou): These hardcoded indexes, although checked against the size |
| 228 // of the array are really hacky. | 230 // of the array are really hacky. |
| 229 #if defined(GOOGLE_CHROME_BUILD) | 231 #if defined(GOOGLE_CHROME_BUILD) |
| 230 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 | 232 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 |
| 231 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 | 233 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 |
| 232 #else | 234 #else |
| 233 const int kDefaultWallpaperIndex = 0; | 235 const int kDefaultWallpaperIndex = 0; |
| 234 const int kGuestWallpaperIndex = kDefaultWallpaperIndex; | 236 const int kGuestWallpaperIndex = kDefaultWallpaperIndex; |
| 235 #endif | 237 #endif |
| 236 | 238 |
| 237 } // namespace | 239 } // namespace |
| 238 | 240 |
| 239 namespace ash { | 241 namespace ash { |
| 240 | 242 |
| 243 int GetInvalidWallpaperIndex() { | |
| 244 return kInvalidWallpaperIndex; | |
| 245 } | |
| 246 | |
| 241 int GetDefaultWallpaperIndex() { | 247 int GetDefaultWallpaperIndex() { |
| 242 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); | 248 DCHECK(kDefaultWallpaperIndex < kDefaultWallpaperCount); |
| 243 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); | 249 return std::min(kDefaultWallpaperIndex, kDefaultWallpaperCount - 1); |
| 244 } | 250 } |
| 245 | 251 |
| 246 int GetGuestWallpaperIndex() { | 252 int GetGuestWallpaperIndex() { |
| 247 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); | 253 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); |
| 248 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); | 254 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); |
| 249 } | 255 } |
| 250 | 256 |
| 251 int GetWallpaperCount() { | 257 int GetWallpaperCount() { |
| 252 return kDefaultWallpaperCount; | 258 return kDefaultWallpaperCount; |
| 253 } | 259 } |
| 254 | 260 |
| 255 const SkBitmap& GetWallpaper(int index) { | 261 const SkBitmap& GetWallpaper(int index) { |
| 256 DCHECK(index >= 0 && index < kDefaultWallpaperCount); | 262 DCHECK(index >= 0 && index < kDefaultWallpaperCount); |
| 257 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 263 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 258 kDefaultWallpapers[index].id).ToSkBitmap(); | 264 kDefaultWallpapers[index].id).ToSkBitmap(); |
| 259 } | 265 } |
| 260 | 266 |
| 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) { | 267 const WallpaperInfo& GetWallpaperInfo(int index) { |
| 268 return kDefaultWallpapers[index]; | 268 return kDefaultWallpapers[index]; |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace ash | 271 } // namespace ash |
| OLD | NEW |