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