| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/chromeos/login/profile_image_downloader.h" | |
| 18 #include "chrome/browser/chromeos/login/user.h" | 17 #include "chrome/browser/chromeos/login/user.h" |
| 19 #include "chrome/browser/chromeos/login/user_image_loader.h" | 18 #include "chrome/browser/chromeos/login/user_image_loader.h" |
| 19 #include "chrome/browser/profiles/profile_downloader_delegate.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 | 23 |
| 24 class FilePath; | 24 class FilePath; |
| 25 class PrefService; | 25 class PrefService; |
| 26 class ProfileDownloader; |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 template<typename> struct DefaultLazyInstanceTraits; | 29 template<typename> struct DefaultLazyInstanceTraits; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace chromeos { | 32 namespace chromeos { |
| 32 | 33 |
| 33 class RemoveUserDelegate; | 34 class RemoveUserDelegate; |
| 34 | 35 |
| 35 // This class provides a mechanism for discovering users who have logged | 36 // This class provides a mechanism for discovering users who have logged |
| 36 // into this chromium os device before and updating that list. | 37 // into this chromium os device before and updating that list. |
| 37 class UserManager : public ProfileImageDownloader::Delegate, | 38 class UserManager : public ProfileDownloaderDelegate, |
| 38 public content::NotificationObserver { | 39 public content::NotificationObserver { |
| 39 public: | 40 public: |
| 40 // Returns a shared instance of a UserManager. Not thread-safe, should only be | 41 // Returns a shared instance of a UserManager. Not thread-safe, should only be |
| 41 // called from the main UI thread. | 42 // called from the main UI thread. |
| 42 static UserManager* Get(); | 43 static UserManager* Get(); |
| 43 | 44 |
| 44 // Registers user manager preferences. | 45 // Registers user manager preferences. |
| 45 static void RegisterPrefs(PrefService* local_state); | 46 static void RegisterPrefs(PrefService* local_state); |
| 46 | 47 |
| 47 // Returns a list of the users who have logged into this device previously. | 48 // Returns a list of the users who have logged into this device previously. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 207 |
| 207 // Deletes user's image file. Runs on FILE thread. | 208 // Deletes user's image file. Runs on FILE thread. |
| 208 void DeleteUserImage(const FilePath& image_path); | 209 void DeleteUserImage(const FilePath& image_path); |
| 209 | 210 |
| 210 // Updates current user ownership on UI thread. | 211 // Updates current user ownership on UI thread. |
| 211 void UpdateOwnership(bool is_owner); | 212 void UpdateOwnership(bool is_owner); |
| 212 | 213 |
| 213 // Checks current user's ownership on file thread. | 214 // Checks current user's ownership on file thread. |
| 214 void CheckOwnership(); | 215 void CheckOwnership(); |
| 215 | 216 |
| 216 // ProfileImageDownloader::Delegate implementation. | 217 // ProfileDownloaderDelegate implementation. |
| 217 virtual void OnDownloadSuccess(const SkBitmap& image) OVERRIDE; | 218 virtual int GetDesiredImageSize() OVERRIDE; |
| 218 virtual void OnDownloadFailure() OVERRIDE; | 219 virtual Profile* GetBrowserProfile() OVERRIDE; |
| 219 virtual void OnDownloadDefaultImage() OVERRIDE; | 220 virtual void OnDownloadComplete(ProfileDownloader* downloader, |
| 221 bool success) OVERRIDE; |
| 220 | 222 |
| 221 // Creates a new User instance. | 223 // Creates a new User instance. |
| 222 User* CreateUser(const std::string& email) const; | 224 User* CreateUser(const std::string& email) const; |
| 223 | 225 |
| 224 // Loads user image from its file. | 226 // Loads user image from its file. |
| 225 scoped_refptr<UserImageLoader> image_loader_; | 227 scoped_refptr<UserImageLoader> image_loader_; |
| 226 | 228 |
| 227 // List of all known users. User instances are owned by |this| and deleted | 229 // List of all known users. User instances are owned by |this| and deleted |
| 228 // when a user is removed with |RemoveUser|. | 230 // when a user is removed with |RemoveUser|. |
| 229 mutable UserList users_; | 231 mutable UserList users_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 258 // Cached flag of whether any user is logged in at the moment. | 260 // Cached flag of whether any user is logged in at the moment. |
| 259 bool user_is_logged_in_; | 261 bool user_is_logged_in_; |
| 260 | 262 |
| 261 content::NotificationRegistrar registrar_; | 263 content::NotificationRegistrar registrar_; |
| 262 | 264 |
| 263 friend struct base::DefaultLazyInstanceTraits<UserManager>; | 265 friend struct base::DefaultLazyInstanceTraits<UserManager>; |
| 264 | 266 |
| 265 ObserverList<Observer> observer_list_; | 267 ObserverList<Observer> observer_list_; |
| 266 | 268 |
| 267 // Download user profile image on login to update it if it's changed. | 269 // Download user profile image on login to update it if it's changed. |
| 268 scoped_ptr<ProfileImageDownloader> profile_image_downloader_; | 270 scoped_ptr<ProfileDownloader> profile_image_downloader_; |
| 269 | 271 |
| 270 // Time when the profile image download has started. | 272 // Time when the profile image download has started. |
| 271 base::Time profile_image_load_start_time_; | 273 base::Time profile_image_load_start_time_; |
| 272 | 274 |
| 273 // True if the last user image required async save operation (which may not | 275 // True if the last user image required async save operation (which may not |
| 274 // have been completed yet). This flag is used to avoid races when user image | 276 // have been completed yet). This flag is used to avoid races when user image |
| 275 // is first set with |SaveUserImage| and then with |SaveUserImagePath|. | 277 // is first set with |SaveUserImage| and then with |SaveUserImagePath|. |
| 276 bool last_image_set_async_; | 278 bool last_image_set_async_; |
| 277 | 279 |
| 278 // Result of the last successful profile image download, if any. | 280 // Result of the last successful profile image download, if any. |
| 279 SkBitmap downloaded_profile_image_; | 281 SkBitmap downloaded_profile_image_; |
| 280 | 282 |
| 281 // Data URL for |downloaded_profile_image_|. | 283 // Data URL for |downloaded_profile_image_|. |
| 282 std::string downloaded_profile_image_data_url_; | 284 std::string downloaded_profile_image_data_url_; |
| 283 | 285 |
| 284 DISALLOW_COPY_AND_ASSIGN(UserManager); | 286 DISALLOW_COPY_AND_ASSIGN(UserManager); |
| 285 }; | 287 }; |
| 286 | 288 |
| 287 } // namespace chromeos | 289 } // namespace chromeos |
| 288 | 290 |
| 289 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 291 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| OLD | NEW |