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

Unified Diff: chrome/browser/chromeos/extensions/wallpaper_private_api.cc

Issue 11415015: Remove use of index in wallpaper picker code and some refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser tests Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/wallpaper_private_api.cc
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
index 4d5f8f970ba217a1632622d81ad99701700243a7..02830324800101016c5bac4385bf9e39fbdeb336 100644
--- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
+++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
@@ -6,7 +6,6 @@
#include <vector>
-#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/shell.h"
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_util.h"
@@ -39,6 +38,25 @@ using content::BrowserThread;
namespace {
+// Keeps in sync (same order) with WallpaperLayout enum in header file.
+const char* kWallpaperLayoutArrays[] = {
+ "CENTER",
+ "CENTER_CROPPED",
+ "STRETCH",
+ "TILE"
+};
+
+const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays);
+
+ash::WallpaperLayout GetLayoutEnum(const std::string& layout) {
+ for (int i = 0; i < kWallpaperLayoutCount; i++) {
+ if (layout.compare(kWallpaperLayoutArrays[i]) == 0)
+ return static_cast<ash::WallpaperLayout>(i);
+ }
+ // Default to use CENTER layout.
+ return ash::WALLPAPER_LAYOUT_CENTER;
+}
+
class WindowStateManager;
// static
@@ -242,7 +260,7 @@ bool WallpaperSetWallpaperFunction::RunImpl() {
if (!args_->GetString(1, &layout_string) || layout_string.empty()) {
return false;
}
- layout_ = ash::GetLayoutEnum(layout_string);
+ layout_ = GetLayoutEnum(layout_string);
if (!args_->GetString(2, &url_) || url_.empty())
return false;
@@ -302,7 +320,7 @@ void WallpaperSetWallpaperFunction::SaveToFile() {
chromeos::WallpaperManager::Get()->ResizeAndSaveWallpaper(
wallpaper,
file_path.InsertBeforeExtension(chromeos::kSmallWallpaperSuffix),
- ash::CENTER_CROPPED,
+ ash::WALLPAPER_LAYOUT_CENTER_CROPPED,
ash::kSmallWallpaperMaxWidth,
ash::kSmallWallpaperMaxHeight);
} else {
@@ -346,7 +364,7 @@ bool WallpaperSetCustomWallpaperFunction::RunImpl() {
if (!args_->GetString(1, &layout_string) || layout_string.empty()) {
return false;
}
- layout_ = ash::GetLayoutEnum(layout_string);
+ layout_ = GetLayoutEnum(layout_string);
// Gets email address while at UI thread.
email_ = chromeos::UserManager::Get()->GetLoggedInUser()->email();
« no previous file with comments | « chrome/browser/chromeos/extensions/wallpaper_private_api.h ('k') | chrome/browser/chromeos/login/user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698