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