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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class SkBitmap; | 26 class SkBitmap; |
27 class FilePath; | 27 class FilePath; |
28 class PrefService; | 28 class PrefService; |
29 class ProfileDownloader; | 29 class ProfileDownloader; |
30 class ProfileSyncService; | 30 class ProfileSyncService; |
31 | 31 |
32 namespace chromeos { | 32 namespace chromeos { |
33 | 33 |
34 class RemoveUserDelegate; | 34 class RemoveUserDelegate; |
| 35 class UserImage; |
35 | 36 |
36 // Implementation of the UserManager. | 37 // Implementation of the UserManager. |
37 class UserManagerImpl : public UserManager, | 38 class UserManagerImpl : public UserManager, |
38 public ProfileDownloaderDelegate, | 39 public ProfileDownloaderDelegate, |
39 public ProfileSyncServiceObserver, | 40 public ProfileSyncServiceObserver, |
40 public content::NotificationObserver { | 41 public content::NotificationObserver { |
41 public: | 42 public: |
42 // UserManager implementation: | 43 // UserManager implementation: |
43 virtual ~UserManagerImpl(); | 44 virtual ~UserManagerImpl(); |
44 | 45 |
(...skipping 23 matching lines...) Expand all Loading... |
68 const std::string& display_email) OVERRIDE; | 69 const std::string& display_email) OVERRIDE; |
69 virtual std::string GetUserDisplayEmail( | 70 virtual std::string GetUserDisplayEmail( |
70 const std::string& username) const OVERRIDE; | 71 const std::string& username) const OVERRIDE; |
71 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type, | 72 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type, |
72 int* index) OVERRIDE; | 73 int* index) OVERRIDE; |
73 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, | 74 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, |
74 int index) OVERRIDE; | 75 int index) OVERRIDE; |
75 virtual void SaveUserDefaultImageIndex(const std::string& username, | 76 virtual void SaveUserDefaultImageIndex(const std::string& username, |
76 int image_index) OVERRIDE; | 77 int image_index) OVERRIDE; |
77 virtual void SaveUserImage(const std::string& username, | 78 virtual void SaveUserImage(const std::string& username, |
78 const SkBitmap& image) OVERRIDE; | 79 const UserImage& user_image) OVERRIDE; |
79 virtual void SetLoggedInUserCustomWallpaperLayout( | 80 virtual void SetLoggedInUserCustomWallpaperLayout( |
80 ash::WallpaperLayout layout) OVERRIDE; | 81 ash::WallpaperLayout layout) OVERRIDE; |
81 virtual void SaveUserImageFromFile(const std::string& username, | 82 virtual void SaveUserImageFromFile(const std::string& username, |
82 const FilePath& path) OVERRIDE; | 83 const FilePath& path) OVERRIDE; |
83 virtual void SaveUserWallpaperFromFile(const std::string& username, | 84 virtual void SaveUserWallpaperFromFile(const std::string& username, |
84 const FilePath& path, | 85 const FilePath& path, |
85 ash::WallpaperLayout layout, | 86 ash::WallpaperLayout layout, |
86 WallpaperDelegate* delegate) OVERRIDE; | 87 WallpaperDelegate* delegate) OVERRIDE; |
87 virtual void SaveUserImageFromProfileImage( | 88 virtual void SaveUserImageFromProfileImage( |
88 const std::string& username) OVERRIDE; | 89 const std::string& username) OVERRIDE; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // The new wallpaper structure is: | 172 // The new wallpaper structure is: |
172 // { WallpaperType: RANDOM|CUSTOMIZED|DEFAULT, | 173 // { WallpaperType: RANDOM|CUSTOMIZED|DEFAULT, |
173 // index: index of the default wallpapers } | 174 // index: index of the default wallpapers } |
174 void MigrateWallpaperData(); | 175 void MigrateWallpaperData(); |
175 | 176 |
176 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED | 177 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED |
177 // notification unless this is a new user and image is set for the first time. | 178 // notification unless this is a new user and image is set for the first time. |
178 // If |image| is empty, sets a stub image for the user. | 179 // If |image| is empty, sets a stub image for the user. |
179 void SetUserImage(const std::string& username, | 180 void SetUserImage(const std::string& username, |
180 int image_index, | 181 int image_index, |
181 const SkBitmap& image); | 182 const UserImage& user_image); |
182 | 183 |
183 void GetUserWallpaperProperties(const std::string& username, | 184 void GetUserWallpaperProperties(const std::string& username, |
184 User::WallpaperType* type, | 185 User::WallpaperType* type, |
185 int* index); | 186 int* index); |
186 void SaveUserWallpaperProperties(const std::string& username, | 187 void SaveUserWallpaperProperties(const std::string& username, |
187 User::WallpaperType type, | 188 User::WallpaperType type, |
188 int index); | 189 int index); |
189 | 190 |
190 // Saves image to file, updates local state preferences to given image index | 191 // Saves image to file, updates local state preferences to given image index |
191 // and sends LOGIN_USER_IMAGE_CHANGED notification. | 192 // and sends LOGIN_USER_IMAGE_CHANGED notification. |
192 void SaveUserImageInternal(const std::string& username, | 193 void SaveUserImageInternal(const std::string& username, |
193 int image_index, | 194 int image_index, |
194 const SkBitmap& image); | 195 const UserImage& user_image); |
195 | 196 |
196 // Saves wallpaper to file, post task to generate thumbnail and updates local | 197 // Saves wallpaper to file, post task to generate thumbnail and updates local |
197 // state preferences. | 198 // state preferences. |
198 void SaveUserWallpaperInternal(const std::string& username, | 199 void SaveUserWallpaperInternal(const std::string& username, |
199 ash::WallpaperLayout layout, | 200 ash::WallpaperLayout layout, |
200 User::WallpaperType type, | 201 User::WallpaperType type, |
201 WallpaperDelegate* delegate, | 202 WallpaperDelegate* delegate, |
202 const SkBitmap& image); | 203 const UserImage& user_image); |
203 | 204 |
204 // Sets desktop background to custom wallpaper and loads wallpaper thumbnail | 205 // Sets desktop background to custom wallpaper and loads wallpaper thumbnail |
205 // asynchronously. | 206 // asynchronously. |
206 void OnCustomWallpaperLoaded(const std::string& email, | 207 void OnCustomWallpaperLoaded(const std::string& email, |
207 ash::WallpaperLayout layout, | 208 ash::WallpaperLayout layout, |
208 const SkBitmap& wallpaper); | 209 const UserImage& wallpaper); |
209 | 210 |
210 // Caches the loaded wallpaper for the given user. | 211 // Caches the loaded wallpaper for the given user. |
211 void OnCustomWallpaperThumbnailLoaded(const std::string& email, | 212 void OnCustomWallpaperThumbnailLoaded(const std::string& email, |
212 const SkBitmap& wallpaper); | 213 const UserImage& user_image); |
213 | 214 |
214 // Updates the custom wallpaper thumbnail in wallpaper picker UI. | 215 // Updates the custom wallpaper thumbnail in wallpaper picker UI. |
215 void OnThumbnailUpdated(WallpaperDelegate* delegate); | 216 void OnThumbnailUpdated(WallpaperDelegate* delegate); |
216 | 217 |
217 // Generates a 128x80 thumbnail and saves it to local file system. | 218 // Generates a 128x80 thumbnail and saves it to local file system. |
218 void GenerateUserWallpaperThumbnail(const std::string& username, | 219 void GenerateUserWallpaperThumbnail(const std::string& username, |
219 User::WallpaperType type, | 220 User::WallpaperType type, |
220 WallpaperDelegate* delegate, | 221 WallpaperDelegate* delegate, |
221 const SkBitmap& wallpaper); | 222 const SkBitmap& wallpaper); |
222 | 223 |
223 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED | 224 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED |
224 // notification. Runs on FILE thread. Posts task for saving image info to | 225 // notification. Runs on FILE thread. Posts task for saving image info to |
225 // Local State on UI thread. | 226 // Local State on UI thread. |
226 void SaveImageToFile(const std::string& username, | 227 void SaveImageToFile(const std::string& username, |
227 const SkBitmap& image, | 228 const UserImage& user_image, |
228 const FilePath& image_path, | 229 const FilePath& image_path, |
229 int image_index); | 230 int image_index); |
230 | 231 |
231 // Saves wallpaper to file with specified path. Runs on FILE thread. Posts | 232 // Saves wallpaper to file with specified path. Runs on FILE thread. Posts |
232 // task for saving wallpaper info to Local State on UI thread. | 233 // task for saving wallpaper info to Local State on UI thread. |
233 void SaveWallpaperToFile(const std::string& username, | 234 void SaveWallpaperToFile(const std::string& username, |
234 const SkBitmap& wallpaper, | 235 const SkBitmap& wallpaper, |
235 const FilePath& wallpaper_path, | 236 const FilePath& wallpaper_path, |
236 ash::WallpaperLayout layout, | 237 ash::WallpaperLayout layout, |
237 User::WallpaperType type); | 238 User::WallpaperType type); |
238 | 239 |
239 // Stores path to the image and its index in local state. Runs on UI thread. | 240 // Stores path to the image and its index in local state. Runs on UI thread. |
240 // If |is_async| is true, it has been posted from the FILE thread after | 241 // If |is_async| is true, it has been posted from the FILE thread after |
241 // saving the image. | 242 // saving the image. |
242 void SaveImageToLocalState(const std::string& username, | 243 void SaveImageToLocalState(const std::string& username, |
243 const std::string& image_path, | 244 const std::string& image_path, |
244 int image_index, | 245 int image_index, |
245 bool is_async); | 246 bool is_async); |
246 | 247 |
247 // Stores layout and type preference in local state. Runs on UI thread. | 248 // Stores layout and type preference in local state. Runs on UI thread. |
248 void SaveWallpaperToLocalState(const std::string& username, | 249 void SaveWallpaperToLocalState(const std::string& username, |
249 const std::string& wallpaper_path, | 250 const std::string& wallpaper_path, |
250 ash::WallpaperLayout layout, | 251 ash::WallpaperLayout layout, |
251 User::WallpaperType type); | 252 User::WallpaperType type); |
252 | 253 |
253 // Saves |image| to the specified |image_path|. Runs on FILE thread. | 254 // Saves |image| to the specified |image_path|. Runs on FILE thread. |
254 bool SaveBitmapToFile(const SkBitmap& image, | 255 bool SaveBitmapToFile(const UserImage& user_image, |
255 const FilePath& image_path); | 256 const FilePath& image_path); |
256 | 257 |
257 // Initializes |downloaded_profile_image_| with the picture of the logged-in | 258 // Initializes |downloaded_profile_image_| with the picture of the logged-in |
258 // user. | 259 // user. |
259 void InitDownloadedProfileImage(); | 260 void InitDownloadedProfileImage(); |
260 | 261 |
261 // Deletes user's image file. Runs on FILE thread. | 262 // Deletes user's image file. Runs on FILE thread. |
262 void DeleteUserImage(const FilePath& image_path); | 263 void DeleteUserImage(const FilePath& image_path); |
263 | 264 |
264 // Updates current user ownership on UI thread. | 265 // Updates current user ownership on UI thread. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 353 |
353 // Data URL for |downloaded_profile_image_|. | 354 // Data URL for |downloaded_profile_image_|. |
354 std::string downloaded_profile_image_data_url_; | 355 std::string downloaded_profile_image_data_url_; |
355 | 356 |
356 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 357 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
357 }; | 358 }; |
358 | 359 |
359 } // namespace chromeos | 360 } // namespace chromeos |
360 | 361 |
361 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 362 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
OLD | NEW |