| OLD | NEW |
| 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_USER_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const std::string& username) const OVERRIDE; | 67 const std::string& username) const OVERRIDE; |
| 68 virtual int GetLoggedInUserWallpaperIndex() OVERRIDE; | 68 virtual int GetLoggedInUserWallpaperIndex() OVERRIDE; |
| 69 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type, | 69 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type, |
| 70 int* index) OVERRIDE; | 70 int* index) OVERRIDE; |
| 71 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, | 71 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, |
| 72 int index) OVERRIDE; | 72 int index) OVERRIDE; |
| 73 virtual void SaveUserDefaultImageIndex(const std::string& username, | 73 virtual void SaveUserDefaultImageIndex(const std::string& username, |
| 74 int image_index) OVERRIDE; | 74 int image_index) OVERRIDE; |
| 75 virtual void SaveUserImage(const std::string& username, | 75 virtual void SaveUserImage(const std::string& username, |
| 76 const SkBitmap& image) OVERRIDE; | 76 const SkBitmap& image) OVERRIDE; |
| 77 virtual void SetLoggedInUserCustomWallpaperLayout( |
| 78 ash::WallpaperLayout layout) OVERRIDE; |
| 77 virtual void SaveUserImageFromFile(const std::string& username, | 79 virtual void SaveUserImageFromFile(const std::string& username, |
| 78 const FilePath& path) OVERRIDE; | 80 const FilePath& path) OVERRIDE; |
| 81 virtual void SaveUserWallpaperFromFile(const std::string& username, |
| 82 const FilePath& path, |
| 83 ash::WallpaperLayout layout, |
| 84 WallpaperDelegate* delegate) OVERRIDE; |
| 79 virtual void SaveUserImageFromProfileImage( | 85 virtual void SaveUserImageFromProfileImage( |
| 80 const std::string& username) OVERRIDE; | 86 const std::string& username) OVERRIDE; |
| 81 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; | 87 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; |
| 82 virtual bool IsCurrentUserOwner() const OVERRIDE; | 88 virtual bool IsCurrentUserOwner() const OVERRIDE; |
| 83 virtual bool IsCurrentUserNew() const OVERRIDE; | 89 virtual bool IsCurrentUserNew() const OVERRIDE; |
| 84 virtual bool IsCurrentUserEphemeral() const OVERRIDE; | 90 virtual bool IsCurrentUserEphemeral() const OVERRIDE; |
| 85 virtual bool IsUserLoggedIn() const OVERRIDE; | 91 virtual bool IsUserLoggedIn() const OVERRIDE; |
| 86 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; | 92 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; |
| 87 virtual bool IsLoggedInAsGuest() const OVERRIDE; | 93 virtual bool IsLoggedInAsGuest() const OVERRIDE; |
| 88 virtual bool IsLoggedInAsStub() const OVERRIDE; | 94 virtual bool IsLoggedInAsStub() const OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 | 105 |
| 100 // ProfileSyncServiceObserver implementation. | 106 // ProfileSyncServiceObserver implementation. |
| 101 virtual void OnStateChanged() OVERRIDE; | 107 virtual void OnStateChanged() OVERRIDE; |
| 102 | 108 |
| 103 protected: | 109 protected: |
| 104 UserManagerImpl(); | 110 UserManagerImpl(); |
| 105 | 111 |
| 106 // Returns image filepath for the given user. | 112 // Returns image filepath for the given user. |
| 107 FilePath GetImagePathForUser(const std::string& username); | 113 FilePath GetImagePathForUser(const std::string& username); |
| 108 | 114 |
| 115 // Returns wallpaper/thumbnail filepath for the given user. |
| 116 FilePath GetWallpaperPathForUser(const std::string& username, |
| 117 bool is_thumbnail); |
| 118 |
| 109 private: | 119 private: |
| 110 friend class UserManagerImplWrapper; | 120 friend class UserManagerImplWrapper; |
| 111 friend class UserManagerTest; | 121 friend class UserManagerTest; |
| 112 | 122 |
| 113 // Loads |users_| from Local State if the list has not been loaded yet. | 123 // Loads |users_| from Local State if the list has not been loaded yet. |
| 114 // Subsequent calls have no effect. Must be called on the UI thread. | 124 // Subsequent calls have no effect. Must be called on the UI thread. |
| 115 void EnsureUsersLoaded(); | 125 void EnsureUsersLoaded(); |
| 116 | 126 |
| 117 // Retrieves trusted device policies and removes users from the persistent | 127 // Retrieves trusted device policies and removes users from the persistent |
| 118 // list if ephemeral users are enabled. Schedules a callback to itself if | 128 // list if ephemeral users are enabled. Schedules a callback to itself if |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void SaveUserWallpaperProperties(const std::string& username, | 180 void SaveUserWallpaperProperties(const std::string& username, |
| 171 User::WallpaperType type, | 181 User::WallpaperType type, |
| 172 int index); | 182 int index); |
| 173 | 183 |
| 174 // Saves image to file, updates local state preferences to given image index | 184 // Saves image to file, updates local state preferences to given image index |
| 175 // and sends LOGIN_USER_IMAGE_CHANGED notification. | 185 // and sends LOGIN_USER_IMAGE_CHANGED notification. |
| 176 void SaveUserImageInternal(const std::string& username, | 186 void SaveUserImageInternal(const std::string& username, |
| 177 int image_index, | 187 int image_index, |
| 178 const SkBitmap& image); | 188 const SkBitmap& image); |
| 179 | 189 |
| 190 // Saves wallpaper to file, post task to generate thumbnail and updates local |
| 191 // state preferences. |
| 192 void SaveUserWallpaperInternal(const std::string& username, |
| 193 ash::WallpaperLayout layout, |
| 194 User::WallpaperType type, |
| 195 WallpaperDelegate* delegate, |
| 196 const SkBitmap& image); |
| 197 |
| 198 // Loads custom wallpaper thumbnail asynchronously. |
| 199 void LoadCustomWallpaperThumbnail(const std::string& email, |
| 200 ash::WallpaperLayout layout, |
| 201 const SkBitmap& wallpaper); |
| 202 |
| 203 // Caches the loaded wallpaper for the given user. |
| 204 void OnCustomWallpaperThumbnailLoaded(const std::string& email, |
| 205 const SkBitmap& wallpaper); |
| 206 |
| 207 // Updates the custom wallpaper thumbnail in wallpaper picker UI. |
| 208 void OnThumbnailUpdated(WallpaperDelegate* delegate); |
| 209 |
| 210 // Generates a 128x80 thumbnail and saves it to local file system. |
| 211 void GenerateUserWallpaperThumbnail(const std::string& username, |
| 212 User::WallpaperType type, |
| 213 WallpaperDelegate* delegate, |
| 214 const SkBitmap& wallpaper); |
| 215 |
| 180 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED | 216 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED |
| 181 // notification. Runs on FILE thread. Posts task for saving image info to | 217 // notification. Runs on FILE thread. Posts task for saving image info to |
| 182 // Local State on UI thread. | 218 // Local State on UI thread. |
| 183 void SaveImageToFile(const std::string& username, | 219 void SaveImageToFile(const std::string& username, |
| 184 const SkBitmap& image, | 220 const SkBitmap& image, |
| 185 const FilePath& image_path, | 221 const FilePath& image_path, |
| 186 int image_index); | 222 int image_index); |
| 187 | 223 |
| 224 // Saves wallpaper to file with specified path. Runs on FILE thread. Posts |
| 225 // task for saving wallpaper info to Local State on UI thread. |
| 226 void SaveWallpaperToFile(const std::string& username, |
| 227 const SkBitmap& wallpaper, |
| 228 const FilePath& wallpaper_path, |
| 229 ash::WallpaperLayout layout, |
| 230 User::WallpaperType type); |
| 231 |
| 188 // Stores path to the image and its index in local state. Runs on UI thread. | 232 // Stores path to the image and its index in local state. Runs on UI thread. |
| 189 // If |is_async| is true, it has been posted from the FILE thread after | 233 // If |is_async| is true, it has been posted from the FILE thread after |
| 190 // saving the image. | 234 // saving the image. |
| 191 void SaveImageToLocalState(const std::string& username, | 235 void SaveImageToLocalState(const std::string& username, |
| 192 const std::string& image_path, | 236 const std::string& image_path, |
| 193 int image_index, | 237 int image_index, |
| 194 bool is_async); | 238 bool is_async); |
| 195 | 239 |
| 240 // Stores layout and type preference in local state. Runs on UI thread. |
| 241 void SaveWallpaperToLocalState(const std::string& username, |
| 242 const std::string& wallpaper_path, |
| 243 ash::WallpaperLayout layout, |
| 244 User::WallpaperType type); |
| 245 |
| 246 // Saves |image| to the specified |image_path|. Runs on FILE thread. |
| 247 bool SaveBitmapToFile(const SkBitmap& image, |
| 248 const FilePath& image_path); |
| 249 |
| 196 // Initializes |downloaded_profile_picture_| with the picture of the logged-in | 250 // Initializes |downloaded_profile_picture_| with the picture of the logged-in |
| 197 // user. | 251 // user. |
| 198 void InitDownloadedProfileImage(); | 252 void InitDownloadedProfileImage(); |
| 199 | 253 |
| 200 // Deletes user's image file. Runs on FILE thread. | 254 // Deletes user's image file. Runs on FILE thread. |
| 201 void DeleteUserImage(const FilePath& image_path); | 255 void DeleteUserImage(const FilePath& image_path); |
| 202 | 256 |
| 203 // Updates current user ownership on UI thread. | 257 // Updates current user ownership on UI thread. |
| 204 void UpdateOwnership(bool is_owner); | 258 void UpdateOwnership(bool is_owner); |
| 205 | 259 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 349 |
| 296 // Data URL for |downloaded_profile_image_|. | 350 // Data URL for |downloaded_profile_image_|. |
| 297 std::string downloaded_profile_image_data_url_; | 351 std::string downloaded_profile_image_data_url_; |
| 298 | 352 |
| 299 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 353 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
| 300 }; | 354 }; |
| 301 | 355 |
| 302 } // namespace chromeos | 356 } // namespace chromeos |
| 303 | 357 |
| 304 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 358 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| OLD | NEW |