Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: ash/desktop_background/desktop_background_controller.h

Issue 2200893002: mash: Partially migrate ash/desktop_background to ash common types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mash browser test crash in GetMaxDisplaySizeInNative. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/ash.gyp ('k') | ash/desktop_background/desktop_background_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/common/shell_observer.h" 11 #include "ash/common/shell_observer.h"
12 #include "ash/display/window_tree_host_manager.h" 12 #include "ash/common/wm_display_observer.h"
13 #include "base/files/file_path.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 13 #include "base/observer_list.h"
18 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
19 #include "components/wallpaper/wallpaper_layout.h" 15 #include "components/wallpaper/wallpaper_layout.h"
20 #include "ui/compositor/layer.h"
21 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
22 17
23 typedef unsigned int SkColor;
24
25 namespace aura {
26 class Window;
27 }
28
29 namespace base { 18 namespace base {
30 class SequencedWorkerPool; 19 class SequencedWorkerPool;
31 } 20 }
32 21
33 namespace wallpaper { 22 namespace wallpaper {
34 class WallpaperResizer; 23 class WallpaperResizer;
35 } 24 }
36 25
37 namespace ash { 26 namespace ash {
38 27
39 const SkColor kLoginWallpaperColor = 0xFEFEFE;
40
41 class DesktopBackgroundControllerObserver; 28 class DesktopBackgroundControllerObserver;
42 29
43 // Updates background layer if necessary. 30 // Updates the desktop background wallpaper.
44 class ASH_EXPORT DesktopBackgroundController 31 class ASH_EXPORT DesktopBackgroundController : public WmDisplayObserver,
45 : public WindowTreeHostManager::Observer, 32 public ShellObserver {
46 public ShellObserver {
47 public: 33 public:
48 class TestAPI; 34 enum BackgroundMode { BACKGROUND_NONE, BACKGROUND_IMAGE };
49
50 enum BackgroundMode {
51 BACKGROUND_NONE,
52 BACKGROUND_IMAGE,
53 };
54 35
55 explicit DesktopBackgroundController( 36 explicit DesktopBackgroundController(
56 base::SequencedWorkerPool* blocking_pool); 37 base::SequencedWorkerPool* blocking_pool);
57 ~DesktopBackgroundController() override; 38 ~DesktopBackgroundController() override;
58 39
59 BackgroundMode desktop_background_mode() const {
60 return desktop_background_mode_;
61 }
62
63 // Add/Remove observers. 40 // Add/Remove observers.
64 void AddObserver(DesktopBackgroundControllerObserver* observer); 41 void AddObserver(DesktopBackgroundControllerObserver* observer);
65 void RemoveObserver(DesktopBackgroundControllerObserver* observer); 42 void RemoveObserver(DesktopBackgroundControllerObserver* observer);
66 43
67 // Provides current image on the background, or empty gfx::ImageSkia if there 44 // Provides current image on the background, or empty gfx::ImageSkia if there
68 // is no image, e.g. background is none. 45 // is no image, e.g. background is none.
69 gfx::ImageSkia GetWallpaper() const; 46 gfx::ImageSkia GetWallpaper() const;
70 47
71 wallpaper::WallpaperLayout GetWallpaperLayout() const; 48 wallpaper::WallpaperLayout GetWallpaperLayout() const;
72 49
(...skipping 13 matching lines...) Expand all
86 void CreateEmptyWallpaper(); 63 void CreateEmptyWallpaper();
87 64
88 // Move all desktop widgets to locked container. 65 // Move all desktop widgets to locked container.
89 // Returns true if the desktop moved. 66 // Returns true if the desktop moved.
90 bool MoveDesktopToLockedContainer(); 67 bool MoveDesktopToLockedContainer();
91 68
92 // Move all desktop widgets to unlocked container. 69 // Move all desktop widgets to unlocked container.
93 // Returns true if the desktop moved. 70 // Returns true if the desktop moved.
94 bool MoveDesktopToUnlockedContainer(); 71 bool MoveDesktopToUnlockedContainer();
95 72
96 // WindowTreeHostManager::Observer: 73 // WmDisplayObserver:
97 void OnDisplayConfigurationChanged() override; 74 void OnDisplayConfigurationChanged() override;
98 75
99 // ShellObserver: 76 // ShellObserver:
100 void OnRootWindowAdded(WmWindow* root_window) override; 77 void OnRootWindowAdded(WmWindow* root_window) override;
101 78
102 // Returns the maximum size of all displays combined in native 79 // Returns the maximum size of all displays combined in native
103 // resolutions. Note that this isn't the bounds of the display who 80 // resolutions. Note that this isn't the bounds of the display who
104 // has maximum resolutions. Instead, this returns the size of the 81 // has maximum resolutions. Instead, this returns the size of the
105 // maximum width of all displays, and the maximum height of all displays. 82 // maximum width of all displays, and the maximum height of all displays.
106 static gfx::Size GetMaxDisplaySizeInNative(); 83 static gfx::Size GetMaxDisplaySizeInNative();
107 84
108 // Returns true if the specified wallpaper is already stored 85 // Returns true if the specified wallpaper is already stored
109 // in |current_wallpaper_|. 86 // in |current_wallpaper_|.
110 // If |compare_layouts| is false, layout is ignored. 87 // If |compare_layouts| is false, layout is ignored.
111 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia& image, 88 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia& image,
112 bool compare_layouts, 89 bool compare_layouts,
113 wallpaper::WallpaperLayout layout) const; 90 wallpaper::WallpaperLayout layout) const;
114 91
92 void set_wallpaper_reload_delay_for_test(int value) {
93 wallpaper_reload_delay_ = value;
94 }
95
115 private: 96 private:
116 friend class DesktopBackgroundControllerTest; 97 // Creates a DesktopBackgroundWidgetController for |root_window|.
117 // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper; 98 void InstallDesktopController(WmWindow* root_window);
118 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize);
119 99
120 // Creates view for all root windows, or notifies them to repaint if they 100 // Creates a DesktopBackgroundWidgetController for all root windows.
121 // already exist.
122 void SetDesktopBackgroundImageMode();
123
124 // Creates and adds component for current mode (either Widget or Layer) to
125 // |root_window|.
126 void InstallDesktopController(aura::Window* root_window);
127
128 // Creates and adds component for current mode (either Widget or Layer) to
129 // all root windows.
130 void InstallDesktopControllerForAllWindows(); 101 void InstallDesktopControllerForAllWindows();
131 102
132 // Moves all desktop components from one container to other across all root 103 // Moves all desktop components from one container to other across all root
133 // windows. Returns true if a desktop moved. 104 // windows. Returns true if a desktop moved.
134 bool ReparentBackgroundWidgets(int src_container, int dst_container); 105 bool ReparentBackgroundWidgets(int src_container, int dst_container);
135 106
136 // Returns id for background container for unlocked and locked states. 107 // Returns id for background container for unlocked and locked states.
137 int GetBackgroundContainerId(bool locked); 108 int GetBackgroundContainerId(bool locked);
138 109
139 // Send notification that background animation finished.
140 void NotifyAnimationFinished();
141
142 // Reload the wallpaper. |clear_cache| specifies whether to clear the 110 // Reload the wallpaper. |clear_cache| specifies whether to clear the
143 // wallpaper cahce or not. 111 // wallpaper cahce or not.
144 void UpdateWallpaper(bool clear_cache); 112 void UpdateWallpaper(bool clear_cache);
145 113
146 void set_wallpaper_reload_delay_for_test(bool value) {
147 wallpaper_reload_delay_ = value;
148 }
149
150 // Can change at runtime.
151 bool locked_; 114 bool locked_;
152 115
153 BackgroundMode desktop_background_mode_; 116 BackgroundMode desktop_background_mode_;
154 117
155 SkColor background_color_;
156
157 base::ObserverList<DesktopBackgroundControllerObserver> observers_; 118 base::ObserverList<DesktopBackgroundControllerObserver> observers_;
158 119
159 // The current wallpaper.
160 std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_; 120 std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_;
161 121
162 gfx::Size current_max_display_size_; 122 gfx::Size current_max_display_size_;
163 123
164 base::OneShotTimer timer_; 124 base::OneShotTimer timer_;
165 125
166 int wallpaper_reload_delay_; 126 int wallpaper_reload_delay_;
167 127
168 base::SequencedWorkerPool* blocking_pool_; 128 base::SequencedWorkerPool* blocking_pool_;
169 129
170 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); 130 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController);
171 }; 131 };
172 132
173 } // namespace ash 133 } // namespace ash
174 134
175 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ 135 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/ash.gyp ('k') | ash/desktop_background/desktop_background_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698