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

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: Merge to trunk 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 8fda99b12e06b196f621c3ad2201ee74d9609c5a..40056a452c1b8b518e31cfbc06afa5c561648566 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
@@ -18,7 +18,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/webui/web_ui_util.h"
+#include "chrome/browser/ui/views/window.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"
@@ -68,8 +69,7 @@ void SetWallpaperOptionsHandler::SendDefaultImages() {
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);
}
@@ -88,24 +88,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