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

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

Issue 10754014: Wallpaper manager backend APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error on linux_chromeos_clang and format nits Created 8 years, 5 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"
11 #include "ui/gfx/image/image.h" 11 #include "ui/gfx/image/image.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Keeps in sync (same order) with WallpaperLayout enum in header file.
16 const char* kWallpaperLayoutArrays[] = {
17 "CENTER",
18 "CENTER_CROPPED",
19 "STRETCH",
20 "TILE"
21 };
22
15 const ash::WallpaperInfo kDefaultWallpapers[] = { 23 const ash::WallpaperInfo kDefaultWallpapers[] = {
16 #if !defined(GOOGLE_CHROME_BUILD) 24 #if !defined(GOOGLE_CHROME_BUILD)
17 { 25 {
18 IDR_AURA_WALLPAPERS_ROMAINGUY_0, 26 IDR_AURA_WALLPAPERS_ROMAINGUY_0,
19 IDR_AURA_WALLPAPERS_ROMAINGUY_0_THUMB, 27 IDR_AURA_WALLPAPERS_ROMAINGUY_0_THUMB,
20 ash::CENTER_CROPPED, 28 ash::CENTER_CROPPED,
21 "Romain Guy", 29 "Romain Guy",
22 "http://www.curious-creature.org" 30 "http://www.curious-creature.org"
23 }, 31 },
24 #else 32 #else
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 }, 222 },
215 { 223 {
216 IDR_AURA_WALLPAPERS_5_GRADIENT7, 224 IDR_AURA_WALLPAPERS_5_GRADIENT7,
217 IDR_AURA_WALLPAPERS_5_GRADIENT7_THUMB, 225 IDR_AURA_WALLPAPERS_5_GRADIENT7_THUMB,
218 ash::TILE, 226 ash::TILE,
219 "Chromium", 227 "Chromium",
220 "http://www.chromium.org" 228 "http://www.chromium.org"
221 }, 229 },
222 }; 230 };
223 231
232 const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays);
224 const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers); 233 const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers);
225 const int kInvalidWallpaperIndex = -1; 234 const int kInvalidWallpaperIndex = -1;
226 const int kSolidColorIndex = -2; 235 const int kSolidColorIndex = -2;
227 236
228 // TODO(saintlou): These hardcoded indexes, although checked against the size 237 // TODO(saintlou): These hardcoded indexes, although checked against the size
229 // of the array are really hacky. 238 // of the array are really hacky.
230 #if defined(GOOGLE_CHROME_BUILD) 239 #if defined(GOOGLE_CHROME_BUILD)
231 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 240 const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0
232 const int kLastRandomWallpaperIndex = 19; // The first 20 are random. 241 const int kLastRandomWallpaperIndex = 19; // The first 20 are random.
233 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 242 const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6
(...skipping 17 matching lines...) Expand all
251 260
252 int GetGuestWallpaperIndex() { 261 int GetGuestWallpaperIndex() {
253 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount); 262 DCHECK(kGuestWallpaperIndex < kDefaultWallpaperCount);
254 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); 263 return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1);
255 } 264 }
256 265
257 int GetInvalidWallpaperIndex() { 266 int GetInvalidWallpaperIndex() {
258 return kInvalidWallpaperIndex; 267 return kInvalidWallpaperIndex;
259 } 268 }
260 269
270 WallpaperLayout GetLayoutEnum(const char* layout) {
271 for (int i = 0; i < kWallpaperLayoutCount; i++) {
272 if (strcmp(layout, kWallpaperLayoutArrays[i]) == 0)
273 return static_cast<WallpaperLayout>(i);
274 }
275 // Default to use CENTER layout.
276 return CENTER;
277 }
278
261 int GetNextWallpaperIndex(int index) { 279 int GetNextWallpaperIndex(int index) {
262 DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount); 280 DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount);
263 return (index + 1) % (kLastRandomWallpaperIndex + 1); 281 return (index + 1) % (kLastRandomWallpaperIndex + 1);
264 } 282 }
265 283
266 int GetSolidColorIndex() { 284 int GetSolidColorIndex() {
267 return kSolidColorIndex; 285 return kSolidColorIndex;
268 } 286 }
269 287
270 int GetWallpaperCount() { 288 int GetWallpaperCount() {
271 return kDefaultWallpaperCount; 289 return kDefaultWallpaperCount;
272 } 290 }
273 291
274 const WallpaperInfo& GetWallpaperInfo(int index) { 292 const WallpaperInfo& GetWallpaperInfo(int index) {
275 DCHECK(index >= 0 && index < kDefaultWallpaperCount); 293 DCHECK(index >= 0 && index < kDefaultWallpaperCount);
276 return kDefaultWallpapers[index]; 294 return kDefaultWallpapers[index];
277 } 295 }
278 296
279 } // namespace ash 297 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698