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

Unified Diff: chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc

Issue 10021066: Replace the index mapping of wallpaper picker UI and hard coded wallpaper index in C++ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add todo Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
diff --git a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
index 58cb08fd1164485f94cfa770e460673dd9b4b0fc..b7a6513d98672bb5a7b061db36729491a5542212 100644
--- a/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handler2.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/window.h"
-#include "chrome/browser/ui/webui/web_ui_util.h"
+#include "chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui.h"
@@ -65,12 +65,10 @@ void SetWallpaperOptionsHandler::SendDefaultImages() {
ListValue images;
DictionaryValue* image_detail;
ash::WallpaperInfo image_info;
-
for (int i = 0; i < ash::GetWallpaperCount(); ++i) {
images.Append(image_detail = new DictionaryValue());
image_info = ash::GetWallpaperInfo(i);
- image_detail->SetString("url", web_ui_util::GetImageDataUrl(
- ash::GetWallpaperThumbnail(i)));
+ image_detail->SetString("url", GetDefaultWallpaperThumbnailURL(i));
image_detail->SetString("author", image_info.author);
image_detail->SetString("website", image_info.website);
}
@@ -89,24 +87,27 @@ void SetWallpaperOptionsHandler::HandlePageInitialized(
void SetWallpaperOptionsHandler::HandlePageShown(const base::ListValue* args) {
DCHECK(args && args->empty());
int index = chromeos::UserManager::Get()->GetUserWallpaperIndex();
- base::FundamentalValue index_value(index);
+ base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index));
web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage",
- index_value);
+ image_url);
}
void SetWallpaperOptionsHandler::HandleSelectImage(const ListValue* args) {
- std::string image_index_string;
- int image_index;
+ std::string image_url;
if (!args ||
args->GetSize() != 1 ||
- !args->GetString(0, &image_index_string) ||
- !base::StringToInt(image_index_string, &image_index) ||
- image_index < 0 || image_index >= ash::GetWallpaperCount())
+ !args->GetString(0, &image_url))
NOTREACHED();
- UserManager::Get()->SaveUserWallpaperIndex(image_index);
- ash::Shell::GetInstance()->desktop_background_controller()->
- SetDesktopBackgroundImageMode();
+ if (image_url.empty())
+ return;
+
+ int user_image_index;
+ if (IsDefaultWallpaperURL(image_url, &user_image_index)) {
+ UserManager::Get()->SaveUserWallpaperIndex(user_image_index);
+ ash::Shell::GetInstance()->desktop_background_controller()->
+ SetDesktopBackgroundImageMode();
+ }
}
gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const {

Powered by Google App Engine
This is Rietveld 408576698