diff options
author | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 16:32:45 +0000 |
---|---|---|
committer | bshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 16:32:45 +0000 |
commit | 2cda5a03af2b1241494d051ba60aa5b2bb5477c7 (patch) | |
tree | bf69c18b013335dab7a13e9a070c5eaa9cfb5a66 /ash | |
parent | 4eb26dd2ba6bd39be48e07238e714939c7729ced (diff) | |
download | chromium_src-2cda5a03af2b1241494d051ba60aa5b2bb5477c7.zip chromium_src-2cda5a03af2b1241494d051ba60aa5b2bb5477c7.tar.gz chromium_src-2cda5a03af2b1241494d051ba60aa5b2bb5477c7.tar.bz2 |
Reland "Implement random wallpaper feature"
CL 10302016 reverted because of failed testes on linux chromeos bot. The reason
was a DCHECK fail. I have fixed the fails in CL 10382072. So reland the random
wallpaper feature here.
TBR=nikita,ben,jhawkins
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/10384079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-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); |