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

Side by Side Diff: chrome/browser/chromeos/login/wallpaper_manager.h

Issue 11308068: Remove the old wallpaper picker code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ash/desktop_background/desktop_background_resources.h" 10 #include "ash/desktop_background/desktop_background_resources.h"
11 #include "base/file_path.h"
11 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/time.h" 14 #include "base/time.h"
14 #include "base/timer.h" 15 #include "base/timer.h"
15 #include "chrome/browser/chromeos/login/user.h" 16 #include "chrome/browser/chromeos/login/user.h"
16 #include "chrome/browser/chromeos/login/user_image.h" 17 #include "chrome/browser/chromeos/login/user_image.h"
17 #include "chrome/browser/chromeos/login/user_image_loader.h" 18 #include "chrome/browser/chromeos/login/user_image_loader.h"
18 #include "chrome/browser/chromeos/system/timezone_settings.h" 19 #include "chrome/browser/chromeos/system/timezone_settings.h"
19 #include "chrome/browser/ui/webui/options/chromeos/set_wallpaper_options_handler .h"
20 #include "chromeos/dbus/power_manager_client.h" 20 #include "chromeos/dbus/power_manager_client.h"
21 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
23 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
24 #include "unicode/timezone.h" 24 #include "unicode/timezone.h"
25 25
26 class PrefService; 26 class PrefService;
27 27
28 namespace chromeos { 28 namespace chromeos {
29 29
(...skipping 25 matching lines...) Expand all
55 55
56 WallpaperManager(); 56 WallpaperManager();
57 57
58 // Registers wallpaper manager preferences. 58 // Registers wallpaper manager preferences.
59 static void RegisterPrefs(PrefService* local_state); 59 static void RegisterPrefs(PrefService* local_state);
60 60
61 // Adds PowerManagerClient and TimeZoneSettings observers. It needs to be 61 // Adds PowerManagerClient and TimeZoneSettings observers. It needs to be
62 // added after PowerManagerClient initialized. 62 // added after PowerManagerClient initialized.
63 void AddObservers(); 63 void AddObservers();
64 64
65 // Migrate the old wallpaper index to a new wallpaper structure for all users
66 // in |users|.
67 // The new wallpaper structure is:
68 // { WallpaperType: DAILY|CUSTOMIZED|DEFAULT,
69 // index: index of the default wallpapers }
70 void MigrateWallpaperData(const UserList& users);
71
72 // Loads wallpaper asynchronously if the current wallpaper is not the 65 // Loads wallpaper asynchronously if the current wallpaper is not the
73 // wallpaper of logged in user. 66 // wallpaper of logged in user.
74 void EnsureLoggedInUserWallpaperLoaded(); 67 void EnsureLoggedInUserWallpaperLoaded();
75 68
76 // Gets |email|'s wallpaper from local disk. When |update_wallpaper| is true,
77 // sets wallpaper to the loaded wallpaper
78 void GetCustomWallpaper(const std::string& email, bool update_wallpaper);
79
80 // Clears ONLINE and CUSTOM wallpaper cache. 69 // Clears ONLINE and CUSTOM wallpaper cache.
81 void ClearWallpaperCache(); 70 void ClearWallpaperCache();
82 71
83 // Gets encoded wallpaper from cache. Returns true if success. 72 // Gets encoded wallpaper from cache. Returns true if success.
84 bool GetWallpaperFromCache(const std::string& email, 73 bool GetWallpaperFromCache(const std::string& email,
85 gfx::ImageSkia* wallpaper); 74 gfx::ImageSkia* wallpaper);
86 75
87 // Returns filepath to save original custom wallpaper for the given user. 76 // Returns filepath to save original custom wallpaper for the given user.
88 FilePath GetOriginalWallpaperPathForUser(const std::string& username); 77 FilePath GetOriginalWallpaperPathForUser(const std::string& username);
89 78
90 // Returns small resolution custom wallpaper filepath for the given user when 79 // Returns small resolution custom wallpaper filepath for the given user when
91 // |is_small| is ture. Otherwise, returns large resolution custom wallpaper 80 // |is_small| is ture. Otherwise, returns large resolution custom wallpaper
92 // path. 81 // path.
93 FilePath GetWallpaperPathForUser(const std::string& username, 82 FilePath GetWallpaperPathForUser(const std::string& username,
94 bool is_small); 83 bool is_small);
95 84
96 // Gets the thumbnail of custom wallpaper from cache. 85 // Gets the thumbnail of custom wallpaper from cache.
97 gfx::ImageSkia GetCustomWallpaperThumbnail(const std::string& email); 86 gfx::ImageSkia GetCustomWallpaperThumbnail(const std::string& email);
98 87
99 // Gets wallpaper properties of logged in user.
100 void GetLoggedInUserWallpaperProperties(User::WallpaperType* type,
101 int* index,
102 base::Time* last_modification_date);
103
104 // Gets wallpaper information of logged in user. 88 // Gets wallpaper information of logged in user.
105 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info); 89 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info);
106 90
107 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged 91 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged
108 // in, uses a solid color wallpaper. If logged in as a stub user, uses an 92 // in, uses a solid color wallpaper. If logged in as a stub user, uses an
109 // empty wallpaper. 93 // empty wallpaper.
110 void InitializeWallpaper(); 94 void InitializeWallpaper();
111 95
112 // NotificationObserver overrides: 96 // NotificationObserver overrides:
113 virtual void Observe(int type, 97 virtual void Observe(int type,
(...skipping 14 matching lines...) Expand all
128 112
129 // Starts a one shot timer which calls BatchUpdateWallpaper at next midnight. 113 // Starts a one shot timer which calls BatchUpdateWallpaper at next midnight.
130 // Cancel any previous timer if any. 114 // Cancel any previous timer if any.
131 void RestartTimer(); 115 void RestartTimer();
132 116
133 // Saves custom wallpaper to file, post task to generate thumbnail and updates 117 // Saves custom wallpaper to file, post task to generate thumbnail and updates
134 // local state preferences. 118 // local state preferences.
135 void SetCustomWallpaper(const std::string& username, 119 void SetCustomWallpaper(const std::string& username,
136 ash::WallpaperLayout layout, 120 ash::WallpaperLayout layout,
137 User::WallpaperType type, 121 User::WallpaperType type,
138 base::WeakPtr<WallpaperDelegate> delegate,
139 const UserImage& wallpaper); 122 const UserImage& wallpaper);
140 123
141 // Tries to load user image from disk; if successful, sets it for the user,
142 // and updates Local State.
143 void SetUserWallpaperFromFile(const std::string& username,
144 const FilePath& path,
145 ash::WallpaperLayout layout,
146 base::WeakPtr<WallpaperDelegate> delegate);
147
148 // Sets selected wallpaper properties for |username| and saves it to Local
149 // State if |is_persistent| is true.
150 void SetUserWallpaperProperties(const std::string& email,
151 User::WallpaperType type,
152 int index,
153 bool is_persistent);
154
155 // Sets one of the default wallpapers for the specified user and saves this 124 // Sets one of the default wallpapers for the specified user and saves this
156 // settings in local state. 125 // settings in local state.
157 void SetInitialUserWallpaper(const std::string& username, bool is_persistent); 126 void SetInitialUserWallpaper(const std::string& username, bool is_persistent);
158 127
159 // Sets selected wallpaper information for |username| and saves it to Local 128 // Sets selected wallpaper information for |username| and saves it to Local
160 // State if |is_persistent| is true. 129 // State if |is_persistent| is true.
161 void SetUserWallpaperInfo(const std::string& username, 130 void SetUserWallpaperInfo(const std::string& username,
162 const WallpaperInfo& info, 131 const WallpaperInfo& info,
163 bool is_persistent); 132 bool is_persistent);
164 133
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // should be only executed once. 170 // should be only executed once.
202 void CacheAllUsersWallpapers(); 171 void CacheAllUsersWallpapers();
203 172
204 // Caches |email|'s wallpaper to memory. 173 // Caches |email|'s wallpaper to memory.
205 void CacheUserWallpaper(const std::string& email); 174 void CacheUserWallpaper(const std::string& email);
206 175
207 // Generates a 128x80 thumbnail and caches it. 176 // Generates a 128x80 thumbnail and caches it.
208 void CacheThumbnail(const std::string& email, 177 void CacheThumbnail(const std::string& email,
209 scoped_ptr<gfx::ImageSkia> wallpaper); 178 scoped_ptr<gfx::ImageSkia> wallpaper);
210 179
180 // Clears all obsolete wallpaper prefs from old version wallpaper pickers.
181 void ClearObsoleteWallpaperPrefs();
182
211 // Deletes a list of wallpaper files in |file_list|. 183 // Deletes a list of wallpaper files in |file_list|.
212 void DeleteWallpaperInList(const std::vector<FilePath>& file_list); 184 void DeleteWallpaperInList(const std::vector<FilePath>& file_list);
213 185
214 // Deletes all |email| related custom or converted wallpapers. 186 // Deletes all |email| related custom or converted wallpapers.
215 void DeleteUserWallpapers(const std::string& email); 187 void DeleteUserWallpapers(const std::string& email);
216 188
217 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper 189 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper
218 // to the loaded wallpaper. 190 // to the loaded wallpaper.
219 void LoadWallpaper(const std::string& email, 191 void LoadWallpaper(const std::string& email,
220 const WallpaperInfo& info, 192 const WallpaperInfo& info,
221 bool update_wallpaper); 193 bool update_wallpaper);
222 194
223 // Generates a 128x80 thumbnail and notifies delegate when ready. 195 // Generates a 128x80 thumbnail.
224 void GenerateUserWallpaperThumbnail(const std::string& email, 196 void GenerateUserWallpaperThumbnail(const std::string& email,
225 User::WallpaperType type, 197 User::WallpaperType type,
226 base::WeakPtr<WallpaperDelegate> delegate,
227 const gfx::ImageSkia& wallpaper); 198 const gfx::ImageSkia& wallpaper);
228 199
229 // Gets |email|'s custom wallpaper in specified |resolution|. Falls back on 200 // Gets |email|'s custom wallpaper in specified |resolution|. Falls back on
230 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper 201 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper
231 // to the loaded wallpaper. Must run on FILE thread. 202 // to the loaded wallpaper. Must run on FILE thread.
232 void GetCustomWallpaperInternal(const std::string& email, 203 void GetCustomWallpaperInternal(const std::string& email,
233 const WallpaperInfo& info, 204 const WallpaperInfo& info,
234 ash::WallpaperResolution resolution, 205 ash::WallpaperResolution resolution,
235 bool update_wallpaper); 206 bool update_wallpaper);
236 207
237 // Gets wallpaper information of |email| from Local State or memory. Returns 208 // Gets wallpaper information of |email| from Local State or memory. Returns
238 // false if wallpaper information is not found. 209 // false if wallpaper information is not found.
239 bool GetUserWallpaperInfo(const std::string& email, WallpaperInfo* info); 210 bool GetUserWallpaperInfo(const std::string& email, WallpaperInfo* info);
240 211
241 // Gets wallpaper |type|, |index| and |last_modification_date| of |email|
242 // from local state.
243 void GetUserWallpaperProperties(const std::string& email,
244 User::WallpaperType* type,
245 int* index,
246 base::Time* last_modification_date);
247
248 // Copy |email| selected built-in wallpapers (high and low resolution) in
249 // ChromeOS image binary to local files on disk. Also converts the wallpaper
250 // properties correspond to the built-in wallpapers to the new wallpaper info.
251 void MigrateBuiltInWallpaper(const std::string& email);
252
253 // Updates the custom wallpaper thumbnail in wallpaper picker UI.
254 void OnThumbnailUpdated(base::WeakPtr<WallpaperDelegate> delegate);
255
256 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. 212 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true.
257 // Otherwise, cache wallpaper to memory if not logged in. 213 // Otherwise, cache wallpaper to memory if not logged in.
258 void OnWallpaperDecoded(const std::string& email, 214 void OnWallpaperDecoded(const std::string& email,
259 ash::WallpaperLayout layout, 215 ash::WallpaperLayout layout,
260 bool update_wallpaper, 216 bool update_wallpaper,
261 const UserImage& wallpaper); 217 const UserImage& wallpaper);
262 218
263 // Saves encoded wallpaper to |path|. This callback is called after encoding 219 // Saves encoded wallpaper to |path|. This callback is called after encoding
264 // to PNG completes. 220 // to PNG completes.
265 void OnWallpaperEncoded(const FilePath& path, 221 void OnWallpaperEncoded(const FilePath& path,
266 scoped_refptr<base::RefCountedBytes> data); 222 scoped_refptr<base::RefCountedBytes> data);
267 223
268 // Generates thumbnail of custom wallpaper on FILE thread. If |persistent| is 224 // Generates thumbnail of custom wallpaper on FILE thread. If |persistent| is
269 // true, saves original custom image and resized images to disk. 225 // true, saves original custom image and resized images to disk.
270 void ProcessCustomWallpaper(const std::string& email, 226 void ProcessCustomWallpaper(const std::string& email,
271 bool persistent, 227 bool persistent,
272 const WallpaperInfo& info, 228 const WallpaperInfo& info,
273 base::WeakPtr<WallpaperDelegate> delegate,
274 scoped_ptr<gfx::ImageSkia> image, 229 scoped_ptr<gfx::ImageSkia> image,
275 const UserImage::RawImage& raw_image); 230 const UserImage::RawImage& raw_image);
276 231
277 // Record data for User Metrics Analysis. 232 // Record data for User Metrics Analysis.
278 void RecordUma(User::WallpaperType type, int index); 233 void RecordUma(User::WallpaperType type, int index);
279 234
280 // Saves original custom wallpaper to |path| (absolute path) on filesystem 235 // Saves original custom wallpaper to |path| (absolute path) on filesystem
281 // and starts resizing operation of the custom wallpaper if necessary. 236 // and starts resizing operation of the custom wallpaper if necessary.
282 void SaveCustomWallpaper(const std::string& email, 237 void SaveCustomWallpaper(const std::string& email,
283 const FilePath& path, 238 const FilePath& path,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 const WallpaperInfo& info, 271 const WallpaperInfo& info,
317 bool update_wallpaper, 272 bool update_wallpaper,
318 const FilePath& wallpaper_path); 273 const FilePath& wallpaper_path);
319 274
320 // Loads user wallpaper from its file. 275 // Loads user wallpaper from its file.
321 scoped_refptr<UserImageLoader> wallpaper_loader_; 276 scoped_refptr<UserImageLoader> wallpaper_loader_;
322 277
323 // The file path of current loaded/loading custom/online wallpaper. 278 // The file path of current loaded/loading custom/online wallpaper.
324 FilePath current_wallpaper_path_; 279 FilePath current_wallpaper_path_;
325 280
326 // Logged-in user wallpaper type.
327 User::WallpaperType current_user_wallpaper_type_;
328
329 // Logged-in user wallpaper index.
330 int current_user_wallpaper_index_;
331
332 // Logged-in user wallpaper information. 281 // Logged-in user wallpaper information.
333 WallpaperInfo current_user_wallpaper_info_; 282 WallpaperInfo current_user_wallpaper_info_;
334 283
335 // Caches wallpapers of users. Accessed only on UI thread. 284 // Caches wallpapers of users. Accessed only on UI thread.
336 CustomWallpaperMap wallpaper_cache_; 285 CustomWallpaperMap wallpaper_cache_;
337 286
338 CustomWallpaperMap custom_wallpaper_thumbnail_cache_; 287 CustomWallpaperMap custom_wallpaper_thumbnail_cache_;
339 288
340 // The last selected user on user pod row. 289 // The last selected user on user pod row.
341 std::string last_selected_user_; 290 std::string last_selected_user_;
342 291
343 bool should_cache_wallpaper_; 292 bool should_cache_wallpaper_;
344 293
345 base::WeakPtrFactory<WallpaperManager> weak_factory_; 294 base::WeakPtrFactory<WallpaperManager> weak_factory_;
346 295
347 content::NotificationRegistrar registrar_; 296 content::NotificationRegistrar registrar_;
348 297
349 base::OneShotTimer<WallpaperManager> timer_; 298 base::OneShotTimer<WallpaperManager> timer_;
350 299
351 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 300 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
352 }; 301 };
353 302
354 } // namespace chromeos 303 } // namespace chromeos
355 304
356 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 305 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698