cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / desktop_background / desktop_background_controller.h
bloba06a3fdfe14345deb46e6b06bdba2285a74188f3
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
3 // found in the LICENSE file.
5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "ash/display/window_tree_host_manager.h"
10 #include "ash/shell_observer.h"
11 #include "base/basictypes.h"
12 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h"
17 #include "base/timer/timer.h"
18 #include "components/wallpaper/wallpaper_layout.h"
19 #include "ui/compositor/layer.h"
20 #include "ui/gfx/image/image_skia.h"
22 typedef unsigned int SkColor;
24 namespace aura {
25 class Window;
28 namespace wallpaper {
29 class WallpaperResizer;
32 namespace ash {
34 const SkColor kLoginWallpaperColor = 0xFEFEFE;
36 class DesktopBackgroundControllerObserver;
38 // Updates background layer if necessary.
39 class ASH_EXPORT DesktopBackgroundController
40 : public WindowTreeHostManager::Observer,
41 public ShellObserver {
42 public:
43 class TestAPI;
45 enum BackgroundMode {
46 BACKGROUND_NONE,
47 BACKGROUND_IMAGE,
50 DesktopBackgroundController();
51 ~DesktopBackgroundController() override;
53 BackgroundMode desktop_background_mode() const {
54 return desktop_background_mode_;
57 // Add/Remove observers.
58 void AddObserver(DesktopBackgroundControllerObserver* observer);
59 void RemoveObserver(DesktopBackgroundControllerObserver* observer);
61 // Provides current image on the background, or empty gfx::ImageSkia if there
62 // is no image, e.g. background is none.
63 gfx::ImageSkia GetWallpaper() const;
65 wallpaper::WallpaperLayout GetWallpaperLayout() const;
67 // Sets wallpaper. This is mostly called by WallpaperManager to set
68 // the default or user selected custom wallpaper.
69 // Returns true if new image was actually set. And false when duplicate set
70 // request detected.
71 bool SetWallpaperImage(const gfx::ImageSkia& image,
72 wallpaper::WallpaperLayout layout);
74 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready
75 // when running. However, the wallpaper widgets are now created
76 // asynchronously. If loading a real wallpaper, there are cases that these
77 // tests crash because the required widget is not ready. This function
78 // synchronously creates an empty widget for those tests to prevent
79 // crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe.
80 void CreateEmptyWallpaper();
82 // Move all desktop widgets to locked container.
83 // Returns true if the desktop moved.
84 bool MoveDesktopToLockedContainer();
86 // Move all desktop widgets to unlocked container.
87 // Returns true if the desktop moved.
88 bool MoveDesktopToUnlockedContainer();
90 // WindowTreeHostManager::Observer:
91 void OnDisplayConfigurationChanged() override;
93 // ShellObserver:
94 void OnRootWindowAdded(aura::Window* root_window) override;
96 // Returns the maximum size of all displays combined in native
97 // resolutions. Note that this isn't the bounds of the display who
98 // has maximum resolutions. Instead, this returns the size of the
99 // maximum width of all displays, and the maximum height of all displays.
100 static gfx::Size GetMaxDisplaySizeInNative();
102 // Returns true if the specified wallpaper is already stored
103 // in |current_wallpaper_|.
104 // If |compare_layouts| is false, layout is ignored.
105 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia& image,
106 bool compare_layouts,
107 wallpaper::WallpaperLayout layout) const;
109 private:
110 friend class DesktopBackgroundControllerTest;
111 // friend class chromeos::WallpaperManagerBrowserTestDefaultWallpaper;
112 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize);
114 // Creates view for all root windows, or notifies them to repaint if they
115 // already exist.
116 void SetDesktopBackgroundImageMode();
118 // Creates and adds component for current mode (either Widget or Layer) to
119 // |root_window|.
120 void InstallDesktopController(aura::Window* root_window);
122 // Creates and adds component for current mode (either Widget or Layer) to
123 // all root windows.
124 void InstallDesktopControllerForAllWindows();
126 // Moves all desktop components from one container to other across all root
127 // windows. Returns true if a desktop moved.
128 bool ReparentBackgroundWidgets(int src_container, int dst_container);
130 // Returns id for background container for unlocked and locked states.
131 int GetBackgroundContainerId(bool locked);
133 // Send notification that background animation finished.
134 void NotifyAnimationFinished();
136 // Reload the wallpaper. |clear_cache| specifies whether to clear the
137 // wallpaper cahce or not.
138 void UpdateWallpaper(bool clear_cache);
140 void set_wallpaper_reload_delay_for_test(bool value) {
141 wallpaper_reload_delay_ = value;
144 // Can change at runtime.
145 bool locked_;
147 BackgroundMode desktop_background_mode_;
149 SkColor background_color_;
151 base::ObserverList<DesktopBackgroundControllerObserver> observers_;
153 // The current wallpaper.
154 scoped_ptr<wallpaper::WallpaperResizer> current_wallpaper_;
156 gfx::Size current_max_display_size_;
158 base::OneShotTimer<DesktopBackgroundController> timer_;
160 int wallpaper_reload_delay_;
162 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController);
165 } // namespace ash
167 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_