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

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

Issue 208273005: If customization includes default wallpaper, download and apply it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Start customization manifest fetch on EULA accepted. Never re-fetch wallpaper. Created 6 years, 9 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_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/display/display_controller.h" 9 #include "ash/display/display_controller.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 BACKGROUND_IMAGE, 76 BACKGROUND_IMAGE,
77 }; 77 };
78 78
79 DesktopBackgroundController(); 79 DesktopBackgroundController();
80 virtual ~DesktopBackgroundController(); 80 virtual ~DesktopBackgroundController();
81 81
82 BackgroundMode desktop_background_mode() const { 82 BackgroundMode desktop_background_mode() const {
83 return desktop_background_mode_; 83 return desktop_background_mode_;
84 } 84 }
85 85
86 void set_command_line_for_testing(base::CommandLine* command_line) { 86 void set_command_line_for_testing(base::CommandLine* command_line);
87 command_line_for_testing_ = command_line;
88 }
89 87
90 // Add/Remove observers. 88 // Add/Remove observers.
91 void AddObserver(DesktopBackgroundControllerObserver* observer); 89 void AddObserver(DesktopBackgroundControllerObserver* observer);
92 void RemoveObserver(DesktopBackgroundControllerObserver* observer); 90 void RemoveObserver(DesktopBackgroundControllerObserver* observer);
93 91
94 // Provides current image on the background, or empty gfx::ImageSkia if there 92 // Provides current image on the background, or empty gfx::ImageSkia if there
95 // is no image, e.g. background is none. 93 // is no image, e.g. background is none.
96 gfx::ImageSkia GetWallpaper() const; 94 gfx::ImageSkia GetWallpaper() const;
97 95
98 WallpaperLayout GetWallpaperLayout() const; 96 WallpaperLayout GetWallpaperLayout() const;
(...skipping 26 matching lines...) Expand all
125 WallpaperResolution GetAppropriateResolution(); 123 WallpaperResolution GetAppropriateResolution();
126 124
127 // Move all desktop widgets to locked container. 125 // Move all desktop widgets to locked container.
128 // Returns true if the desktop moved. 126 // Returns true if the desktop moved.
129 bool MoveDesktopToLockedContainer(); 127 bool MoveDesktopToLockedContainer();
130 128
131 // Move all desktop widgets to unlocked container. 129 // Move all desktop widgets to unlocked container.
132 // Returns true if the desktop moved. 130 // Returns true if the desktop moved.
133 bool MoveDesktopToUnlockedContainer(); 131 bool MoveDesktopToUnlockedContainer();
134 132
133 // Use given files as default wallpaper.
134 void SetDefaultWallpaperPath(
135 const base::FilePath& customized_default_wallpaper_file_small,
136 const base::FilePath& customized_default_wallpaper_file_large);
137
135 // Overrides DisplayController::Observer: 138 // Overrides DisplayController::Observer:
136 virtual void OnDisplayConfigurationChanged() OVERRIDE; 139 virtual void OnDisplayConfigurationChanged() OVERRIDE;
137 140
138 private: 141 private:
139 friend class DesktopBackgroundControllerTest; 142 friend class DesktopBackgroundControllerTest;
140 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize); 143 FRIEND_TEST_ALL_PREFIXES(DesktopBackgroundControllerTest, GetMaxDisplaySize);
141 144
142 // An operation to asynchronously loads wallpaper. 145 // An operation to asynchronously loads wallpaper.
143 class WallpaperLoader; 146 class WallpaperLoader;
144 147
148 // Init "*default_*_wallpaper_file_" from given command line.
149 void SetDefaultWallpaperPathFromCommandLine(base::CommandLine* command_line);
150
145 // Returns true if the specified default wallpaper is already being 151 // Returns true if the specified default wallpaper is already being
146 // loaded by |wallpaper_loader_| or stored in |current_wallpaper_|. 152 // loaded by |wallpaper_loader_| or stored in |current_wallpaper_|.
153 // (i.e. no need to reload if exactly duplicate request received)
147 bool DefaultWallpaperIsAlreadyLoadingOrLoaded( 154 bool DefaultWallpaperIsAlreadyLoadingOrLoaded(
148 const base::FilePath& image_file, int image_resource_id) const; 155 const base::FilePath& image_file, int image_resource_id) const;
149 156
157 // Returns true if the specified default wallpaper file is already being
158 // loaded |wallpaper_loader_| or stored in |current_wallpaper_|.
Mattias Nissler (ping if slow) 2014/03/24 20:38:54 nit: ... loaded *by* |wallpaper_loader|...
Alexander Alekseev 2014/03/25 14:38:29 Done.
159 // (i.e. if current wallpaper is "default" and we need to replace the default
160 // wallpaper with another file, we need to initiate SetDefaultWallpaper() )
161 bool DefaultWallpaperFileIsAlreadyLoadingOrLoaded(
162 const base::FilePath& image_file) const;
163
150 // Returns true if the specified custom wallpaper is already stored 164 // Returns true if the specified custom wallpaper is already stored
151 // in |current_wallpaper_|. 165 // in |current_wallpaper_|.
152 bool CustomWallpaperIsAlreadyLoaded(const gfx::ImageSkia& image) const; 166 bool CustomWallpaperIsAlreadyLoaded(const gfx::ImageSkia& image) const;
153 167
154 // Creates view for all root windows, or notifies them to repaint if they 168 // Creates view for all root windows, or notifies them to repaint if they
155 // already exist. 169 // already exist.
156 void SetDesktopBackgroundImageMode(); 170 void SetDesktopBackgroundImageMode();
157 171
158 // Creates a new background widget and sets the background mode to image mode. 172 // Creates a new background widget and sets the background mode to image mode.
159 // Called after a default wallpaper has been loaded successfully. 173 // Called after a default wallpaper has been loaded successfully.
(...skipping 23 matching lines...) Expand all
183 void set_wallpaper_reload_delay_for_test(bool value) { 197 void set_wallpaper_reload_delay_for_test(bool value) {
184 wallpaper_reload_delay_ = value; 198 wallpaper_reload_delay_ = value;
185 } 199 }
186 200
187 // Returns the maximum size of all displays combined in native 201 // Returns the maximum size of all displays combined in native
188 // resolutions. Note that this isn't the bounds of the display who 202 // resolutions. Note that this isn't the bounds of the display who
189 // has maximum resolutions. Instead, this returns the size of the 203 // has maximum resolutions. Instead, this returns the size of the
190 // maximum width of all displays, and the maximum height of all displays. 204 // maximum width of all displays, and the maximum height of all displays.
191 static gfx::Size GetMaxDisplaySizeInNative(); 205 static gfx::Size GetMaxDisplaySizeInNative();
192 206
207 // SetDefaultWallpaper using given path and mode.
208 bool DoSetDefaultWallpaper(const base::FilePath& file_path,
209 const bool use_large);
210
211 // Before setting first wallpaper we need to check and probably apply
212 // device customization.
213 void CheckForCustomization();
214
193 // If non-NULL, used in place of the real command line. 215 // If non-NULL, used in place of the real command line.
194 base::CommandLine* command_line_for_testing_; 216 base::CommandLine* command_line_for_testing_;
195 217
196 // Can change at runtime. 218 // Can change at runtime.
197 bool locked_; 219 bool locked_;
198 220
199 BackgroundMode desktop_background_mode_; 221 BackgroundMode desktop_background_mode_;
200 222
201 SkColor background_color_; 223 SkColor background_color_;
202 224
(...skipping 12 matching lines...) Expand all
215 237
216 // Loads default wallpaper from disk. 238 // Loads default wallpaper from disk.
217 scoped_refptr<WallpaperLoader> default_wallpaper_loader_; 239 scoped_refptr<WallpaperLoader> default_wallpaper_loader_;
218 240
219 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_; 241 base::WeakPtrFactory<DesktopBackgroundController> weak_ptr_factory_;
220 242
221 base::OneShotTimer<DesktopBackgroundController> timer_; 243 base::OneShotTimer<DesktopBackgroundController> timer_;
222 244
223 int wallpaper_reload_delay_; 245 int wallpaper_reload_delay_;
224 246
247 base::FilePath default_small_wallpaper_file_;
248 base::FilePath default_large_wallpaper_file_;
249
250 base::FilePath guest_default_small_wallpaper_file_;
251 base::FilePath guest_default_large_wallpaper_file_;
252
253 bool customization_applied_;
254
225 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController); 255 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundController);
226 }; 256 };
227 257
228 } // namespace ash 258 } // namespace ash
229 259
230 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ 260 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698