| 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" |
| 11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "base/timer.h" | 18 #include "base/timer.h" |
| 19 #include "chrome/browser/chromeos/login/user.h" | 19 #include "chrome/browser/chromeos/login/user.h" |
| 20 #include "chrome/browser/chromeos/login/user_image_loader.h" | 20 #include "chrome/browser/chromeos/login/user_image_loader.h" |
| 21 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
| 22 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 22 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
| 24 #include "chrome/browser/profiles/profile_downloader_delegate.h" | 23 #include "chrome/browser/profiles/profile_downloader_delegate.h" |
| 25 #include "chrome/browser/sync/profile_sync_service_observer.h" | 24 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 26 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
| 27 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 28 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
| 29 | 28 |
| 29 class SkBitmap; |
| 30 class FilePath; | 30 class FilePath; |
| 31 class PrefService; | 31 class PrefService; |
| 32 class ProfileDownloader; | 32 class ProfileDownloader; |
| 33 class ProfileSyncService; | 33 class ProfileSyncService; |
| 34 class SkBitmap; | |
| 35 | 34 |
| 36 namespace chromeos { | 35 namespace chromeos { |
| 37 | 36 |
| 38 class RemoveUserDelegate; | 37 class RemoveUserDelegate; |
| 39 class UserImage; | 38 class UserImage; |
| 40 | 39 |
| 41 // Implementation of the UserManager. | 40 // Implementation of the UserManager. |
| 42 class UserManagerImpl : public UserManager, | 41 class UserManagerImpl : public UserManager, |
| 43 public ProfileDownloaderDelegate, | 42 public ProfileDownloaderDelegate, |
| 44 public ProfileSyncServiceObserver, | 43 public ProfileSyncServiceObserver, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; | 86 virtual void DownloadProfileImage(const std::string& reason) OVERRIDE; |
| 88 virtual bool IsCurrentUserOwner() const OVERRIDE; | 87 virtual bool IsCurrentUserOwner() const OVERRIDE; |
| 89 virtual bool IsCurrentUserNew() const OVERRIDE; | 88 virtual bool IsCurrentUserNew() const OVERRIDE; |
| 90 virtual bool IsCurrentUserEphemeral() const OVERRIDE; | 89 virtual bool IsCurrentUserEphemeral() const OVERRIDE; |
| 91 virtual bool IsUserLoggedIn() const OVERRIDE; | 90 virtual bool IsUserLoggedIn() const OVERRIDE; |
| 92 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; | 91 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; |
| 93 virtual bool IsLoggedInAsGuest() const OVERRIDE; | 92 virtual bool IsLoggedInAsGuest() const OVERRIDE; |
| 94 virtual bool IsLoggedInAsStub() const OVERRIDE; | 93 virtual bool IsLoggedInAsStub() const OVERRIDE; |
| 95 virtual bool IsSessionStarted() const OVERRIDE; | 94 virtual bool IsSessionStarted() const OVERRIDE; |
| 96 virtual bool IsEphemeralUser(const std::string& email) const OVERRIDE; | 95 virtual bool IsEphemeralUser(const std::string& email) const OVERRIDE; |
| 97 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; | 96 virtual void AddObserver(Observer* obs) OVERRIDE; |
| 98 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; | 97 virtual void RemoveObserver(Observer* obs) OVERRIDE; |
| 99 virtual void NotifyLocalStateChanged() OVERRIDE; | 98 virtual void NotifyLocalStateChanged() OVERRIDE; |
| 100 virtual const gfx::ImageSkia& DownloadedProfileImage() const OVERRIDE; | 99 virtual const gfx::ImageSkia& DownloadedProfileImage() const OVERRIDE; |
| 101 | 100 |
| 102 // content::NotificationObserver implementation. | 101 // content::NotificationObserver implementation. |
| 103 virtual void Observe(int type, | 102 virtual void Observe(int type, |
| 104 const content::NotificationSource& source, | 103 const content::NotificationSource& source, |
| 105 const content::NotificationDetails& details) OVERRIDE; | 104 const content::NotificationDetails& details) OVERRIDE; |
| 106 | 105 |
| 107 // ProfileSyncServiceObserver implementation. | 106 // ProfileSyncServiceObserver implementation. |
| 108 virtual void OnStateChanged() OVERRIDE; | 107 virtual void OnStateChanged() OVERRIDE; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // download times). | 206 // download times). |
| 208 void DownloadProfileData(const std::string& reason, bool download_image); | 207 void DownloadProfileData(const std::string& reason, bool download_image); |
| 209 | 208 |
| 210 // Scheduled call for downloading profile data. | 209 // Scheduled call for downloading profile data. |
| 211 void DownloadProfileDataScheduled(); | 210 void DownloadProfileDataScheduled(); |
| 212 | 211 |
| 213 // Deletes user's image file. Runs on FILE thread. | 212 // Deletes user's image file. Runs on FILE thread. |
| 214 void DeleteUserImage(const FilePath& image_path); | 213 void DeleteUserImage(const FilePath& image_path); |
| 215 | 214 |
| 216 // Updates current user ownership on UI thread. | 215 // Updates current user ownership on UI thread. |
| 217 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status, | 216 void UpdateOwnership(bool is_owner); |
| 218 bool is_owner); | |
| 219 | 217 |
| 220 // Triggers an asynchronous ownership check. | 218 // Checks current user's ownership on file thread. |
| 221 void CheckOwnership(); | 219 void CheckOwnership(); |
| 222 | 220 |
| 223 // ProfileDownloaderDelegate implementation. | 221 // ProfileDownloaderDelegate implementation. |
| 224 virtual bool NeedsProfilePicture() const OVERRIDE; | 222 virtual bool NeedsProfilePicture() const OVERRIDE; |
| 225 virtual int GetDesiredImageSideLength() const OVERRIDE; | 223 virtual int GetDesiredImageSideLength() const OVERRIDE; |
| 226 virtual Profile* GetBrowserProfile() OVERRIDE; | 224 virtual Profile* GetBrowserProfile() OVERRIDE; |
| 227 virtual std::string GetCachedPictureURL() const OVERRIDE; | 225 virtual std::string GetCachedPictureURL() const OVERRIDE; |
| 228 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) OVERRIDE; | 226 virtual void OnProfileDownloadSuccess(ProfileDownloader* downloader) OVERRIDE; |
| 229 virtual void OnProfileDownloadFailure(ProfileDownloader* downloader) OVERRIDE; | 227 virtual void OnProfileDownloadFailure(ProfileDownloader* downloader) OVERRIDE; |
| 230 | 228 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // been read from trusted device policy yet. | 274 // been read from trusted device policy yet. |
| 277 std::string owner_email_; | 275 std::string owner_email_; |
| 278 | 276 |
| 279 content::NotificationRegistrar registrar_; | 277 content::NotificationRegistrar registrar_; |
| 280 | 278 |
| 281 // Profile sync service which is observed to take actions after sync | 279 // Profile sync service which is observed to take actions after sync |
| 282 // errors appear. NOTE: there is no guarantee that it is the current sync | 280 // errors appear. NOTE: there is no guarantee that it is the current sync |
| 283 // service, so do NOT use it outside |OnStateChanged| method. | 281 // service, so do NOT use it outside |OnStateChanged| method. |
| 284 ProfileSyncService* observed_sync_service_; | 282 ProfileSyncService* observed_sync_service_; |
| 285 | 283 |
| 286 ObserverList<UserManager::Observer> observer_list_; | 284 ObserverList<Observer> observer_list_; |
| 287 | 285 |
| 288 // Download user profile image on login to update it if it's changed. | 286 // Download user profile image on login to update it if it's changed. |
| 289 scoped_ptr<ProfileDownloader> profile_image_downloader_; | 287 scoped_ptr<ProfileDownloader> profile_image_downloader_; |
| 290 | 288 |
| 291 // Arbitrary string passed to the last |DownloadProfileImage| call. | 289 // Arbitrary string passed to the last |DownloadProfileImage| call. |
| 292 std::string profile_image_download_reason_; | 290 std::string profile_image_download_reason_; |
| 293 | 291 |
| 294 // Time when the profile image download has started. | 292 // Time when the profile image download has started. |
| 295 base::Time profile_image_load_start_time_; | 293 base::Time profile_image_load_start_time_; |
| 296 | 294 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 314 | 312 |
| 315 // Timer triggering DownloadProfileDataScheduled for refreshing profile data. | 313 // Timer triggering DownloadProfileDataScheduled for refreshing profile data. |
| 316 base::RepeatingTimer<UserManagerImpl> profile_download_timer_; | 314 base::RepeatingTimer<UserManagerImpl> profile_download_timer_; |
| 317 | 315 |
| 318 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 316 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
| 319 }; | 317 }; |
| 320 | 318 |
| 321 } // namespace chromeos | 319 } // namespace chromeos |
| 322 | 320 |
| 323 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 321 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| OLD | NEW |