From 3dca75f77445eb146a501b4fd3d10f5129910c59 Mon Sep 17 00:00:00 2001 From: "bshe@chromium.org" Date: Wed, 25 Jul 2012 20:23:59 +0000 Subject: Wallpaper manager backend APIs BUG=118684 TEST=none Review URL: https://chromiumcodereview.appspot.com/10754014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148400 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/desktop_background/desktop_background_resources.cc | 18 ++++++++++++++++++ ash/desktop_background/desktop_background_resources.h | 3 +++ 2 files changed, 21 insertions(+) (limited to 'ash/desktop_background') diff --git a/ash/desktop_background/desktop_background_resources.cc b/ash/desktop_background/desktop_background_resources.cc index 64392e5..01f7f46 100644 --- a/ash/desktop_background/desktop_background_resources.cc +++ b/ash/desktop_background/desktop_background_resources.cc @@ -12,6 +12,14 @@ namespace { +// Keeps in sync (same order) with WallpaperLayout enum in header file. +const char* kWallpaperLayoutArrays[] = { + "CENTER", + "CENTER_CROPPED", + "STRETCH", + "TILE" +}; + const ash::WallpaperInfo kDefaultWallpapers[] = { #if !defined(GOOGLE_CHROME_BUILD) { @@ -221,6 +229,7 @@ const ash::WallpaperInfo kDefaultWallpapers[] = { }, }; +const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays); const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers); const int kInvalidWallpaperIndex = -1; const int kSolidColorIndex = -2; @@ -258,6 +267,15 @@ int GetInvalidWallpaperIndex() { return kInvalidWallpaperIndex; } +WallpaperLayout GetLayoutEnum(const std::string& layout) { + for (int i = 0; i < kWallpaperLayoutCount; i++) { + if (layout.compare(kWallpaperLayoutArrays[i]) == 0) + return static_cast(i); + } + // Default to use CENTER layout. + return CENTER; +} + int GetNextWallpaperIndex(int index) { DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount); return (index + 1) % (kLastRandomWallpaperIndex + 1); diff --git a/ash/desktop_background/desktop_background_resources.h b/ash/desktop_background/desktop_background_resources.h index 7c14ce6..54cdf55 100644 --- a/ash/desktop_background/desktop_background_resources.h +++ b/ash/desktop_background/desktop_background_resources.h @@ -5,6 +5,8 @@ #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ +#include + #include "ash/ash_export.h" #include "third_party/skia/include/core/SkColor.h" @@ -32,6 +34,7 @@ const SkColor kLoginWallpaperColor = 0xFEFEFE; ASH_EXPORT int GetDefaultWallpaperIndex(); ASH_EXPORT int GetGuestWallpaperIndex(); ASH_EXPORT int GetInvalidWallpaperIndex(); +ASH_EXPORT WallpaperLayout GetLayoutEnum(const std::string& layout); ASH_EXPORT int GetNextWallpaperIndex(int index); ASH_EXPORT int GetSolidColorIndex(); ASH_EXPORT int GetWallpaperCount(); -- cgit v1.1