diff options
author | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 17:38:01 +0000 |
---|---|---|
committer | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 17:38:01 +0000 |
commit | 2b54191b3f0aac1ee95159f4930baf73d000cc0f (patch) | |
tree | 11c4814cc31a7c24ff54ae59fdf060840cf55ce7 /ash/desktop_background | |
parent | 7aca0d97aa3577f614cf0368c4bfb1f36704d484 (diff) | |
download | chromium_src-2b54191b3f0aac1ee95159f4930baf73d000cc0f.zip chromium_src-2b54191b3f0aac1ee95159f4930baf73d000cc0f.tar.gz chromium_src-2b54191b3f0aac1ee95159f4930baf73d000cc0f.tar.bz2 |
Implement random wallpaper feature
BUG=120217
TEST=Go to set wallpaper overlay in settings page, check the "I'm feeling
lucky" checkbox. Sign out and sign in a couple of times, verify if the
wallpaper is random.
Review URL: https://chromiumcodereview.appspot.com/10302016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
-rw-r--r-- | ash/desktop_background/desktop_background_resources.cc | 8 | ||||
-rw-r--r-- | ash/desktop_background/desktop_background_resources.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/ash/desktop_background/desktop_background_resources.cc b/ash/desktop_background/desktop_background_resources.cc index 5b7d07f..e5cf675 100644 --- a/ash/desktop_background/desktop_background_resources.cc +++ b/ash/desktop_background/desktop_background_resources.cc @@ -229,12 +229,14 @@ const int kInvalidWallpaperIndex = -1; // of the array are really hacky. #if defined(GOOGLE_CHROME_BUILD) const int kDefaultWallpaperIndex = 16; // IDR_AURA_WALLPAPERS_3_URBAN0 +const int kLastRandomWallpaperIndex = 19; // The first 20 are random. const int kGuestWallpaperIndex = 26; // IDR_AURA_WALLPAPERS_5_GRADIENT6 #else // Set default wallpaper to the grey background for faster wallpaper loading // time in browser tests. Otherwise, some of the tests will finish before // wallpaper loaded and cause crashes. const int kDefaultWallpaperIndex = 6; // IDR_AURA_WALLPAPERS_5_GRADIENT5 +const int kLastRandomWallpaperIndex = 8; const int kGuestWallpaperIndex = kDefaultWallpaperIndex; #endif @@ -256,6 +258,12 @@ int GetGuestWallpaperIndex() { return std::min(kGuestWallpaperIndex, kDefaultWallpaperCount - 1); } +int GetRandomWallpaperIndex() { + DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount); + return base::RandInt(0, + std::min(kLastRandomWallpaperIndex, kDefaultWallpaperCount - 1)); +} + int GetWallpaperCount() { return kDefaultWallpaperCount; } diff --git a/ash/desktop_background/desktop_background_resources.h b/ash/desktop_background/desktop_background_resources.h index 5a0391d..19f23d0 100644 --- a/ash/desktop_background/desktop_background_resources.h +++ b/ash/desktop_background/desktop_background_resources.h @@ -31,6 +31,7 @@ struct ASH_EXPORT WallpaperInfo { ASH_EXPORT int GetInvalidWallpaperIndex(); ASH_EXPORT int GetDefaultWallpaperIndex(); ASH_EXPORT int GetGuestWallpaperIndex(); +ASH_EXPORT int GetRandomWallpaperIndex(); ASH_EXPORT int GetWallpaperCount(); ASH_EXPORT const WallpaperInfo& GetWallpaperInfo(int index); |