| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/singleton.h" | |
| 15 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 16 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 17 #include "base/values.h" | |
| 18 #include "chrome/browser/chromeos/login/user.h" | 16 #include "chrome/browser/chromeos/login/user.h" |
| 19 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" | 17 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" |
| 20 #include "chrome/browser/chromeos/login/user_manager.h" | 18 #include "chrome/browser/chromeos/login/user_manager.h" |
| 21 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 19 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 22 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 20 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 21 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 24 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 22 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 25 #include "chrome/browser/sync/profile_sync_service_observer.h" | 23 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 26 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| 27 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 28 | 26 |
| 29 class PrefService; | 27 class PrefService; |
| 30 class ProfileSyncService; | 28 class ProfileSyncService; |
| 31 | 29 |
| 30 namespace policy { |
| 31 class DeviceLocalAccount; |
| 32 } |
| 33 |
| 32 namespace chromeos { | 34 namespace chromeos { |
| 33 | 35 |
| 34 class RemoveUserDelegate; | 36 class RemoveUserDelegate; |
| 35 class SessionLengthLimiter; | 37 class SessionLengthLimiter; |
| 36 | 38 |
| 37 // Implementation of the UserManager. | 39 // Implementation of the UserManager. |
| 38 class UserManagerImpl | 40 class UserManagerImpl |
| 39 : public UserManager, | 41 : public UserManager, |
| 40 public ProfileSyncServiceObserver, | 42 public ProfileSyncServiceObserver, |
| 41 public content::NotificationObserver, | 43 public content::NotificationObserver, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 128 |
| 127 // content::NotificationObserver implementation. | 129 // content::NotificationObserver implementation. |
| 128 virtual void Observe(int type, | 130 virtual void Observe(int type, |
| 129 const content::NotificationSource& source, | 131 const content::NotificationSource& source, |
| 130 const content::NotificationDetails& details) OVERRIDE; | 132 const content::NotificationDetails& details) OVERRIDE; |
| 131 | 133 |
| 132 // ProfileSyncServiceObserver implementation. | 134 // ProfileSyncServiceObserver implementation. |
| 133 virtual void OnStateChanged() OVERRIDE; | 135 virtual void OnStateChanged() OVERRIDE; |
| 134 | 136 |
| 135 // policy::DeviceLocalAccountPolicyService::Observer implementation. | 137 // policy::DeviceLocalAccountPolicyService::Observer implementation. |
| 136 virtual void OnPolicyUpdated(const std::string& account_id) OVERRIDE; | 138 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; |
| 137 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | 139 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; |
| 138 | 140 |
| 139 private: | 141 private: |
| 140 friend class UserManager; | 142 friend class UserManager; |
| 141 friend class WallpaperManager; | 143 friend class WallpaperManager; |
| 142 friend class UserManagerTest; | 144 friend class UserManagerTest; |
| 143 | 145 |
| 144 UserManagerImpl(); | 146 UserManagerImpl(); |
| 145 | 147 |
| 146 // Loads |users_| from Local State if the list has not been loaded yet. | 148 // Loads |users_| from Local State if the list has not been loaded yet. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 213 |
| 212 // Removes data stored or cached outside the user's cryptohome (wallpaper, | 214 // Removes data stored or cached outside the user's cryptohome (wallpaper, |
| 213 // avatar, OAuth token status, display name, display email). | 215 // avatar, OAuth token status, display name, display email). |
| 214 void RemoveNonCryptohomeData(const std::string& email); | 216 void RemoveNonCryptohomeData(const std::string& email); |
| 215 | 217 |
| 216 // Removes a regular or locally managed user from the user list. | 218 // Removes a regular or locally managed user from the user list. |
| 217 // Returns the user if found or NULL otherwise. | 219 // Returns the user if found or NULL otherwise. |
| 218 // Also removes the user from the persistent user list. | 220 // Also removes the user from the persistent user list. |
| 219 User* RemoveRegularOrLocallyManagedUserFromList(const std::string& username); | 221 User* RemoveRegularOrLocallyManagedUserFromList(const std::string& username); |
| 220 | 222 |
| 223 // If data for a public account is marked as pending removal and the user is |
| 224 // no longer logged into that account, removes the data. |
| 225 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); |
| 226 |
| 221 // Removes data belonging to public accounts that are no longer found on the | 227 // Removes data belonging to public accounts that are no longer found on the |
| 222 // user list. If the user is currently logged into one of these accounts, the | 228 // user list. If the user is currently logged into one of these accounts, the |
| 223 // data for that account is not removed immediately but marked as pending | 229 // data for that account is not removed immediately but marked as pending |
| 224 // removal after logout. | 230 // removal after logout. |
| 225 void CleanUpPublicAccountNonCryptohomeData( | 231 void CleanUpPublicAccountNonCryptohomeData( |
| 226 const std::vector<std::string>& old_public_accounts); | 232 const std::vector<std::string>& old_public_accounts); |
| 227 | 233 |
| 228 // Replaces the list of public accounts with |public_accounts|. Ensures that | 234 // Replaces the list of public accounts with those found in |
| 229 // data belonging to accounts no longer on the list is removed. Returns |true| | 235 // |device_local_accounts|. Ensures that data belonging to accounts no longer |
| 230 // if the list has changed. | 236 // on the list is removed. Returns |true| if the list has changed. |
| 231 // Public accounts are defined by policy. This method is called whenever an | 237 // Public accounts are defined by policy. This method is called whenever an |
| 232 // updated list of public accounts is received from policy. | 238 // updated list of public accounts is received from policy. |
| 233 bool UpdateAndCleanUpPublicAccounts(const base::ListValue& public_accounts); | 239 bool UpdateAndCleanUpPublicAccounts( |
| 240 const std::vector<policy::DeviceLocalAccount>& device_local_accounts); |
| 234 | 241 |
| 235 // Updates the display name for public account |username| from policy settings | 242 // Updates the display name for public account |username| from policy settings |
| 236 // associated with that username. | 243 // associated with that username. |
| 237 void UpdatePublicAccountDisplayName(const std::string& username); | 244 void UpdatePublicAccountDisplayName(const std::string& username); |
| 238 | 245 |
| 239 // Notifies the UI about a change to the user list. | 246 // Notifies the UI about a change to the user list. |
| 240 void NotifyUserListChanged(); | 247 void NotifyUserListChanged(); |
| 241 | 248 |
| 242 // Notifies observers that merge session state had changed. | 249 // Notifies observers that merge session state had changed. |
| 243 void NotifyMergeSessionStateChanged(); | 250 void NotifyMergeSessionStateChanged(); |
| 244 | 251 |
| 245 // Notifies observers that active user_id hash has changed. | 252 // Notifies observers that active user_id hash has changed. |
| 246 void NotifyActiveUserHashChanged(const std::string& hash); | 253 void NotifyActiveUserHashChanged(const std::string& hash); |
| 247 | 254 |
| 248 // Returns true if there is non-committed user creation transaction. | 255 // Returns true if there is non-committed user creation transaction. |
| 249 bool HasFailedLocallyManagedUserCreationTransaction(); | 256 bool HasFailedLocallyManagedUserCreationTransaction(); |
| 250 | 257 |
| 251 // Attempts to clean up data that could be left from failed user creation. | 258 // Attempts to clean up data that could be left from failed user creation. |
| 252 void RollbackLocallyManagedUserCreationTransaction(); | 259 void RollbackLocallyManagedUserCreationTransaction(); |
| 253 | 260 |
| 254 // Lazily creates default user flow. | 261 // Lazily creates default user flow. |
| 255 UserFlow* GetDefaultUserFlow() const; | 262 UserFlow* GetDefaultUserFlow() const; |
| 256 | 263 |
| 257 // Update the global LoginState. | 264 // Update the global LoginState. |
| 258 void UpdateLoginState(); | 265 void UpdateLoginState(); |
| 259 | 266 |
| 260 // Gets the list of public accounts defined in device settings. | |
| 261 void ReadPublicAccounts(base::ListValue* public_accounts); | |
| 262 | |
| 263 // Insert |user| at the front of the LRU user list.. | 267 // Insert |user| at the front of the LRU user list.. |
| 264 void SetLRUUser(User* user); | 268 void SetLRUUser(User* user); |
| 265 | 269 |
| 266 // Interface to the signed settings store. | 270 // Interface to the signed settings store. |
| 267 CrosSettings* cros_settings_; | 271 CrosSettings* cros_settings_; |
| 268 | 272 |
| 269 // Interface to device-local account definitions and associated policy. | 273 // Interface to device-local account definitions and associated policy. |
| 270 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; | 274 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; |
| 271 | 275 |
| 272 // True if users have been loaded from prefs already. | 276 // True if users have been loaded from prefs already. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 360 |
| 357 // Specific flows by user e-mail. | 361 // Specific flows by user e-mail. |
| 358 FlowMap specific_flows_; | 362 FlowMap specific_flows_; |
| 359 | 363 |
| 360 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 364 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
| 361 }; | 365 }; |
| 362 | 366 |
| 363 } // namespace chromeos | 367 } // namespace chromeos |
| 364 | 368 |
| 365 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 369 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| OLD | NEW |