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 "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/timer/timer.h" |
15 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
16 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
17 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
18 | 20 |
19 typedef unsigned int SkColor; | 21 typedef unsigned int SkColor; |
20 | 22 |
21 class CommandLine; | 23 class CommandLine; |
22 | 24 |
23 namespace aura { | 25 namespace aura { |
24 class RootWindow; | 26 class RootWindow; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 60 |
59 // The width and heigh of wallpaper thumbnails. | 61 // The width and heigh of wallpaper thumbnails. |
60 ASH_EXPORT extern const int kWallpaperThumbnailWidth; | 62 ASH_EXPORT extern const int kWallpaperThumbnailWidth; |
61 ASH_EXPORT extern const int kWallpaperThumbnailHeight; | 63 ASH_EXPORT extern const int kWallpaperThumbnailHeight; |
62 | 64 |
63 class DesktopBackgroundControllerObserver; | 65 class DesktopBackgroundControllerObserver; |
64 class WallpaperResizer; | 66 class WallpaperResizer; |
65 | 67 |
66 // Loads selected desktop wallpaper from file system asynchronously and updates | 68 // Loads selected desktop wallpaper from file system asynchronously and updates |
67 // background layer if loaded successfully. | 69 // background layer if loaded successfully. |
68 class ASH_EXPORT DesktopBackgroundController { | 70 class ASH_EXPORT DesktopBackgroundController |
| 71 : public DisplayController::Observer { |
69 public: | 72 public: |
70 enum BackgroundMode { | 73 enum BackgroundMode { |
71 BACKGROUND_NONE, | 74 BACKGROUND_NONE, |
72 BACKGROUND_IMAGE, | 75 BACKGROUND_IMAGE, |
73 }; | 76 }; |
74 | 77 |
75 DesktopBackgroundController(); | 78 DesktopBackgroundController(); |
76 virtual ~DesktopBackgroundController(); | 79 virtual ~DesktopBackgroundController(); |
77 | 80 |
78 BackgroundMode desktop_background_mode() const { | 81 BackgroundMode desktop_background_mode() const { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 WallpaperResolution GetAppropriateResolution(); | 124 WallpaperResolution GetAppropriateResolution(); |
122 | 125 |
123 // Move all desktop widgets to locked container. | 126 // Move all desktop widgets to locked container. |
124 // Returns true if the desktop moved. | 127 // Returns true if the desktop moved. |
125 bool MoveDesktopToLockedContainer(); | 128 bool MoveDesktopToLockedContainer(); |
126 | 129 |
127 // Move all desktop widgets to unlocked container. | 130 // Move all desktop widgets to unlocked container. |
128 // Returns true if the desktop moved. | 131 // Returns true if the desktop moved. |
129 bool MoveDesktopToUnlockedContainer(); | 132 bool MoveDesktopToUnlockedContainer(); |
130 | 133 |
| 134 // Overrides DisplayController::Observer: |
| 135 virtual void OnDisplayConfigurationChanged() OVERRIDE; |
| 136 |
131 private: | 137 private: |
132 friend class DesktopBackgroundControllerTest; | 138 friend class DesktopBackgroundControllerTest; |
133 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); | 139 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); |
134 | 140 |
135 // An operation to asynchronously loads wallpaper. | 141 // An operation to asynchronously loads wallpaper. |
136 class WallpaperLoader; | 142 class WallpaperLoader; |
137 | 143 |
138 // Returns true if the specified default wallpaper is already being | 144 // Returns true if the specified default wallpaper is already being |
139 // loaded by |wallpaper_loader_| or stored in |current_wallpaper_|. | 145 // loaded by |wallpaper_loader_| or stored in |current_wallpaper_|. |
140 bool DefaultWallpaperIsAlreadyLoadingOrLoaded( | 146 bool DefaultWallpaperIsAlreadyLoadingOrLoaded( |
(...skipping 22 matching lines...) Expand all Loading... |
163 // Moves all desktop components from one container to other across all root | 169 // Moves all desktop components from one container to other across all root |
164 // windows. Returns true if a desktop moved. | 170 // windows. Returns true if a desktop moved. |
165 bool ReparentBackgroundWidgets(int src_container, int dst_container); | 171 bool ReparentBackgroundWidgets(int src_container, int dst_container); |
166 | 172 |
167 // Returns id for background container for unlocked and locked states. | 173 // Returns id for background container for unlocked and locked states. |
168 int GetBackgroundContainerId(bool locked); | 174 int GetBackgroundContainerId(bool locked); |
169 | 175 |
170 // Send notification that background animation finished. | 176 // Send notification that background animation finished. |
171 void NotifyAnimationFinished(); | 177 void NotifyAnimationFinished(); |
172 | 178 |
| 179 // Reload the wallpaper. |
| 180 void UpdateWallpaper(); |
| 181 |
| 182 void set_wallpaper_reload_delay_for_test(bool value) { |
| 183 wallpaper_reload_delay_ = value; |
| 184 } |
| 185 |
173 // Returns the maximum size of all displays combined in native | 186 // Returns the maximum size of all displays combined in native |
174 // resolutions. Note that this isn't the bounds of the display who | 187 // resolutions. Note that this isn't the bounds of the display who |
175 // has maximum resolutions. Instead, this returns the size of the | 188 // has maximum resolutions. Instead, this returns the size of the |
176 // maximum width of all displays, and the maximum height of all displays. | 189 // maximum width of all displays, and the maximum height of all displays. |
177 static gfx::Size GetMaxDisplaySizeInNative(); | 190 static gfx::Size GetMaxDisplaySizeInNative(); |
178 | 191 |
179 // If non-NULL, used in place of the real command line. | 192 // If non-NULL, used in place of the real command line. |
180 CommandLine* command_line_for_testing_; | 193 CommandLine* command_line_for_testing_; |
181 | 194 |
182 // Can change at runtime. | 195 // Can change at runtime. |
183 bool locked_; | 196 bool locked_; |
184 | 197 |
185 BackgroundMode desktop_background_mode_; | 198 BackgroundMode desktop_background_mode_; |
186 | 199 |
187 SkColor background_color_; | 200 SkColor background_color_; |
188 | 201 |
189 ObserverList<DesktopBackgroundControllerObserver> observers_; | 202 ObserverList<DesktopBackgroundControllerObserver> observers_; |
190 | 203 |
191 // The current wallpaper. | 204 // The current wallpaper. |
192 scoped_ptr<WallpaperResizer> current_wallpaper_; | 205 scoped_ptr<WallpaperResizer> current_wallpaper_; |
193 | 206 |
194 // If a default wallpaper is stored in |current_wallpaper_|, the path and | 207 // If a default wallpaper is stored in |current_wallpaper_|, the path and |
195 // resource ID that were passed to WallpaperLoader when loading it. | 208 // resource ID that were passed to WallpaperLoader when loading it. |
196 // Otherwise, empty and -1, respectively. | 209 // Otherwise, empty and -1, respectively. |
197 base::FilePath current_default_wallpaper_path_; | 210 base::FilePath current_default_wallpaper_path_; |
198 int current_default_wallpaper_resource_id_; | 211 int current_default_wallpaper_resource_id_; |
199 | 212 |
| 213 gfx::Size current_max_display_size_; |
| 214 |
200 scoped_refptr<WallpaperLoader> wallpaper_loader_; | 215 scoped_refptr<WallpaperLoader> wallpaper_loader_; |
201 | 216 |
202 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; | 217 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; |
203 | 218 |
| 219 base::OneShotTimer<DesktopBackgroundController> timer_; |
| 220 |
| 221 int wallpaper_reload_delay_; |
| 222 |
204 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 223 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
205 }; | 224 }; |
206 | 225 |
207 } // namespace ash | 226 } // namespace ash |
208 | 227 |
209 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 228 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
OLD | NEW |