Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 const std::string& username) const OVERRIDE; | 66 const std::string& username) const OVERRIDE; |
| 67 virtual int GetLoggedInUserWallpaperIndex() OVERRIDE; | 67 virtual int GetLoggedInUserWallpaperIndex() OVERRIDE; |
| 68 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType& type, | 68 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType& type, |
| 69 int& index) OVERRIDE; | 69 int& index) OVERRIDE; |
| 70 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, | 70 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, |
| 71 int index) OVERRIDE; | 71 int index) OVERRIDE; |
| 72 virtual void SaveUserDefaultImageIndex(const std::string& username, | 72 virtual void SaveUserDefaultImageIndex(const std::string& username, |
| 73 int image_index) OVERRIDE; | 73 int image_index) OVERRIDE; |
| 74 virtual void SaveUserImage(const std::string& username, | 74 virtual void SaveUserImage(const std::string& username, |
| 75 const SkBitmap& image) OVERRIDE; | 75 const SkBitmap& image) OVERRIDE; |
| 76 virtual void SetLoggedInUserCustomWallpaperLayout( | |
| 77 ash::WallpaperLayout layout) OVERRIDE; | |
| 76 virtual void SaveUserImageFromFile(const std::string& username, | 78 virtual void SaveUserImageFromFile(const std::string& username, |
| 77 const FilePath& path) OVERRIDE; | 79 const FilePath& path) OVERRIDE; |
| 80 virtual void SaveUserWallpaperFromFile(const std::string& username, | |
| 81 const FilePath& path, | |
| 82 ash::WallpaperLayout layout) OVERRIDE; | |
| 78 virtual void SaveUserImageFromProfileImage( | 83 virtual void SaveUserImageFromProfileImage( |
| 79 const std::string& username) OVERRIDE; | 84 const std::string& username) OVERRIDE; |
| 80 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; | 85 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; |
| 81 virtual void LoadKeyStore() OVERRIDE; | 86 virtual void LoadKeyStore() OVERRIDE; |
| 82 virtual bool IsCurrentUserOwner() const OVERRIDE; | 87 virtual bool IsCurrentUserOwner() const OVERRIDE; |
| 83 virtual bool IsCurrentUserNew() const OVERRIDE; | 88 virtual bool IsCurrentUserNew() const OVERRIDE; |
| 84 virtual bool IsCurrentUserEphemeral() const OVERRIDE; | 89 virtual bool IsCurrentUserEphemeral() const OVERRIDE; |
| 85 virtual bool IsUserLoggedIn() const OVERRIDE; | 90 virtual bool IsUserLoggedIn() const OVERRIDE; |
| 86 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; | 91 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; |
| 87 virtual bool IsLoggedInAsGuest() const OVERRIDE; | 92 virtual bool IsLoggedInAsGuest() const OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 98 | 103 |
| 99 // ProfileSyncServiceObserver implementation. | 104 // ProfileSyncServiceObserver implementation. |
| 100 virtual void OnStateChanged() OVERRIDE; | 105 virtual void OnStateChanged() OVERRIDE; |
| 101 | 106 |
| 102 protected: | 107 protected: |
| 103 UserManagerImpl(); | 108 UserManagerImpl(); |
| 104 | 109 |
| 105 // Returns image filepath for the given user. | 110 // Returns image filepath for the given user. |
| 106 FilePath GetImagePathForUser(const std::string& username); | 111 FilePath GetImagePathForUser(const std::string& username); |
| 107 | 112 |
| 113 // Returns wallpaper/thumbnail filepath for the given user. | |
| 114 FilePath GetWallpaperPathForUser(const std::string& username, | |
| 115 bool is_thumbnail); | |
| 116 | |
| 108 private: | 117 private: |
| 109 friend class UserManagerImplWrapper; | 118 friend class UserManagerImplWrapper; |
| 110 friend class UserManagerTest; | 119 friend class UserManagerTest; |
| 111 | 120 |
| 112 // Loads |users_| from Local State if the list has not been loaded yet. | 121 // Loads |users_| from Local State if the list has not been loaded yet. |
| 113 // Subsequent calls have no effect. Must be called on the UI thread. | 122 // Subsequent calls have no effect. Must be called on the UI thread. |
| 114 void EnsureUsersLoaded(); | 123 void EnsureUsersLoaded(); |
| 115 | 124 |
| 116 // Retrieves trusted device policies and removes users from the persistent | 125 // Retrieves trusted device policies and removes users from the persistent |
| 117 // list if ephemeral users are enabled. Schedules a callback to itself if | 126 // list if ephemeral users are enabled. Schedules a callback to itself if |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 129 // Returns the user with the given email address if found in the persistent | 138 // Returns the user with the given email address if found in the persistent |
| 130 // list. Returns |NULL| otherwise. | 139 // list. Returns |NULL| otherwise. |
| 131 const User* FindUserInList(const std::string& email) const; | 140 const User* FindUserInList(const std::string& email) const; |
| 132 | 141 |
| 133 // Makes stub user the current logged-in user (for test paths). | 142 // Makes stub user the current logged-in user (for test paths). |
| 134 void StubUserLoggedIn(); | 143 void StubUserLoggedIn(); |
| 135 | 144 |
| 136 // Notifies on new user session. | 145 // Notifies on new user session. |
| 137 void NotifyOnLogin(); | 146 void NotifyOnLogin(); |
| 138 | 147 |
| 148 // Notifies the custom wallpaper thumbnail has ready. | |
| 149 void NotifyThumbnailUpdated(); | |
| 150 | |
| 139 // Reads user's oauth token status from local state preferences. | 151 // Reads user's oauth token status from local state preferences. |
| 140 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; | 152 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; |
| 141 | 153 |
| 142 void SetCurrentUserIsOwner(bool is_current_user_owner); | 154 void SetCurrentUserIsOwner(bool is_current_user_owner); |
| 143 | 155 |
| 144 // Sets one of the default images for the specified user and saves this | 156 // Sets one of the default images for the specified user and saves this |
| 145 // setting in local state. | 157 // setting in local state. |
| 146 // Does not send LOGIN_USER_IMAGE_CHANGED notification. | 158 // Does not send LOGIN_USER_IMAGE_CHANGED notification. |
| 147 void SetInitialUserImage(const std::string& username); | 159 void SetInitialUserImage(const std::string& username); |
| 148 | 160 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 169 void SaveUserWallpaperProperties(const std::string& username, | 181 void SaveUserWallpaperProperties(const std::string& username, |
| 170 User::WallpaperType type, | 182 User::WallpaperType type, |
| 171 int index); | 183 int index); |
| 172 | 184 |
| 173 // Saves image to file, updates local state preferences to given image index | 185 // Saves image to file, updates local state preferences to given image index |
| 174 // and sends LOGIN_USER_IMAGE_CHANGED notification. | 186 // and sends LOGIN_USER_IMAGE_CHANGED notification. |
| 175 void SaveUserImageInternal(const std::string& username, | 187 void SaveUserImageInternal(const std::string& username, |
| 176 int image_index, | 188 int image_index, |
| 177 const SkBitmap& image); | 189 const SkBitmap& image); |
| 178 | 190 |
| 191 // Saves wallpaper to file, post task to generate thumbnail and updates local | |
| 192 // state preferences. | |
| 193 void SaveUserWallpaperInternal(const std::string& username, | |
| 194 ash::WallpaperLayout layout, | |
| 195 User::WallpaperType type, | |
| 196 const SkBitmap& image); | |
| 197 | |
| 198 // Asynchronous load custom wallpaper thumbnail. | |
|
flackr
2012/05/04 19:06:17
Loads custom wallpaper thumbnail asynchronously.
bshe
2012/05/08 22:22:18
Done.
| |
| 199 void LoadCustomWallpaperThumbnail(const std::string& email, | |
| 200 ash::WallpaperLayout layout, | |
| 201 const SkBitmap& wallpaper); | |
| 202 | |
| 203 // Cache the loaded wallpaper to the given user. | |
|
flackr
2012/05/04 19:06:17
s/Cache/Caches
s/to/for
bshe
2012/05/08 22:22:18
Done.
| |
| 204 void OnCustomWallpaperThumbnailLoaded(const std::string& email, | |
| 205 const SkBitmap& wallpaper); | |
| 206 | |
| 207 // Generate a 128x80 thumbnail and save it local file system. | |
|
flackr
2012/05/04 19:06:17
s/Generate/Generates
s/save/saves
bshe
2012/05/08 22:22:18
Done.
| |
| 208 void GenerateUserWallpaperThumbnail(const std::string& username, | |
| 209 User::WallpaperType type, | |
| 210 const SkBitmap& wallpaper); | |
| 211 | |
| 179 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED | 212 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED |
| 180 // notification. Runs on FILE thread. Posts task for saving image info to | 213 // notification. Runs on FILE thread. Posts task for saving image info to |
| 181 // Local State on UI thread. | 214 // Local State on UI thread. |
| 182 void SaveImageToFile(const std::string& username, | 215 void SaveImageToFile(const std::string& username, |
| 183 const SkBitmap& image, | 216 const SkBitmap& image, |
| 184 const FilePath& image_path, | 217 const FilePath& image_path, |
| 185 int image_index); | 218 int image_index); |
| 186 | 219 |
| 220 // Saves wallpaper to file with specified path. Runs on FILE thread. Posts | |
| 221 // task for saving wallpaper info to Local State on UI thread. | |
| 222 void SaveWallpaperToFile(const std::string& username, | |
| 223 const SkBitmap& wallpaper, | |
| 224 const FilePath& wallpaper_path, | |
| 225 ash::WallpaperLayout layout, | |
| 226 User::WallpaperType type); | |
| 227 | |
| 187 // Stores path to the image and its index in local state. Runs on UI thread. | 228 // Stores path to the image and its index in local state. Runs on UI thread. |
| 188 // If |is_async| is true, it has been posted from the FILE thread after | 229 // If |is_async| is true, it has been posted from the FILE thread after |
| 189 // saving the image. | 230 // saving the image. |
| 190 void SaveImageToLocalState(const std::string& username, | 231 void SaveImageToLocalState(const std::string& username, |
| 191 const std::string& image_path, | 232 const std::string& image_path, |
| 192 int image_index, | 233 int image_index, |
| 193 bool is_async); | 234 bool is_async); |
| 194 | 235 |
| 236 // Stores layout and type preference in local state. Runs on UI thread. | |
| 237 void SaveWallpaperToLocalState(const std::string& username, | |
| 238 const std::string& wallpaper_path, | |
| 239 ash::WallpaperLayout layout, | |
| 240 User::WallpaperType type); | |
| 241 | |
| 242 // Save |image| to the specified |image_path|. Runs on FILE thread. | |
|
flackr
2012/05/04 19:06:17
s/Save/Saves
bshe
2012/05/08 22:22:18
Done.
| |
| 243 bool SaveBitmapToFile(const SkBitmap& image, | |
| 244 const FilePath& image_path); | |
| 245 | |
| 195 // Initializes |downloaded_profile_picture_| with the picture of the logged-in | 246 // Initializes |downloaded_profile_picture_| with the picture of the logged-in |
| 196 // user. | 247 // user. |
| 197 void InitDownloadedProfileImage(); | 248 void InitDownloadedProfileImage(); |
| 198 | 249 |
| 199 // Deletes user's image file. Runs on FILE thread. | 250 // Deletes user's image file. Runs on FILE thread. |
| 200 void DeleteUserImage(const FilePath& image_path); | 251 void DeleteUserImage(const FilePath& image_path); |
| 201 | 252 |
| 202 // Updates current user ownership on UI thread. | 253 // Updates current user ownership on UI thread. |
| 203 void UpdateOwnership(bool is_owner); | 254 void UpdateOwnership(bool is_owner); |
| 204 | 255 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 bool is_current_user_new_; | 297 bool is_current_user_new_; |
| 247 | 298 |
| 248 // Cached flag of whether the currently logged-in user is ephemeral. Storage | 299 // Cached flag of whether the currently logged-in user is ephemeral. Storage |
| 249 // of persistent information is avoided for such users by not adding them to | 300 // of persistent information is avoided for such users by not adding them to |
| 250 // the user list in local state, not downloading their custom user images and | 301 // the user list in local state, not downloading their custom user images and |
| 251 // mounting their cryptohomes using tmpfs. | 302 // mounting their cryptohomes using tmpfs. |
| 252 bool is_current_user_ephemeral_; | 303 bool is_current_user_ephemeral_; |
| 253 | 304 |
| 254 User::WallpaperType current_user_wallpaper_type_; | 305 User::WallpaperType current_user_wallpaper_type_; |
| 255 | 306 |
| 256 //std::string current_user_wallpaper_path_; | |
| 257 | |
| 258 int current_user_wallpaper_index_; | 307 int current_user_wallpaper_index_; |
| 259 | 308 |
| 260 // Cache current user selected wallpaper layout in memory. | |
| 261 //ash::ImageLayout current_user_wallpaper_layout_; | |
| 262 | |
| 263 // The key store for the current user has been loaded. This flag is needed to | 309 // The key store for the current user has been loaded. This flag is needed to |
| 264 // ensure that the key store will not be loaded twice in the policy recovery | 310 // ensure that the key store will not be loaded twice in the policy recovery |
| 265 // "safe-mode". | 311 // "safe-mode". |
| 266 bool key_store_loaded_; | 312 bool key_store_loaded_; |
| 267 // Cached flag indicating whether ephemeral users are enabled. Defaults to | 313 // Cached flag indicating whether ephemeral users are enabled. Defaults to |
| 268 // |false| if the value has not been read from trusted device policy yet. | 314 // |false| if the value has not been read from trusted device policy yet. |
| 269 bool ephemeral_users_enabled_; | 315 bool ephemeral_users_enabled_; |
| 270 | 316 |
| 271 // Cached name of device owner. Defaults to empty string if the value has not | 317 // Cached name of device owner. Defaults to empty string if the value has not |
| 272 // been read from trusted device policy yet. | 318 // been read from trusted device policy yet. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 300 | 346 |
| 301 // Data URL for |downloaded_profile_image_|. | 347 // Data URL for |downloaded_profile_image_|. |
| 302 std::string downloaded_profile_image_data_url_; | 348 std::string downloaded_profile_image_data_url_; |
| 303 | 349 |
| 304 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 350 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
| 305 }; | 351 }; |
| 306 | 352 |
| 307 } // namespace chromeos | 353 } // namespace chromeos |
| 308 | 354 |
| 309 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 355 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| OLD | NEW |