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