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

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

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

Powered by Google App Engine
This is Rietveld 408576698