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" | 9 #include "ash/desktop_background/desktop_background_resources.h" |
10 #include "ash/wm/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_observer.h" |
| 18 #include "ui/compositor/layer.h" |
16 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
17 | 20 |
18 namespace aura { | 21 namespace aura { |
19 class RootWindow; | 22 class RootWindow; |
20 } | 23 } |
21 | 24 |
22 namespace ash { | 25 namespace ash { |
23 | 26 |
24 class UserWallpaperDelegate { | 27 class UserWallpaperDelegate { |
25 public: | 28 public: |
(...skipping 14 matching lines...) Expand all Loading... |
40 | 43 |
41 // Notifies delegate that wallpaper animation has finished. | 44 // Notifies delegate that wallpaper animation has finished. |
42 virtual void OnWallpaperAnimationFinished() = 0; | 45 virtual void OnWallpaperAnimationFinished() = 0; |
43 | 46 |
44 // Notifies delegate that wallpaper boot animation has finished. | 47 // Notifies delegate that wallpaper boot animation has finished. |
45 virtual void OnWallpaperBootAnimationFinished() = 0; | 48 virtual void OnWallpaperBootAnimationFinished() = 0; |
46 }; | 49 }; |
47 | 50 |
48 // Loads selected desktop wallpaper from file system asynchronously and updates | 51 // Loads selected desktop wallpaper from file system asynchronously and updates |
49 // background layer if loaded successfully. | 52 // background layer if loaded successfully. |
50 class ASH_EXPORT DesktopBackgroundController { | 53 class ASH_EXPORT DesktopBackgroundController : public aura::WindowObserver { |
51 public: | 54 public: |
52 enum BackgroundMode { | 55 enum BackgroundMode { |
53 BACKGROUND_IMAGE, | 56 BACKGROUND_IMAGE, |
54 BACKGROUND_SOLID_COLOR | 57 BACKGROUND_SOLID_COLOR |
55 }; | 58 }; |
56 | 59 |
57 DesktopBackgroundController(); | 60 DesktopBackgroundController(); |
58 virtual ~DesktopBackgroundController(); | 61 virtual ~DesktopBackgroundController(); |
59 | 62 |
60 // Gets the desktop background mode. | 63 // Gets the desktop background mode. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void SetDesktopBackgroundSolidColorMode(SkColor color); | 95 void SetDesktopBackgroundSolidColorMode(SkColor color); |
93 | 96 |
94 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready | 97 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready |
95 // when running. However, the wallpaper widgets are now created asynchronously | 98 // when running. However, the wallpaper widgets are now created asynchronously |
96 // . If loading a real wallpaper, there are cases that these tests crash | 99 // . If loading a real wallpaper, there are cases that these tests crash |
97 // because the required widget is not ready. This function synchronously | 100 // because the required widget is not ready. This function synchronously |
98 // creates an empty widget for those tests to prevent crashes. An example test | 101 // creates an empty widget for those tests to prevent crashes. An example test |
99 // is SystemGestureEventFilterTest.ThreeFingerSwipe. | 102 // is SystemGestureEventFilterTest.ThreeFingerSwipe. |
100 void CreateEmptyWallpaper(); | 103 void CreateEmptyWallpaper(); |
101 | 104 |
| 105 // Move all desktop widgets to locked container. |
| 106 void MoveDesktopToLockedContainer(); |
| 107 |
| 108 // Move all desktop widgets to unlocked container. |
| 109 void MoveDesktopToUnlockedContainer(); |
| 110 |
| 111 // WindowObserver implementation. |
| 112 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 113 |
102 private: | 114 private: |
103 // An operation to asynchronously loads wallpaper. | 115 // An operation to asynchronously loads wallpaper. |
104 class WallpaperOperation; | 116 class WallpaperOperation; |
105 | 117 |
106 struct WallpaperData; | 118 struct WallpaperData; |
107 | 119 |
108 // Creates a new background widget using the current wallpapaer image and | 120 // Creates view for all root windows, or notifies them to repaint if they |
109 // use it as a background of the |root_window|. Deletes the old widget if any. | 121 // already exist. |
110 void SetDesktopBackgroundImage(aura::RootWindow* root_window); | 122 void SetDesktopBackgroundImageMode(); |
111 | |
112 // Update the background of all root windows using the current wallpaper image | |
113 // in |current_wallpaper_|. | |
114 void UpdateDesktopBackgroundImageMode(); | |
115 | 123 |
116 // Creates a new background widget and sets the background mode to image mode. | 124 // Creates a new background widget and sets the background mode to image mode. |
117 // Called after wallpaper loaded successfully. | 125 // Called after wallpaper loaded successfully. |
118 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); | 126 void OnWallpaperLoadCompleted(scoped_refptr<WallpaperOperation> wo); |
119 | 127 |
| 128 // Adds layer with solid |color| to container |container_id| in |root_window|. |
| 129 ui::Layer* SetColorLayerForContainer(SkColor color, |
| 130 aura::RootWindow* root_window, |
| 131 int container_id); |
| 132 |
| 133 // Creates and adds component for current mode (either Widget or Layer) to |
| 134 // |root_window|. |
| 135 void InstallComponent(aura::RootWindow* root_window); |
| 136 |
| 137 // Creates and adds component for current mode (either Widget or Layer) to |
| 138 // all root windows. |
| 139 void InstallComponentForAllWindows(); |
| 140 |
| 141 // Moves all descktop components from one container to other across all root |
| 142 // windows. |
| 143 void ReparentBackgroundWidgets(int src_container, int dst_container); |
| 144 |
| 145 // Returns id for background container for unlocked and locked states. |
| 146 int GetBackgroundContainerId(bool locked); |
| 147 |
120 // Can change at runtime. | 148 // Can change at runtime. |
| 149 bool locked_; |
| 150 |
121 BackgroundMode desktop_background_mode_; | 151 BackgroundMode desktop_background_mode_; |
122 | 152 |
123 SkColor background_color_; | 153 SkColor background_color_; |
124 | 154 |
125 // The current wallpaper. | 155 // The current wallpaper. |
126 scoped_ptr<WallpaperData> current_wallpaper_; | 156 scoped_ptr<WallpaperData> current_wallpaper_; |
127 | 157 |
128 scoped_refptr<WallpaperOperation> wallpaper_op_; | 158 scoped_refptr<WallpaperOperation> wallpaper_op_; |
129 | 159 |
130 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; | 160 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; |
131 | 161 |
132 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); | 162 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); |
133 }; | 163 }; |
134 | 164 |
135 } // namespace ash | 165 } // namespace ash |
136 | 166 |
137 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ | 167 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ |
OLD | NEW |