| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. | 99 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. |
| 100 void AddObservers(); | 100 void AddObservers(); |
| 101 | 101 |
| 102 // Loads wallpaper asynchronously if the current wallpaper is not the | 102 // Loads wallpaper asynchronously if the current wallpaper is not the |
| 103 // wallpaper of logged in user. | 103 // wallpaper of logged in user. |
| 104 void EnsureLoggedInUserWallpaperLoaded(); | 104 void EnsureLoggedInUserWallpaperLoaded(); |
| 105 | 105 |
| 106 // Clears ONLINE and CUSTOM wallpaper cache. | 106 // Clears ONLINE and CUSTOM wallpaper cache. |
| 107 void ClearWallpaperCache(); | 107 void ClearWallpaperCache(); |
| 108 | 108 |
| 109 // Returns custom wallpaper path. Append |sub_dir|, |email| and |file| to | 109 // Returns custom wallpaper path. Append |sub_dir|, |user_id_hash| and |file| |
| 110 // custom wallpaper directory. | 110 // to custom wallpaper directory. |
| 111 base::FilePath GetCustomWallpaperPath(const char* sub_dir, | 111 base::FilePath GetCustomWallpaperPath(const char* sub_dir, |
| 112 const std::string& email, | 112 const std::string& user_id_hash, |
| 113 const std::string& file); | 113 const std::string& file); |
| 114 | 114 |
| 115 // Gets encoded wallpaper from cache. Returns true if success. | 115 // Gets encoded wallpaper from cache. Returns true if success. |
| 116 bool GetWallpaperFromCache(const std::string& email, | 116 bool GetWallpaperFromCache(const std::string& email, |
| 117 gfx::ImageSkia* wallpaper); | 117 gfx::ImageSkia* wallpaper); |
| 118 | 118 |
| 119 // Returns filepath to save original custom wallpaper for the given user. | 119 // Returns filepath to save original custom wallpaper for the given user. |
| 120 base::FilePath GetOriginalWallpaperPathForUser(const std::string& username); | 120 base::FilePath GetOriginalWallpaperPathForUser(const std::string& username); |
| 121 | 121 |
| 122 // Gets wallpaper information of logged in user. | 122 // Gets wallpaper information of logged in user. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 148 // resized wallpaper to |path|. | 148 // resized wallpaper to |path|. |
| 149 void ResizeAndSaveWallpaper(const UserImage& wallpaper, | 149 void ResizeAndSaveWallpaper(const UserImage& wallpaper, |
| 150 const base::FilePath& path, | 150 const base::FilePath& path, |
| 151 ash::WallpaperLayout layout, | 151 ash::WallpaperLayout layout, |
| 152 int preferred_width, | 152 int preferred_width, |
| 153 int preferred_height); | 153 int preferred_height); |
| 154 | 154 |
| 155 // Saves custom wallpaper to file, post task to generate thumbnail and updates | 155 // Saves custom wallpaper to file, post task to generate thumbnail and updates |
| 156 // local state preferences. | 156 // local state preferences. |
| 157 void SetCustomWallpaper(const std::string& username, | 157 void SetCustomWallpaper(const std::string& username, |
| 158 const std::string& user_id_hash, |
| 158 const std::string& file, | 159 const std::string& file, |
| 159 ash::WallpaperLayout layout, | 160 ash::WallpaperLayout layout, |
| 160 User::WallpaperType type, | 161 User::WallpaperType type, |
| 161 const UserImage& wallpaper); | 162 const UserImage& wallpaper); |
| 162 | 163 |
| 163 // Sets wallpaper to default wallpaper. | 164 // Sets wallpaper to default wallpaper. |
| 164 void SetDefaultWallpaper(); | 165 void SetDefaultWallpaper(); |
| 165 | 166 |
| 166 // Sets one of the default wallpapers for the specified user and saves this | 167 // Sets one of the default wallpapers for the specified user and saves this |
| 167 // settings in local state. | 168 // settings in local state. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 213 |
| 213 // Clears all obsolete wallpaper prefs from old version wallpaper pickers. | 214 // Clears all obsolete wallpaper prefs from old version wallpaper pickers. |
| 214 void ClearObsoleteWallpaperPrefs(); | 215 void ClearObsoleteWallpaperPrefs(); |
| 215 | 216 |
| 216 // Deletes everything else except |path| in the same directory. | 217 // Deletes everything else except |path| in the same directory. |
| 217 void DeleteAllExcept(const base::FilePath& path); | 218 void DeleteAllExcept(const base::FilePath& path); |
| 218 | 219 |
| 219 // Deletes a list of wallpaper files in |file_list|. | 220 // Deletes a list of wallpaper files in |file_list|. |
| 220 void DeleteWallpaperInList(const std::vector<base::FilePath>& file_list); | 221 void DeleteWallpaperInList(const std::vector<base::FilePath>& file_list); |
| 221 | 222 |
| 222 // Deletes all |email| related custom or converted wallpapers. | 223 // Deletes all |email| related custom wallpapers and directories. |
| 223 void DeleteUserWallpapers(const std::string& email); | 224 void DeleteUserWallpapers(const std::string& email, |
| 225 const std::string& path_to_file); |
| 224 | 226 |
| 225 // Creates all new custom wallpaper directories for |email| if not exist. | 227 // Creates all new custom wallpaper directories for |user_id_hash| if not |
| 226 void EnsureCustomWallpaperDirectories(const std::string& email); | 228 // exist. |
| 229 void EnsureCustomWallpaperDirectories(const std::string& user_id_hash); |
| 227 | 230 |
| 228 // Gets the CommandLine representing the current process's command line. | 231 // Gets the CommandLine representing the current process's command line. |
| 229 CommandLine* GetComandLine(); | 232 CommandLine* GetComandLine(); |
| 230 | 233 |
| 231 // Initialize wallpaper of registered device after device policy is trusted. | 234 // Initialize wallpaper of registered device after device policy is trusted. |
| 232 // Note that before device is enrolled, it proceeds with untrusted setting. | 235 // Note that before device is enrolled, it proceeds with untrusted setting. |
| 233 void InitializeRegisteredDeviceWallpaper(); | 236 void InitializeRegisteredDeviceWallpaper(); |
| 234 | 237 |
| 235 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper | 238 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper |
| 236 // to the loaded wallpaper. | 239 // to the loaded wallpaper. |
| 237 void LoadWallpaper(const std::string& email, | 240 void LoadWallpaper(const std::string& email, |
| 238 const WallpaperInfo& info, | 241 const WallpaperInfo& info, |
| 239 bool update_wallpaper); | 242 bool update_wallpaper); |
| 240 | 243 |
| 244 // Moves custom wallpapers from |email| directory to |user_id_hash| |
| 245 // directory. |
| 246 void MoveCustomWallpapersOnWorker(const std::string& email, |
| 247 const std::string& user_id_hash); |
| 248 |
| 249 // Called when the original custom wallpaper is moved to the new place. |
| 250 // Updates the corresponding user wallpaper info. |
| 251 void MoveCustomWallpapersSuccess(const std::string& email, |
| 252 const std::string& user_id_hash); |
| 253 |
| 254 // Moves custom wallpaper to a new place. Email address was used as directory |
| 255 // name in the old system, this is not safe. New directory system uses |
| 256 // user_id_hash instead of email. This must be called after user_id_hash is |
| 257 // ready. |
| 258 void MoveLoggedInUserCustomWallpaper(); |
| 259 |
| 241 // Gets |email|'s custom wallpaper at |wallpaper_path|. Falls back on original | 260 // Gets |email|'s custom wallpaper at |wallpaper_path|. Falls back on original |
| 242 // custom wallpaper. When |update_wallpaper| is true, sets wallpaper to the | 261 // custom wallpaper. When |update_wallpaper| is true, sets wallpaper to the |
| 243 // loaded wallpaper. Must run on wallpaper sequenced worker thread. | 262 // loaded wallpaper. Must run on wallpaper sequenced worker thread. |
| 244 void GetCustomWallpaperInternal(const std::string& email, | 263 void GetCustomWallpaperInternal(const std::string& email, |
| 245 const WallpaperInfo& info, | 264 const WallpaperInfo& info, |
| 246 const base::FilePath& wallpaper_path, | 265 const base::FilePath& wallpaper_path, |
| 247 bool update_wallpaper); | 266 bool update_wallpaper); |
| 248 | 267 |
| 249 // Gets wallpaper information of |email| from Local State or memory. Returns | 268 // Gets wallpaper information of |email| from Local State or memory. Returns |
| 250 // false if wallpaper information is not found. | 269 // false if wallpaper information is not found. |
| 251 bool GetUserWallpaperInfo(const std::string& email, WallpaperInfo* info); | 270 bool GetUserWallpaperInfo(const std::string& email, WallpaperInfo* info); |
| 252 | 271 |
| 253 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. | 272 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. |
| 254 // Otherwise, cache wallpaper to memory if not logged in. | 273 // Otherwise, cache wallpaper to memory if not logged in. |
| 255 void OnWallpaperDecoded(const std::string& email, | 274 void OnWallpaperDecoded(const std::string& email, |
| 256 ash::WallpaperLayout layout, | 275 ash::WallpaperLayout layout, |
| 257 bool update_wallpaper, | 276 bool update_wallpaper, |
| 258 const UserImage& wallpaper); | 277 const UserImage& wallpaper); |
| 259 | 278 |
| 260 // Generates thumbnail of custom wallpaper on wallpaper sequenced worker | 279 // Generates thumbnail of custom wallpaper on wallpaper sequenced worker |
| 261 // thread. If |persistent| is true, saves original custom image and resized | 280 // thread. If |persistent| is true, saves original custom image and resized |
| 262 // images to disk. | 281 // images to disk. |
| 263 void ProcessCustomWallpaper(const std::string& email, | 282 void ProcessCustomWallpaper(const std::string& user_id_hash, |
| 264 bool persistent, | 283 bool persistent, |
| 265 const WallpaperInfo& info, | 284 const WallpaperInfo& info, |
| 266 scoped_ptr<gfx::ImageSkia> image, | 285 scoped_ptr<gfx::ImageSkia> image, |
| 267 const UserImage::RawImage& raw_image); | 286 const UserImage::RawImage& raw_image); |
| 268 | 287 |
| 269 // Record data for User Metrics Analysis. | 288 // Record data for User Metrics Analysis. |
| 270 void RecordUma(User::WallpaperType type, int index); | 289 void RecordUma(User::WallpaperType type, int index); |
| 271 | 290 |
| 272 // Saves original custom wallpaper to |path| (absolute path) on filesystem | 291 // Saves original custom wallpaper to |path| (absolute path) on filesystem |
| 273 // and starts resizing operation of the custom wallpaper if necessary. | 292 // and starts resizing operation of the custom wallpaper if necessary. |
| 274 void SaveCustomWallpaper(const std::string& email, | 293 void SaveCustomWallpaper(const std::string& user_id_hash, |
| 275 const base::FilePath& path, | 294 const base::FilePath& path, |
| 276 ash::WallpaperLayout layout, | 295 ash::WallpaperLayout layout, |
| 277 const UserImage& wallpaper); | 296 const UserImage& wallpaper); |
| 278 | 297 |
| 279 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. | 298 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. |
| 280 void SaveWallpaperInternal(const base::FilePath& path, const char* data, | 299 void SaveWallpaperInternal(const base::FilePath& path, const char* data, |
| 281 int size); | 300 int size); |
| 282 | 301 |
| 283 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the | 302 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the |
| 284 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. | 303 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 341 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
| 323 | 342 |
| 324 content::NotificationRegistrar registrar_; | 343 content::NotificationRegistrar registrar_; |
| 325 | 344 |
| 326 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 345 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
| 327 }; | 346 }; |
| 328 | 347 |
| 329 } // namespace chromeos | 348 } // namespace chromeos |
| 330 | 349 |
| 331 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 350 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
| OLD | NEW |