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
r.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handle
r.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 14 matching lines...) Expand all Loading... |
25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
28 | 28 |
29 namespace chromeos { | 29 namespace chromeos { |
30 namespace options2 { | 30 namespace options2 { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Returns info about extensions for files we support as wallpaper images. | 34 // Returns info about extensions for files we support as wallpaper images. |
35 SelectFileDialog::FileTypeInfo GetUserImageFileTypeInfo() { | 35 ui::SelectFileDialog::FileTypeInfo GetUserImageFileTypeInfo() { |
36 SelectFileDialog::FileTypeInfo file_type_info; | 36 ui::SelectFileDialog::FileTypeInfo file_type_info; |
37 file_type_info.extensions.resize(3); | 37 file_type_info.extensions.resize(3); |
38 | 38 |
39 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("jpg")); | 39 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("jpg")); |
40 file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("jpeg")); | 40 file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("jpeg")); |
41 | 41 |
42 file_type_info.extensions[2].push_back(FILE_PATH_LITERAL("png")); | 42 file_type_info.extensions[2].push_back(FILE_PATH_LITERAL("png")); |
43 | 43 |
44 return file_type_info; | 44 return file_type_info; |
45 } | 45 } |
46 | 46 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setCustomImage"); | 177 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setCustomImage"); |
178 } else { | 178 } else { |
179 SendLayoutOptions(ash::CENTER_CROPPED); | 179 SendLayoutOptions(ash::CENTER_CROPPED); |
180 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", | 180 web_ui()->CallJavascriptFunction("SetWallpaperOptions.setSelectedImage", |
181 image_url, is_daily); | 181 image_url, is_daily); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 void SetWallpaperOptionsHandler::HandleChooseFile(const ListValue* args) { | 185 void SetWallpaperOptionsHandler::HandleChooseFile(const ListValue* args) { |
186 DCHECK(args && args->empty()); | 186 DCHECK(args && args->empty()); |
187 select_file_dialog_ = SelectFileDialog::Create( | 187 select_file_dialog_ = ui::SelectFileDialog::Create( |
188 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); | 188 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); |
189 | 189 |
190 FilePath downloads_path; | 190 FilePath downloads_path; |
191 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) | 191 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) |
192 NOTREACHED(); | 192 NOTREACHED(); |
193 | 193 |
194 // Static so we initialize it only once. | 194 // Static so we initialize it only once. |
195 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info, | 195 CR_DEFINE_STATIC_LOCAL(ui::SelectFileDialog::FileTypeInfo, file_type_info, |
196 (GetUserImageFileTypeInfo())); | 196 (GetUserImageFileTypeInfo())); |
197 | 197 |
198 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, | 198 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_OPEN_FILE, |
199 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), | 199 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), |
200 downloads_path, &file_type_info, 0, | 200 downloads_path, &file_type_info, 0, |
201 FILE_PATH_LITERAL(""), | 201 FILE_PATH_LITERAL(""), |
202 GetBrowserWindow(), NULL); | 202 GetBrowserWindow(), NULL); |
203 } | 203 } |
204 | 204 |
205 void SetWallpaperOptionsHandler::HandleLayoutChanged(const ListValue* args) { | 205 void SetWallpaperOptionsHandler::HandleLayoutChanged(const ListValue* args) { |
206 int selected_layout = ash::CENTER_CROPPED; | 206 int selected_layout = ash::CENTER_CROPPED; |
207 if (!ExtractIntegerValue(args, &selected_layout)) | 207 if (!ExtractIntegerValue(args, &selected_layout)) |
208 NOTREACHED() << "Could not read wallpaper layout from JSON argument"; | 208 NOTREACHED() << "Could not read wallpaper layout from JSON argument"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { | 250 gfx::NativeWindow SetWallpaperOptionsHandler::GetBrowserWindow() const { |
251 Browser* browser = | 251 Browser* browser = |
252 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 252 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
253 return browser->window()->GetNativeWindow(); | 253 return browser->window()->GetNativeWindow(); |
254 } | 254 } |
255 | 255 |
256 } // namespace options2 | 256 } // namespace options2 |
257 } // namespace chromeos | 257 } // namespace chromeos |
OLD | NEW |