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/desktop_background/desktop_background_resources.h" | |
10 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
14 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
15 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
16 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
17 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
18 | 17 |
19 typedef unsigned int SkColor; | 18 typedef unsigned int SkColor; |
20 | 19 |
21 namespace aura { | 20 namespace aura { |
22 class RootWindow; | 21 class RootWindow; |
23 } | 22 } |
24 | 23 |
25 namespace ash { | 24 namespace ash { |
26 | 25 |
| 26 enum WallpaperLayout { |
| 27 WALLPAPER_LAYOUT_CENTER, |
| 28 WALLPAPER_LAYOUT_CENTER_CROPPED, |
| 29 WALLPAPER_LAYOUT_STRETCH, |
| 30 WALLPAPER_LAYOUT_TILE, |
| 31 }; |
| 32 |
| 33 enum WallpaperResolution { |
| 34 WALLPAPER_RESOLUTION_LARGE, |
| 35 WALLPAPER_RESOLUTION_SMALL |
| 36 }; |
| 37 |
| 38 const SkColor kLoginWallpaperColor = 0xFEFEFE; |
| 39 |
| 40 // Encapsulates wallpaper infomation needed by desktop background controller. |
| 41 struct ASH_EXPORT WallpaperInfo { |
| 42 int idr; |
| 43 WallpaperLayout layout; |
| 44 }; |
| 45 |
| 46 ASH_EXPORT extern const WallpaperInfo kDefaultLargeWallpaper; |
| 47 ASH_EXPORT extern const WallpaperInfo kDefaultSmallWallpaper; |
| 48 ASH_EXPORT extern const WallpaperInfo kGuestLargeWallpaper; |
| 49 ASH_EXPORT extern const WallpaperInfo kGuestSmallWallpaper; |
| 50 |
27 // The width and height of small/large resolution wallpaper. When screen size is | 51 // The width and height of small/large resolution wallpaper. When screen size is |
28 // smaller than |kSmallWallpaperMaxWidth| and |kSmallWallpaperMaxHeight|, the | 52 // smaller than |kSmallWallpaperMaxWidth| and |kSmallWallpaperMaxHeight|, the |
29 // small resolution wallpaper should be used. Otherwise, uses the large | 53 // small resolution wallpaper should be used. Otherwise, uses the large |
30 // resolution wallpaper. | 54 // resolution wallpaper. |
31 ASH_EXPORT extern const int kSmallWallpaperMaxWidth; | 55 ASH_EXPORT extern const int kSmallWallpaperMaxWidth; |
32 ASH_EXPORT extern const int kSmallWallpaperMaxHeight; | 56 ASH_EXPORT extern const int kSmallWallpaperMaxHeight; |
33 ASH_EXPORT extern const int kLargeWallpaperMaxWidth; | 57 ASH_EXPORT extern const int kLargeWallpaperMaxWidth; |
34 ASH_EXPORT extern const int kLargeWallpaperMaxHeight; | 58 ASH_EXPORT extern const int kLargeWallpaperMaxHeight; |
35 | 59 |
36 class DesktopBackgroundControllerObserver; | 60 class DesktopBackgroundControllerObserver; |
(...skipping 20 matching lines...) Expand all Loading... |
57 void RemoveObserver(DesktopBackgroundControllerObserver* observer); | 81 void RemoveObserver(DesktopBackgroundControllerObserver* observer); |
58 | 82 |
59 gfx::ImageSkia GetWallpaper() const; | 83 gfx::ImageSkia GetWallpaper() const; |
60 | 84 |
61 WallpaperLayout GetWallpaperLayout() const; | 85 WallpaperLayout GetWallpaperLayout() const; |
62 | 86 |
63 // Provides current image on the background, or empty gfx::ImageSkia if there | 87 // Provides current image on the background, or empty gfx::ImageSkia if there |
64 // is no image, e.g. background is solid color. | 88 // is no image, e.g. background is solid color. |
65 gfx::ImageSkia GetCurrentWallpaperImage(); | 89 gfx::ImageSkia GetCurrentWallpaperImage(); |
66 | 90 |
| 91 // Gets the IDR of current wallpaper. Returns -1 if current wallpaper is not |
| 92 // a builtin wallpaper. |
| 93 int GetWallpaperIDR() const; |
| 94 |
67 // Initialize root window's background. | 95 // Initialize root window's background. |
68 void OnRootWindowAdded(aura::RootWindow* root_window); | 96 void OnRootWindowAdded(aura::RootWindow* root_window); |
69 | 97 |
70 // Loads default wallpaper at |index| asynchronously but does not set the | 98 // Loads builtin wallpaper asynchronously and sets to current wallpaper after |
71 // loaded image to current wallpaper. Resource bundle will cache the loaded | 99 // loaded. |
72 // image. | 100 void SetDefaultWallpaper(const WallpaperInfo& info); |
73 void CacheDefaultWallpaper(int index); | |
74 | |
75 // Loads default wallpaper at |index| asynchronously and sets to current | |
76 // wallpaper after loaded. | |
77 void SetDefaultWallpaper(int index); | |
78 | |
79 // Forces to reload the current default wallpaper. A different resolution | |
80 // wallpaper maybe loaded. | |
81 void ReloadDefaultWallpaper(); | |
82 | 101 |
83 // Sets the user selected custom wallpaper. Called when user selected a file | 102 // Sets the user selected custom wallpaper. Called when user selected a file |
84 // from file system or changed the layout of wallpaper. | 103 // from file system or changed the layout of wallpaper. |
85 void SetCustomWallpaper(const gfx::ImageSkia& wallpaper, | 104 void SetCustomWallpaper(const gfx::ImageSkia& wallpaper, |
86 WallpaperLayout layout); | 105 WallpaperLayout layout); |
87 | 106 |
88 // Cancels the current wallpaper loading operation. | 107 // Cancels the current wallpaper loading operation. |
89 void CancelPendingWallpaperOperation(); | 108 void CancelPendingWallpaperOperation(); |
90 | 109 |
91 // Sets the desktop background to solid color mode and creates a solid | 110 // Sets the desktop background to solid color mode and creates a solid |
(...skipping 17 matching lines...) Expand all Loading... |
109 | 128 |
110 // Move all desktop widgets to unlocked container. | 129 // Move all desktop widgets to unlocked container. |
111 // Returns true if the desktop moved. | 130 // Returns true if the desktop moved. |
112 bool MoveDesktopToUnlockedContainer(); | 131 bool MoveDesktopToUnlockedContainer(); |
113 | 132 |
114 // WindowObserver implementation. | 133 // WindowObserver implementation. |
115 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 134 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
116 | 135 |
117 private: | 136 private: |
118 // An operation to asynchronously loads wallpaper. | 137 // An operation to asynchronously loads wallpaper. |
119 class WallpaperOperation; | 138 class WallpaperLoader; |
120 | 139 |
121 struct WallpaperData; | 140 struct WallpaperData; |
122 | 141 |
123 // Creates view for all root windows, or notifies them to repaint if they | 142 // Creates view for all root windows, or notifies them to repaint if they |
124 // already exist. | 143 // already exist. |
125 void SetDesktopBackgroundImageMode(); | 144 void SetDesktopBackgroundImageMode(); |
126 | 145 |
127 // Creates a new background widget and sets the background mode to image mode. | 146 // Creates a new background widget and sets the background mode to image mode. |
128 // Called after wallpaper loaded successfully. | 147 // Called after wallpaper loaded successfully. |
129 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); | 148 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperLoader> wl); |
130 | 149 |
131 // Adds layer with solid |color| to container |container_id| in |root_window|. | 150 // Adds layer with solid |color| to container |container_id| in |root_window|. |
132 ui::Layer* SetColorLayerForContainer(SkColor color, | 151 ui::Layer* SetColorLayerForContainer(SkColor color, |
133 aura::RootWindow* root_window, | 152 aura::RootWindow* root_window, |
134 int container_id); | 153 int container_id); |
135 | 154 |
136 // Creates and adds component for current mode (either Widget or Layer) to | 155 // Creates and adds component for current mode (either Widget or Layer) to |
137 // |root_window|. | 156 // |root_window|. |
138 void InstallDesktopController(aura::RootWindow* root_window); | 157 void InstallDesktopController(aura::RootWindow* root_window); |
139 | 158 |
(...skipping 16 matching lines...) Expand all Loading... |
156 | 175 |
157 BackgroundMode desktop_background_mode_; | 176 BackgroundMode desktop_background_mode_; |
158 | 177 |
159 SkColor background_color_; | 178 SkColor background_color_; |
160 | 179 |
161 ObserverList<DesktopBackgroundControllerObserver> observers_; | 180 ObserverList<DesktopBackgroundControllerObserver> observers_; |
162 | 181 |
163 // The current wallpaper. | 182 // The current wallpaper. |
164 scoped_ptr<WallpaperData> current_wallpaper_; | 183 scoped_ptr<WallpaperData> current_wallpaper_; |
165 | 184 |
166 scoped_refptr<WallpaperOperation> wallpaper_op_; | 185 scoped_refptr<WallpaperLoader> wallpaper_loader_; |
167 | 186 |
168 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; | 187 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; |
169 | 188 |
170 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 189 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
171 }; | 190 }; |
172 | 191 |
173 } // namespace ash | 192 } // namespace ash |
174 | 193 |
175 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 194 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
OLD | NEW |