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

Side by Side Diff: ash/common/wallpaper/wallpaper_controller.h

Issue 2413503002: Cleanup mojo Wallpaper interfaces for mash. (Closed)
Patch Set: Cleanup. Created 4 years, 2 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
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_COMMON_WALLPAPER_WALLPAPER_CONTROLLER_H_ 5 #ifndef ASH_COMMON_WALLPAPER_WALLPAPER_CONTROLLER_H_
6 #define ASH_COMMON_WALLPAPER_WALLPAPER_CONTROLLER_H_ 6 #define ASH_COMMON_WALLPAPER_WALLPAPER_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/common/wm_display_observer.h" 12 #include "ash/common/wm_display_observer.h"
13 #include "ash/public/interfaces/wallpaper.mojom.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "components/wallpaper/wallpaper_layout.h" 17 #include "components/wallpaper/wallpaper_layout.h"
18 #include "mojo/public/cpp/bindings/binding_set.h"
17 #include "ui/gfx/image/image_skia.h" 19 #include "ui/gfx/image/image_skia.h"
18 20
19 namespace base { 21 namespace base {
20 class TaskRunner; 22 class TaskRunner;
21 } 23 }
22 24
23 namespace wallpaper { 25 namespace wallpaper {
24 class WallpaperResizer; 26 class WallpaperResizer;
25 } 27 }
26 28
27 namespace ash { 29 namespace ash {
28 30
29 class WallpaperControllerObserver; 31 class WallpaperControllerObserver;
30 32
31 // Controls the desktop background wallpaper. 33 // Controls the desktop background wallpaper.
32 class ASH_EXPORT WallpaperController : public WmDisplayObserver, 34 class ASH_EXPORT WallpaperController : public mojom::WallpaperController,
35 public WmDisplayObserver,
33 public ShellObserver { 36 public ShellObserver {
34 public: 37 public:
35 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; 38 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE };
36 39
37 explicit WallpaperController( 40 explicit WallpaperController(
38 const scoped_refptr<base::TaskRunner>& task_runner); 41 const scoped_refptr<base::TaskRunner>& task_runner);
39 ~WallpaperController() override; 42 ~WallpaperController() override;
40 43
44 // Binds the mojom::WallpaperController interface request to this object.
45 void BindRequest(mojom::WallpaperControllerRequest request);
46
41 // Add/Remove observers. 47 // Add/Remove observers.
42 void AddObserver(WallpaperControllerObserver* observer); 48 void AddObserver(WallpaperControllerObserver* observer);
43 void RemoveObserver(WallpaperControllerObserver* observer); 49 void RemoveObserver(WallpaperControllerObserver* observer);
44 50
45 // Provides current image on the wallpaper, or empty gfx::ImageSkia if there 51 // Provides current image on the wallpaper, or empty gfx::ImageSkia if there
46 // is no image, e.g. wallpaper is none. 52 // is no image, e.g. wallpaper is none.
47 gfx::ImageSkia GetWallpaper() const; 53 gfx::ImageSkia GetWallpaper() const;
48 54
49 wallpaper::WallpaperLayout GetWallpaperLayout() const; 55 wallpaper::WallpaperLayout GetWallpaperLayout() const;
50 56
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // in |current_wallpaper_|. 93 // in |current_wallpaper_|.
88 // If |compare_layouts| is false, layout is ignored. 94 // If |compare_layouts| is false, layout is ignored.
89 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia& image, 95 bool WallpaperIsAlreadyLoaded(const gfx::ImageSkia& image,
90 bool compare_layouts, 96 bool compare_layouts,
91 wallpaper::WallpaperLayout layout) const; 97 wallpaper::WallpaperLayout layout) const;
92 98
93 void set_wallpaper_reload_delay_for_test(int value) { 99 void set_wallpaper_reload_delay_for_test(int value) {
94 wallpaper_reload_delay_ = value; 100 wallpaper_reload_delay_ = value;
95 } 101 }
96 102
103 // Opens the set wallpaper page in the browser.
104 void OpenSetWallpaperPage();
105
106 // mojom::WallpaperController overrides:
107 void SetWallpaper(const SkBitmap& wallpaper,
108 mojom::WallpaperLayout layout) override;
109
97 private: 110 private:
98 // Creates a WallpaperWidgetController for |root_window|. 111 // Creates a WallpaperWidgetController for |root_window|.
99 void InstallDesktopController(WmWindow* root_window); 112 void InstallDesktopController(WmWindow* root_window);
100 113
101 // Creates a WallpaperWidgetController for all root windows. 114 // Creates a WallpaperWidgetController for all root windows.
102 void InstallDesktopControllerForAllWindows(); 115 void InstallDesktopControllerForAllWindows();
103 116
104 // Moves the wallpaper to the specified container across all root windows. 117 // Moves the wallpaper to the specified container across all root windows.
105 // Returns true if a wallpaper moved. 118 // Returns true if a wallpaper moved.
106 bool ReparentWallpaper(int container); 119 bool ReparentWallpaper(int container);
107 120
108 // Returns the wallpaper container id for unlocked and locked states. 121 // Returns the wallpaper container id for unlocked and locked states.
109 int GetWallpaperContainerId(bool locked); 122 int GetWallpaperContainerId(bool locked);
110 123
111 // Reload the wallpaper. |clear_cache| specifies whether to clear the 124 // Reload the wallpaper. |clear_cache| specifies whether to clear the
112 // wallpaper cahce or not. 125 // wallpaper cahce or not.
113 void UpdateWallpaper(bool clear_cache); 126 void UpdateWallpaper(bool clear_cache);
114 127
115 bool locked_; 128 bool locked_;
116 129
117 WallpaperMode wallpaper_mode_; 130 WallpaperMode wallpaper_mode_;
118 131
132 // Bindings for the WallpaperController interface.
133 mojo::BindingSet<mojom::WallpaperController> bindings_;
134
119 base::ObserverList<WallpaperControllerObserver> observers_; 135 base::ObserverList<WallpaperControllerObserver> observers_;
120 136
121 std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_; 137 std::unique_ptr<wallpaper::WallpaperResizer> current_wallpaper_;
122 138
123 gfx::Size current_max_display_size_; 139 gfx::Size current_max_display_size_;
124 140
125 base::OneShotTimer timer_; 141 base::OneShotTimer timer_;
126 142
127 int wallpaper_reload_delay_; 143 int wallpaper_reload_delay_;
128 144
129 scoped_refptr<base::TaskRunner> task_runner_; 145 scoped_refptr<base::TaskRunner> task_runner_;
130 146
131 DISALLOW_COPY_AND_ASSIGN(WallpaperController); 147 DISALLOW_COPY_AND_ASSIGN(WallpaperController);
132 }; 148 };
133 149
134 } // namespace ash 150 } // namespace ash
135 151
136 #endif // ASH_COMMON_WALLPAPER_WALLPAPER_CONTROLLER_H_ 152 #endif // ASH_COMMON_WALLPAPER_WALLPAPER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698