| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public: | 44 public: |
| 45 // UserManager implementation: | 45 // UserManager implementation: |
| 46 virtual ~UserManagerImpl(); | 46 virtual ~UserManagerImpl(); |
| 47 | 47 |
| 48 virtual const UserList& GetUsers() const OVERRIDE; | 48 virtual const UserList& GetUsers() const OVERRIDE; |
| 49 virtual void UserLoggedIn(const std::string& email, | 49 virtual void UserLoggedIn(const std::string& email, |
| 50 bool browser_restart) OVERRIDE; | 50 bool browser_restart) OVERRIDE; |
| 51 virtual void DemoUserLoggedIn() OVERRIDE; | 51 virtual void DemoUserLoggedIn() OVERRIDE; |
| 52 virtual void GuestUserLoggedIn() OVERRIDE; | 52 virtual void GuestUserLoggedIn() OVERRIDE; |
| 53 virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE; | 53 virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE; |
| 54 virtual void InitializeWallpaper() OVERRIDE; | |
| 55 virtual void UserSelected(const std::string& email) OVERRIDE; | |
| 56 virtual void SessionStarted() OVERRIDE; | 54 virtual void SessionStarted() OVERRIDE; |
| 57 virtual void RemoveUser(const std::string& email, | 55 virtual void RemoveUser(const std::string& email, |
| 58 RemoveUserDelegate* delegate) OVERRIDE; | 56 RemoveUserDelegate* delegate) OVERRIDE; |
| 59 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; | 57 virtual void RemoveUserFromList(const std::string& email) OVERRIDE; |
| 60 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; | 58 virtual bool IsKnownUser(const std::string& email) const OVERRIDE; |
| 61 virtual const User* FindUser(const std::string& email) const OVERRIDE; | 59 virtual const User* FindUser(const std::string& email) const OVERRIDE; |
| 62 virtual const User& GetLoggedInUser() const OVERRIDE; | 60 virtual const User& GetLoggedInUser() const OVERRIDE; |
| 63 virtual User& GetLoggedInUser() OVERRIDE; | 61 virtual User& GetLoggedInUser() OVERRIDE; |
| 64 virtual void SaveUserOAuthStatus( | 62 virtual void SaveUserOAuthStatus( |
| 65 const std::string& username, | 63 const std::string& username, |
| 66 User::OAuthTokenStatus oauth_token_status) OVERRIDE; | 64 User::OAuthTokenStatus oauth_token_status) OVERRIDE; |
| 67 virtual void SaveUserDisplayName(const std::string& username, | 65 virtual void SaveUserDisplayName(const std::string& username, |
| 68 const string16& display_name) OVERRIDE; | 66 const string16& display_name) OVERRIDE; |
| 69 virtual string16 GetUserDisplayName( | 67 virtual string16 GetUserDisplayName( |
| 70 const std::string& username) const OVERRIDE; | 68 const std::string& username) const OVERRIDE; |
| 71 virtual void SaveUserDisplayEmail(const std::string& username, | 69 virtual void SaveUserDisplayEmail(const std::string& username, |
| 72 const std::string& display_email) OVERRIDE; | 70 const std::string& display_email) OVERRIDE; |
| 73 virtual std::string GetUserDisplayEmail( | 71 virtual std::string GetUserDisplayEmail( |
| 74 const std::string& username) const OVERRIDE; | 72 const std::string& username) const OVERRIDE; |
| 75 virtual void GetLoggedInUserWallpaperProperties(User::WallpaperType* type, | |
| 76 int* index, | |
| 77 base::Time* last_modification_date) OVERRIDE; | |
| 78 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, | 73 virtual void SaveLoggedInUserWallpaperProperties(User::WallpaperType type, |
| 79 int index) OVERRIDE; | 74 int index) OVERRIDE; |
| 80 virtual void SaveUserDefaultImageIndex(const std::string& username, | 75 virtual void SaveUserDefaultImageIndex(const std::string& username, |
| 81 int image_index) OVERRIDE; | 76 int image_index) OVERRIDE; |
| 82 virtual void SaveUserImage(const std::string& username, | 77 virtual void SaveUserImage(const std::string& username, |
| 83 const UserImage& user_image) OVERRIDE; | 78 const UserImage& user_image) OVERRIDE; |
| 84 virtual void SetLoggedInUserCustomWallpaperLayout( | 79 virtual void SetLoggedInUserCustomWallpaperLayout( |
| 85 ash::WallpaperLayout layout) OVERRIDE; | 80 ash::WallpaperLayout layout) OVERRIDE; |
| 86 virtual void SaveUserImageFromFile(const std::string& username, | 81 virtual void SaveUserImageFromFile(const std::string& username, |
| 87 const FilePath& path) OVERRIDE; | 82 const FilePath& path) OVERRIDE; |
| 88 virtual void SaveUserWallpaperFromFile( | |
| 89 const std::string& username, | |
| 90 const FilePath& path, | |
| 91 ash::WallpaperLayout layout, | |
| 92 base::WeakPtr<WallpaperDelegate> delegate) OVERRIDE; | |
| 93 virtual void SaveUserImageFromProfileImage( | 83 virtual void SaveUserImageFromProfileImage( |
| 94 const std::string& username) OVERRIDE; | 84 const std::string& username) OVERRIDE; |
| 95 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; | 85 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; |
| 96 virtual bool IsCurrentUserOwner() const OVERRIDE; | 86 virtual bool IsCurrentUserOwner() const OVERRIDE; |
| 97 virtual bool IsCurrentUserNew() const OVERRIDE; | 87 virtual bool IsCurrentUserNew() const OVERRIDE; |
| 98 virtual bool IsCurrentUserEphemeral() const OVERRIDE; | 88 virtual bool IsCurrentUserEphemeral() const OVERRIDE; |
| 99 virtual bool IsUserLoggedIn() const OVERRIDE; | 89 virtual bool IsUserLoggedIn() const OVERRIDE; |
| 100 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; | 90 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; |
| 101 virtual bool IsLoggedInAsGuest() const OVERRIDE; | 91 virtual bool IsLoggedInAsGuest() const OVERRIDE; |
| 102 virtual bool IsLoggedInAsStub() const OVERRIDE; | 92 virtual bool IsLoggedInAsStub() const OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 | 103 |
| 114 // ProfileSyncServiceObserver implementation. | 104 // ProfileSyncServiceObserver implementation. |
| 115 virtual void OnStateChanged() OVERRIDE; | 105 virtual void OnStateChanged() OVERRIDE; |
| 116 | 106 |
| 117 protected: | 107 protected: |
| 118 UserManagerImpl(); | 108 UserManagerImpl(); |
| 119 | 109 |
| 120 // Returns image filepath for the given user. | 110 // Returns image filepath for the given user. |
| 121 FilePath GetImagePathForUser(const std::string& username); | 111 FilePath GetImagePathForUser(const std::string& username); |
| 122 | 112 |
| 123 // Returns wallpaper/thumbnail filepath for the given user. | |
| 124 FilePath GetWallpaperPathForUser(const std::string& username, | |
| 125 bool is_thumbnail); | |
| 126 | |
| 127 private: | 113 private: |
| 128 friend class UserManagerImplWrapper; | 114 friend class UserManagerImplWrapper; |
| 129 friend class UserManagerTest; | 115 friend class UserManagerTest; |
| 130 friend class WallpaperManager; | 116 friend class WallpaperManager; |
| 131 | 117 |
| 132 // Loads |users_| from Local State if the list has not been loaded yet. | 118 // Loads |users_| from Local State if the list has not been loaded yet. |
| 133 // Subsequent calls have no effect. Must be called on the UI thread. | 119 // Subsequent calls have no effect. Must be called on the UI thread. |
| 134 void EnsureUsersLoaded(); | 120 void EnsureUsersLoaded(); |
| 135 | 121 |
| 136 // Loads wallpaper asynchronously if the current wallpaper is not the | |
| 137 // wallpaper of logged in user. | |
| 138 void EnsureLoggedInUserWallpaperLoaded(); | |
| 139 | |
| 140 // Retrieves trusted device policies and removes users from the persistent | 122 // Retrieves trusted device policies and removes users from the persistent |
| 141 // list if ephemeral users are enabled. Schedules a callback to itself if | 123 // list if ephemeral users are enabled. Schedules a callback to itself if |
| 142 // trusted device policies are not yet available. | 124 // trusted device policies are not yet available. |
| 143 void RetrieveTrustedDevicePolicies(); | 125 void RetrieveTrustedDevicePolicies(); |
| 144 | 126 |
| 145 // Returns true if trusted device policies have successfully been retrieved | 127 // Returns true if trusted device policies have successfully been retrieved |
| 146 // and ephemeral users are enabled. | 128 // and ephemeral users are enabled. |
| 147 bool AreEphemeralUsersEnabled() const; | 129 bool AreEphemeralUsersEnabled() const; |
| 148 | 130 |
| 149 // Returns true if the user with the given email address is to be treated as | 131 // Returns true if the user with the given email address is to be treated as |
| (...skipping 10 matching lines...) Expand all Loading... |
| 160 // Reads user's oauth token status from local state preferences. | 142 // Reads user's oauth token status from local state preferences. |
| 161 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; | 143 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; |
| 162 | 144 |
| 163 void SetCurrentUserIsOwner(bool is_current_user_owner); | 145 void SetCurrentUserIsOwner(bool is_current_user_owner); |
| 164 | 146 |
| 165 // Sets one of the default images for the specified user and saves this | 147 // Sets one of the default images for the specified user and saves this |
| 166 // setting in local state. | 148 // setting in local state. |
| 167 // Does not send LOGIN_USER_IMAGE_CHANGED notification. | 149 // Does not send LOGIN_USER_IMAGE_CHANGED notification. |
| 168 void SetInitialUserImage(const std::string& username); | 150 void SetInitialUserImage(const std::string& username); |
| 169 | 151 |
| 170 // Sets one of the default wallpapers for the specified user and saves this | |
| 171 // settings in local state. | |
| 172 void SetInitialUserWallpaper(const std::string& username); | |
| 173 | |
| 174 // Migrate the old wallpaper index to a new wallpaper structure. | 152 // Migrate the old wallpaper index to a new wallpaper structure. |
| 175 // The new wallpaper structure is: | 153 // The new wallpaper structure is: |
| 176 // { WallpaperType: DAILY|CUSTOMIZED|DEFAULT, | 154 // { WallpaperType: DAILY|CUSTOMIZED|DEFAULT, |
| 177 // index: index of the default wallpapers } | 155 // index: index of the default wallpapers } |
| 178 void MigrateWallpaperData(); | 156 void MigrateWallpaperData(); |
| 179 | 157 |
| 180 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED | 158 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED |
| 181 // notification unless this is a new user and image is set for the first time. | 159 // notification unless this is a new user and image is set for the first time. |
| 182 // If |image| is empty, sets a stub image for the user. | 160 // If |image| is empty, sets a stub image for the user. |
| 183 void SetUserImage(const std::string& username, | 161 void SetUserImage(const std::string& username, |
| 184 int image_index, | 162 int image_index, |
| 185 const GURL& image_url, | 163 const GURL& image_url, |
| 186 const UserImage& user_image); | 164 const UserImage& user_image); |
| 187 | 165 |
| 188 // Get wallpaper |type|, |index| and |last_modification_date| of |username| | |
| 189 // from local state. | |
| 190 void GetUserWallpaperProperties(const std::string& username, | |
| 191 User::WallpaperType* type, | |
| 192 int* index, | |
| 193 base::Time* last_modification_date); | |
| 194 | |
| 195 // Set |username|'s wallpaper |type|, |index| and local date to local state. | |
| 196 void SaveUserWallpaperProperties(const std::string& username, | |
| 197 User::WallpaperType type, | |
| 198 int index); | |
| 199 | |
| 200 // Saves image to file, updates local state preferences to given image index | 166 // Saves image to file, updates local state preferences to given image index |
| 201 // and sends LOGIN_USER_IMAGE_CHANGED notification. | 167 // and sends LOGIN_USER_IMAGE_CHANGED notification. |
| 202 void SaveUserImageInternal(const std::string& username, | 168 void SaveUserImageInternal(const std::string& username, |
| 203 int image_index, | 169 int image_index, |
| 204 const GURL& image_url, | 170 const GURL& image_url, |
| 205 const UserImage& user_image); | 171 const UserImage& user_image); |
| 206 | 172 |
| 207 // Saves wallpaper to file, post task to generate thumbnail and updates local | |
| 208 // state preferences. | |
| 209 void SaveUserWallpaperInternal(const std::string& username, | |
| 210 ash::WallpaperLayout layout, | |
| 211 User::WallpaperType type, | |
| 212 base::WeakPtr<WallpaperDelegate> delegate, | |
| 213 const UserImage& user_image); | |
| 214 | |
| 215 // Sets desktop background to custom wallpaper and loads wallpaper thumbnail | |
| 216 // asynchronously. | |
| 217 void OnCustomWallpaperLoaded(const std::string& email, | |
| 218 ash::WallpaperLayout layout, | |
| 219 const UserImage& wallpaper); | |
| 220 | |
| 221 // Caches the loaded wallpaper for the given user. | |
| 222 void OnCustomWallpaperThumbnailLoaded(const std::string& email, | |
| 223 const UserImage& user_image); | |
| 224 | |
| 225 // Updates the custom wallpaper thumbnail in wallpaper picker UI. | |
| 226 void OnThumbnailUpdated(base::WeakPtr<WallpaperDelegate> delegate); | |
| 227 | |
| 228 // Generates a 128x80 thumbnail and saves it to local file system. | |
| 229 void GenerateUserWallpaperThumbnail(const std::string& username, | |
| 230 User::WallpaperType type, | |
| 231 base::WeakPtr<WallpaperDelegate> delegate, | |
| 232 const SkBitmap& wallpaper); | |
| 233 | |
| 234 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED | 173 // Saves image to file with specified path and sends LOGIN_USER_IMAGE_CHANGED |
| 235 // notification. Runs on FILE thread. Posts task for saving image info to | 174 // notification. Runs on FILE thread. Posts task for saving image info to |
| 236 // Local State on UI thread. | 175 // Local State on UI thread. |
| 237 void SaveImageToFile(const std::string& username, | 176 void SaveImageToFile(const std::string& username, |
| 238 const UserImage& user_image, | 177 const UserImage& user_image, |
| 239 const FilePath& image_path, | 178 const FilePath& image_path, |
| 240 int image_index, | 179 int image_index, |
| 241 const GURL& image_url); | 180 const GURL& image_url); |
| 242 | 181 |
| 243 // Saves wallpaper to file with specified path. Runs on FILE thread. Posts | |
| 244 // task for saving wallpaper info to Local State on UI thread. | |
| 245 void SaveWallpaperToFile(const std::string& username, | |
| 246 const SkBitmap& wallpaper, | |
| 247 const FilePath& wallpaper_path, | |
| 248 ash::WallpaperLayout layout, | |
| 249 User::WallpaperType type); | |
| 250 | |
| 251 // Stores path to the image and its index in local state. Runs on UI thread. | 182 // Stores path to the image and its index in local state. Runs on UI thread. |
| 252 // If |is_async| is true, it has been posted from the FILE thread after | 183 // If |is_async| is true, it has been posted from the FILE thread after |
| 253 // saving the image. | 184 // saving the image. |
| 254 void SaveImageToLocalState(const std::string& username, | 185 void SaveImageToLocalState(const std::string& username, |
| 255 const std::string& image_path, | 186 const std::string& image_path, |
| 256 int image_index, | 187 int image_index, |
| 257 const GURL& image_url, | 188 const GURL& image_url, |
| 258 bool is_async); | 189 bool is_async); |
| 259 | 190 |
| 260 // Stores layout and type preference in local state. Runs on UI thread. | 191 // Stores layout and type preference in local state. Runs on UI thread. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // Cached flag of whether the currently logged-in user existed before this | 258 // Cached flag of whether the currently logged-in user existed before this |
| 328 // login. | 259 // login. |
| 329 bool is_current_user_new_; | 260 bool is_current_user_new_; |
| 330 | 261 |
| 331 // Cached flag of whether the currently logged-in user is ephemeral. Storage | 262 // Cached flag of whether the currently logged-in user is ephemeral. Storage |
| 332 // of persistent information is avoided for such users by not adding them to | 263 // of persistent information is avoided for such users by not adding them to |
| 333 // the user list in local state, not downloading their custom user images and | 264 // the user list in local state, not downloading their custom user images and |
| 334 // mounting their cryptohomes using tmpfs. | 265 // mounting their cryptohomes using tmpfs. |
| 335 bool is_current_user_ephemeral_; | 266 bool is_current_user_ephemeral_; |
| 336 | 267 |
| 337 User::WallpaperType current_user_wallpaper_type_; | |
| 338 | |
| 339 int current_user_wallpaper_index_; | |
| 340 | |
| 341 // Cached flag indicating whether ephemeral users are enabled. Defaults to | 268 // Cached flag indicating whether ephemeral users are enabled. Defaults to |
| 342 // |false| if the value has not been read from trusted device policy yet. | 269 // |false| if the value has not been read from trusted device policy yet. |
| 343 bool ephemeral_users_enabled_; | 270 bool ephemeral_users_enabled_; |
| 344 | 271 |
| 345 // True if user pod row is showed at login screen. | 272 // True if user pod row is showed at login screen. |
| 346 bool show_users_; | 273 bool show_users_; |
| 347 | 274 |
| 348 // Cached name of device owner. Defaults to empty string if the value has not | 275 // Cached name of device owner. Defaults to empty string if the value has not |
| 349 // been read from trusted device policy yet. | 276 // been read from trusted device policy yet. |
| 350 std::string owner_email_; | 277 std::string owner_email_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 314 |
| 388 // Timer triggering DownloadProfileDataScheduled for refreshing profile data. | 315 // Timer triggering DownloadProfileDataScheduled for refreshing profile data. |
| 389 base::RepeatingTimer<UserManagerImpl> profile_download_timer_; | 316 base::RepeatingTimer<UserManagerImpl> profile_download_timer_; |
| 390 | 317 |
| 391 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 318 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
| 392 }; | 319 }; |
| 393 | 320 |
| 394 } // namespace chromeos | 321 } // namespace chromeos |
| 395 | 322 |
| 396 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 323 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| OLD | NEW |