| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 127 |
| 126 // content::NotificationObserver implementation. | 128 // content::NotificationObserver implementation. |
| 127 virtual void Observe(int type, | 129 virtual void Observe(int type, |
| 128 const content::NotificationSource& source, | 130 const content::NotificationSource& source, |
| 129 const content::NotificationDetails& details) OVERRIDE; | 131 const content::NotificationDetails& details) OVERRIDE; |
| 130 | 132 |
| 131 // ProfileSyncServiceObserver implementation. | 133 // ProfileSyncServiceObserver implementation. |
| 132 virtual void OnStateChanged() OVERRIDE; | 134 virtual void OnStateChanged() OVERRIDE; |
| 133 | 135 |
| 134 // policy::DeviceLocalAccountPolicyService::Observer implementation. | 136 // policy::DeviceLocalAccountPolicyService::Observer implementation. |
| 135 virtual void OnPolicyUpdated(const std::string& account_id) OVERRIDE; | 137 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; |
| 136 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | 138 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; |
| 137 | 139 |
| 138 private: | 140 private: |
| 139 friend class UserManager; | 141 friend class UserManager; |
| 140 friend class WallpaperManager; | 142 friend class WallpaperManager; |
| 141 friend class UserManagerTest; | 143 friend class UserManagerTest; |
| 142 | 144 |
| 143 UserManagerImpl(); | 145 UserManagerImpl(); |
| 144 | 146 |
| 145 // Loads |users_| from Local State if the list has not been loaded yet. | 147 // 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... |
| 210 | 212 |
| 211 // Removes data stored or cached outside the user's cryptohome (wallpaper, | 213 // Removes data stored or cached outside the user's cryptohome (wallpaper, |
| 212 // avatar, OAuth token status, display name, display email). | 214 // avatar, OAuth token status, display name, display email). |
| 213 void RemoveNonCryptohomeData(const std::string& email); | 215 void RemoveNonCryptohomeData(const std::string& email); |
| 214 | 216 |
| 215 // Removes a regular or locally managed user from the user list. | 217 // Removes a regular or locally managed user from the user list. |
| 216 // Returns the user if found or NULL otherwise. | 218 // Returns the user if found or NULL otherwise. |
| 217 // Also removes the user from the persistent user list. | 219 // Also removes the user from the persistent user list. |
| 218 User* RemoveRegularOrLocallyManagedUserFromList(const std::string& username); | 220 User* RemoveRegularOrLocallyManagedUserFromList(const std::string& username); |
| 219 | 221 |
| 222 // If data for a public account is marked as pending removal and the user is |
| 223 // no longer logged into that account, removes the data. |
| 224 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); |
| 225 |
| 220 // Removes data belonging to public accounts that are no longer found on the | 226 // Removes data belonging to public accounts that are no longer found on the |
| 221 // user list. If the user is currently logged into one of these accounts, the | 227 // user list. If the user is currently logged into one of these accounts, the |
| 222 // data for that account is not removed immediately but marked as pending | 228 // data for that account is not removed immediately but marked as pending |
| 223 // removal after logout. | 229 // removal after logout. |
| 224 void CleanUpPublicAccountNonCryptohomeData( | 230 void CleanUpPublicAccountNonCryptohomeData( |
| 225 const std::vector<std::string>& old_public_accounts); | 231 const std::vector<std::string>& old_public_accounts); |
| 226 | 232 |
| 227 // Replaces the list of public accounts with |public_accounts|. Ensures that | 233 // Replaces the list of public accounts with those found in |
| 228 // data belonging to accounts no longer on the list is removed. Returns |true| | 234 // |device_local_accounts|. Ensures that data belonging to accounts no longer |
| 229 // if the list has changed. | 235 // on the list is removed. Returns |true| if the list has changed. |
| 230 // Public accounts are defined by policy. This method is called whenever an | 236 // Public accounts are defined by policy. This method is called whenever an |
| 231 // updated list of public accounts is received from policy. | 237 // updated list of public accounts is received from policy. |
| 232 bool UpdateAndCleanUpPublicAccounts(const base::ListValue& public_accounts); | 238 bool UpdateAndCleanUpPublicAccounts( |
| 239 const std::vector<policy::DeviceLocalAccount>& device_local_accounts); |
| 233 | 240 |
| 234 // Updates the display name for public account |username| from policy settings | 241 // Updates the display name for public account |username| from policy settings |
| 235 // associated with that username. | 242 // associated with that username. |
| 236 void UpdatePublicAccountDisplayName(const std::string& username); | 243 void UpdatePublicAccountDisplayName(const std::string& username); |
| 237 | 244 |
| 238 // Notifies the UI about a change to the user list. | 245 // Notifies the UI about a change to the user list. |
| 239 void NotifyUserListChanged(); | 246 void NotifyUserListChanged(); |
| 240 | 247 |
| 241 // Notifies observers that merge session state had changed. | 248 // Notifies observers that merge session state had changed. |
| 242 void NotifyMergeSessionStateChanged(); | 249 void NotifyMergeSessionStateChanged(); |
| 243 | 250 |
| 244 // Notifies observers that active user_id hash has changed. | 251 // Notifies observers that active user_id hash has changed. |
| 245 void NotifyActiveUserHashChanged(const std::string& hash); | 252 void NotifyActiveUserHashChanged(const std::string& hash); |
| 246 | 253 |
| 247 // Returns true if there is non-committed user creation transaction. | 254 // Returns true if there is non-committed user creation transaction. |
| 248 bool HasFailedLocallyManagedUserCreationTransaction(); | 255 bool HasFailedLocallyManagedUserCreationTransaction(); |
| 249 | 256 |
| 250 // Attempts to clean up data that could be left from failed user creation. | 257 // Attempts to clean up data that could be left from failed user creation. |
| 251 void RollbackLocallyManagedUserCreationTransaction(); | 258 void RollbackLocallyManagedUserCreationTransaction(); |
| 252 | 259 |
| 253 // Lazily creates default user flow. | 260 // Lazily creates default user flow. |
| 254 UserFlow* GetDefaultUserFlow() const; | 261 UserFlow* GetDefaultUserFlow() const; |
| 255 | 262 |
| 256 // Update the global LoginState. | 263 // Update the global LoginState. |
| 257 void UpdateLoginState(); | 264 void UpdateLoginState(); |
| 258 | 265 |
| 259 // Gets the list of public accounts defined in device settings. | |
| 260 void ReadPublicAccounts(base::ListValue* public_accounts); | |
| 261 | |
| 262 // Interface to the signed settings store. | 266 // Interface to the signed settings store. |
| 263 CrosSettings* cros_settings_; | 267 CrosSettings* cros_settings_; |
| 264 | 268 |
| 265 // Interface to device-local account definitions and associated policy. | 269 // Interface to device-local account definitions and associated policy. |
| 266 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; | 270 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; |
| 267 | 271 |
| 268 // True if users have been loaded from prefs already. | 272 // True if users have been loaded from prefs already. |
| 269 bool users_loaded_; | 273 bool users_loaded_; |
| 270 | 274 |
| 271 // List of all known users. User instances are owned by |this|. Regular users | 275 // List of all known users. User instances are owned by |this|. Regular users |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 348 |
| 345 // Specific flows by user e-mail. | 349 // Specific flows by user e-mail. |
| 346 FlowMap specific_flows_; | 350 FlowMap specific_flows_; |
| 347 | 351 |
| 348 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 352 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
| 349 }; | 353 }; |
| 350 | 354 |
| 351 } // namespace chromeos | 355 } // namespace chromeos |
| 352 | 356 |
| 353 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 357 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
| OLD | NEW |