| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handle
r2.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handle
r2.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 !args->GetString(0, &image_url)) | 212 !args->GetString(0, &image_url)) |
| 213 NOTREACHED(); | 213 NOTREACHED(); |
| 214 | 214 |
| 215 if (image_url.empty()) | 215 if (image_url.empty()) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 int user_image_index; | 218 int user_image_index; |
| 219 if (IsDefaultWallpaperURL(image_url, &user_image_index)) { | 219 if (IsDefaultWallpaperURL(image_url, &user_image_index)) { |
| 220 UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DEFAULT, | 220 UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::DEFAULT, |
| 221 user_image_index); | 221 user_image_index); |
| 222 ash::Shell::GetInstance()->user_wallpaper_delegate()-> | 222 ash::Shell::GetInstance()->user_wallpaper_delegate()->InitializeWallpaper(); |
| 223 SetLoggedInUserWallpaper(); | |
| 224 } | 223 } |
| 225 } | 224 } |
| 226 | 225 |
| 227 void SetWallpaperOptionsHandler::HandleRandomWallpaper(const ListValue* args) { | 226 void SetWallpaperOptionsHandler::HandleRandomWallpaper(const ListValue* args) { |
| 228 int index = ash::GetRandomWallpaperIndex(); | 227 int index = ash::GetRandomWallpaperIndex(); |
| 229 UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::RANDOM, index); | 228 UserManager::Get()->SaveLoggedInUserWallpaperProperties(User::RANDOM, index); |
| 230 ash::Shell::GetInstance()->desktop_background_controller()-> | 229 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 231 SetDefaultWallpaper(index); | 230 SetDefaultWallpaper(index); |
| 232 base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index)); | 231 base::StringValue image_url(GetDefaultWallpaperThumbnailURL(index)); |
| 233 base::FundamentalValue is_random(true); | 232 base::FundamentalValue is_random(true); |
| 234 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", | 233 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", |
| 235 image_url, is_random); | 234 image_url, is_random); |
| 236 } | 235 } |
| 237 | 236 |
| 238 gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { | 237 gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { |
| 239 Browser* browser = | 238 Browser* browser = |
| 240 browser::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); | 239 browser::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); |
| 241 if (!browser) | 240 if (!browser) |
| 242 return NULL; | 241 return NULL; |
| 243 return browser->window()->GetNativeHandle(); | 242 return browser->window()->GetNativeHandle(); |
| 244 } | 243 } |
| 245 | 244 |
| 246 } // namespace options2 | 245 } // namespace options2 |
| 247 } // namespace chromeos | 246 } // namespace chromeos |
| OLD | NEW |