| 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 ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // Center the wallpaper on the desktop without scaling it. The wallpaper | 29 // Center the wallpaper on the desktop without scaling it. The wallpaper |
| 30 // may be cropped. | 30 // may be cropped. |
| 31 WALLPAPER_LAYOUT_CENTER, | 31 WALLPAPER_LAYOUT_CENTER, |
| 32 // Scale the wallpaper (while preserving its aspect ratio) to cover the | 32 // Scale the wallpaper (while preserving its aspect ratio) to cover the |
| 33 // desktop; the wallpaper may be cropped. | 33 // desktop; the wallpaper may be cropped. |
| 34 WALLPAPER_LAYOUT_CENTER_CROPPED, | 34 WALLPAPER_LAYOUT_CENTER_CROPPED, |
| 35 // Scale the wallpaper (without preserving its aspect ratio) to match the | 35 // Scale the wallpaper (without preserving its aspect ratio) to match the |
| 36 // desktop's size. | 36 // desktop's size. |
| 37 WALLPAPER_LAYOUT_STRETCH, | 37 WALLPAPER_LAYOUT_STRETCH, |
| 38 // Tile the wallpaper over the background without scaling it. | 38 // Tile the wallpaper over the background without scaling it. |
| 39 WALLPAPER_LAYOUT_TILE, | 39 WALLPAPER_LAYOUT_TILE |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 const SkColor kLoginWallpaperColor = 0xFEFEFE; | 42 const SkColor kLoginWallpaperColor = 0xFEFEFE; |
| 43 | 43 |
| 44 class DesktopBackgroundControllerObserver; | 44 class DesktopBackgroundControllerObserver; |
| 45 class WallpaperResizer; | 45 class WallpaperResizer; |
| 46 | 46 |
| 47 // Updates background layer if necessary. | 47 // Updates background layer if necessary. |
| 48 class ASH_EXPORT DesktopBackgroundController | 48 class ASH_EXPORT DesktopBackgroundController |
| 49 : public DisplayController::Observer { | 49 : public DisplayController::Observer { |
| 50 public: | 50 public: |
| 51 class TestAPI; | 51 class TestAPI; |
| 52 | 52 |
| 53 enum BackgroundMode { | 53 enum BackgroundMode { |
| 54 BACKGROUND_NONE, | 54 BACKGROUND_NONE, |
| 55 BACKGROUND_IMAGE, | 55 BACKGROUND_IMAGE, |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // This is used to initialize Resource ID variables and to denote "no |
| 59 // resource ID" in parameters. |
| 60 static const int ASH_EXPORT kInvalidResourceID; |
| 61 |
| 58 DesktopBackgroundController(); | 62 DesktopBackgroundController(); |
| 59 virtual ~DesktopBackgroundController(); | 63 virtual ~DesktopBackgroundController(); |
| 60 | 64 |
| 61 BackgroundMode desktop_background_mode() const { | 65 BackgroundMode desktop_background_mode() const { |
| 62 return desktop_background_mode_; | 66 return desktop_background_mode_; |
| 63 } | 67 } |
| 64 | 68 |
| 65 // Add/Remove observers. | 69 // Add/Remove observers. |
| 66 void AddObserver(DesktopBackgroundControllerObserver* observer); | 70 void AddObserver(DesktopBackgroundControllerObserver* observer); |
| 67 void RemoveObserver(DesktopBackgroundControllerObserver* observer); | 71 void RemoveObserver(DesktopBackgroundControllerObserver* observer); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 105 |
| 102 // Overrides DisplayController::Observer: | 106 // Overrides DisplayController::Observer: |
| 103 virtual void OnDisplayConfigurationChanged() OVERRIDE; | 107 virtual void OnDisplayConfigurationChanged() OVERRIDE; |
| 104 | 108 |
| 105 // Returns the maximum size of all displays combined in native | 109 // Returns the maximum size of all displays combined in native |
| 106 // resolutions. Note that this isn't the bounds of the display who | 110 // resolutions. Note that this isn't the bounds of the display who |
| 107 // has maximum resolutions. Instead, this returns the size of the | 111 // has maximum resolutions. Instead, this returns the size of the |
| 108 // maximum width of all displays, and the maximum height of all displays. | 112 // maximum width of all displays, and the maximum height of all displays. |
| 109 static gfx::Size GetMaxDisplaySizeInNative(); | 113 static gfx::Size GetMaxDisplaySizeInNative(); |
| 110 | 114 |
| 115 // Returns true if the specified wallpaper is already stored |
| 116 // in |current_wallpaper_|. |
| 117 // If |image| is NULL, resource_id is compared. |
| 118 // If |compare_layouts| is false, layout is ignored. |
| 119 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia* image, |
| 120 int resource_id, |
| 121 bool compare_layouts, |
| 122 WallpaperLayout layout) const; |
| 123 |
| 111 private: | 124 private: |
| 112 friend class DesktopBackgroundControllerTest; | 125 friend class DesktopBackgroundControllerTest; |
| 113 // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper; | 126 // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper; |
| 114 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); | 127 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); |
| 115 | 128 |
| 116 // Returns true if the specified wallpaper is already stored | |
| 117 // in |current_wallpaper_|. | |
| 118 // If |image| is NULL, resource_id is compared. | |
| 119 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia* image, | |
| 120 int resource_id, | |
| 121 WallpaperLayout layout) const; | |
| 122 | |
| 123 // Creates view for all root windows, or notifies them to repaint if they | 129 // Creates view for all root windows, or notifies them to repaint if they |
| 124 // already exist. | 130 // already exist. |
| 125 void SetDesktopBackgroundImageMode(); | 131 void SetDesktopBackgroundImageMode(); |
| 126 | 132 |
| 127 // Creates and adds component for current mode (either Widget or Layer) to | 133 // Creates and adds component for current mode (either Widget or Layer) to |
| 128 // |root_window|. | 134 // |root_window|. |
| 129 void InstallDesktopController(aura::Window* root_window); | 135 void InstallDesktopController(aura::Window* root_window); |
| 130 | 136 |
| 131 // Creates and adds component for current mode (either Widget or Layer) to | 137 // Creates and adds component for current mode (either Widget or Layer) to |
| 132 // all root windows. | 138 // all root windows. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 base::OneShotTimer<DesktopBackgroundController> timer_; | 172 base::OneShotTimer<DesktopBackgroundController> timer_; |
| 167 | 173 |
| 168 int wallpaper_reload_delay_; | 174 int wallpaper_reload_delay_; |
| 169 | 175 |
| 170 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 176 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
| 171 }; | 177 }; |
| 172 | 178 |
| 173 } // namespace ash | 179 } // namespace ash |
| 174 | 180 |
| 175 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 181 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
| OLD | NEW |