Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2 _H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2 _H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2 _H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDLER2 _H_ |
| 7 | 7 |
| 8 #include "ash/desktop_background/desktop_background_resources.h" | |
| 8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/ui/select_file_dialog.h" | |
| 9 #include "chrome/browser/ui/webui/options2/options_ui2.h" | 11 #include "chrome/browser/ui/webui/options2/options_ui2.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 11 | 13 |
| 12 namespace base { | 14 namespace base { |
| 13 class DictionaryValue; | 15 class DictionaryValue; |
| 14 class ListValue; | 16 class ListValue; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace chromeos { | 19 namespace chromeos { |
| 20 | |
| 21 class WallpaperDelegate { | |
| 22 public: | |
| 23 // Call javascript function to add/update custom wallpaper thumbnail in | |
| 24 // picker UI. | |
| 25 virtual void SetCustomWallpaperThumbnail() = 0; | |
|
James Hawkins
2012/05/11 18:13:23
nit: Add protected destructor.
| |
| 26 }; | |
| 27 | |
| 18 namespace options2 { | 28 namespace options2 { |
| 19 | 29 |
| 20 // ChromeOS user image options page UI handler. | 30 // ChromeOS user image options page UI handler. |
| 21 class SetWallpaperOptionsHandler : public ::options2::OptionsPageUIHandler{ | 31 class SetWallpaperOptionsHandler : public ::options2::OptionsPageUIHandler, |
| 32 public SelectFileDialog::Listener, | |
| 33 public WallpaperDelegate { | |
| 22 public: | 34 public: |
| 23 SetWallpaperOptionsHandler(); | 35 SetWallpaperOptionsHandler(); |
| 24 virtual ~SetWallpaperOptionsHandler(); | 36 virtual ~SetWallpaperOptionsHandler(); |
| 25 | 37 |
| 26 // OptionsPageUIHandler implementation. | 38 // OptionsPageUIHandler implementation. |
| 27 virtual void GetLocalizedValues( | 39 virtual void GetLocalizedValues( |
| 28 base::DictionaryValue* localized_strings) OVERRIDE; | 40 base::DictionaryValue* localized_strings) OVERRIDE; |
| 29 | 41 |
| 30 // WebUIMessageHandler implementation. | 42 // WebUIMessageHandler implementation. |
| 31 virtual void RegisterMessages() OVERRIDE; | 43 virtual void RegisterMessages() OVERRIDE; |
| 32 | 44 |
| 45 // WallpaperDelegate implementation. | |
| 46 virtual void SetCustomWallpaperThumbnail() OVERRIDE; | |
| 47 | |
| 33 private: | 48 private: |
| 49 // SelectFileDialog::Delegate implementation. | |
| 50 virtual void FileSelected(const FilePath& path, int index, | |
| 51 void* params) OVERRIDE; | |
| 52 | |
| 34 // Sends list of available default images to the page. | 53 // Sends list of available default images to the page. |
| 35 void SendDefaultImages(); | 54 void SendDefaultImages(); |
| 36 | 55 |
| 56 // Sends layout options for custom wallpaper. Only exposes CENTER, | |
| 57 // CENTER_CROPPED, STRETCH to users. Set the selected option to specified | |
| 58 // |layout|. | |
| 59 void SendLayoutOptions(ash::WallpaperLayout layout); | |
| 60 | |
| 37 // Handles page initialized event. | 61 // Handles page initialized event. |
| 38 void HandlePageInitialized(const base::ListValue* args); | 62 void HandlePageInitialized(const base::ListValue* args); |
| 39 | 63 |
| 40 // Handles page shown event. | 64 // Handles page shown event. |
| 41 void HandlePageShown(const base::ListValue* args); | 65 void HandlePageShown(const base::ListValue* args); |
| 42 | 66 |
| 67 // Opens a file selection dialog to choose user image from file. | |
| 68 void HandleChooseFile(const base::ListValue* args); | |
| 69 | |
| 70 // Redraws the wallpaper with specified wallpaper layout. | |
| 71 void HandleLayoutChanged(const base::ListValue* args); | |
| 72 | |
| 43 // Selects one of the available default wallpapers. | 73 // Selects one of the available default wallpapers. |
| 44 void HandleDefaultWallpaper(const base::ListValue* args); | 74 void HandleDefaultWallpaper(const base::ListValue* args); |
| 45 | 75 |
| 46 // Sets user wallpaper to a random one from the default wallpapers. | 76 // Sets user wallpaper to a random one from the default wallpapers. |
| 47 void HandleRandomWallpaper(const base::ListValue* args); | 77 void HandleRandomWallpaper(const base::ListValue* args); |
| 48 | 78 |
| 49 // Returns handle to browser window or NULL if it can't be found. | 79 // Returns handle to browser window or NULL if it can't be found. |
| 50 gfx::NativeWindow GetBrowserWindow() const; | 80 gfx::NativeWindow GetBrowserWindow() const; |
| 51 | 81 |
| 82 // Shows a dialog box for selecting a file. | |
| 83 scoped_refptr<SelectFileDialog> select_file_dialog_; | |
| 84 | |
| 52 base::WeakPtrFactory<SetWallpaperOptionsHandler> weak_factory_; | 85 base::WeakPtrFactory<SetWallpaperOptionsHandler> weak_factory_; |
| 53 | 86 |
| 54 DISALLOW_COPY_AND_ASSIGN(SetWallpaperOptionsHandler); | 87 DISALLOW_COPY_AND_ASSIGN(SetWallpaperOptionsHandler); |
| 55 }; | 88 }; |
| 56 | 89 |
| 57 } // namespace options2 | 90 } // namespace options2 |
| 58 } // namespace chromeos | 91 } // namespace chromeos |
| 59 | 92 |
| 60 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDL ER2_H_ | 93 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SET_WALLPAPER_OPTIONS_HANDL ER2_H_ |
| OLD | NEW |