| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/chrome_select_file_policy.h" | |
| 21 #include "chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.
h" | 20 #include "chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.
h" |
| 22 #include "chrome/browser/ui/webui/web_ui_util.h" | 21 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 23 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 24 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
| 25 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 29 | 28 |
| 30 namespace chromeos { | 29 namespace chromeos { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setCustomImage"); | 169 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setCustomImage"); |
| 171 } else { | 170 } else { |
| 172 SendLayoutOptions(ash::CENTER_CROPPED); | 171 SendLayoutOptions(ash::CENTER_CROPPED); |
| 173 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", | 172 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", |
| 174 image_url, is_random); | 173 image_url, is_random); |
| 175 } | 174 } |
| 176 } | 175 } |
| 177 | 176 |
| 178 void SetWallpaperOptionsHandler::HandleChooseFile(const ListValue* args) { | 177 void SetWallpaperOptionsHandler::HandleChooseFile(const ListValue* args) { |
| 179 DCHECK(args && args->empty()); | 178 DCHECK(args && args->empty()); |
| 180 select_file_dialog_ = SelectFileDialog::Create( | 179 if (!select_file_dialog_.get()) |
| 181 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); | 180 select_file_dialog_ = SelectFileDialog::Create(this); |
| 182 | 181 |
| 183 FilePath downloads_path; | 182 FilePath downloads_path; |
| 184 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) | 183 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) |
| 185 NOTREACHED(); | 184 NOTREACHED(); |
| 186 | 185 |
| 187 // Static so we initialize it only once. | 186 // Static so we initialize it only once. |
| 188 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info, | 187 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info, |
| 189 (GetUserImageFileTypeInfo())); | 188 (GetUserImageFileTypeInfo())); |
| 190 | 189 |
| 191 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, | 190 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, |
| 192 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), | 191 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), |
| 193 downloads_path, &file_type_info, 0, | 192 downloads_path, &file_type_info, 0, |
| 194 FILE_PATH_LITERAL(""), | 193 FILE_PATH_LITERAL(""), |
| 194 web_ui()->GetWebContents(), |
| 195 GetBrowserWindow(), NULL); | 195 GetBrowserWindow(), NULL); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void SetWallpaperOptionsHandler::HandleLayoutChanged(const ListValue* args) { | 198 void SetWallpaperOptionsHandler::HandleLayoutChanged(const ListValue* args) { |
| 199 int selected_layout = ash::CENTER_CROPPED; | 199 int selected_layout = ash::CENTER_CROPPED; |
| 200 if (!ExtractIntegerValue(args, &selected_layout)) | 200 if (!ExtractIntegerValue(args, &selected_layout)) |
| 201 NOTREACHED() << "Could not read wallpaper layout from JSON argument"; | 201 NOTREACHED() << "Could not read wallpaper layout from JSON argument"; |
| 202 | 202 |
| 203 ash::WallpaperLayout layout = | 203 ash::WallpaperLayout layout = |
| 204 static_cast<ash::WallpaperLayout>(selected_layout); | 204 static_cast<ash::WallpaperLayout>(selected_layout); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { | 238 gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { |
| 239 Browser* browser = | 239 Browser* browser = |
| 240 browser::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); | 240 browser::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); |
| 241 if (!browser) | 241 if (!browser) |
| 242 return NULL; | 242 return NULL; |
| 243 return browser->window()->GetNativeWindow(); | 243 return browser->window()->GetNativeWindow(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace options2 | 246 } // namespace options2 |
| 247 } // namespace chromeos | 247 } // namespace chromeos |
| OLD | NEW |