| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ | 5 #ifndef COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ |
| 6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ | 6 #define COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 virtual void DeleteUser(User* user); | 129 virtual void DeleteUser(User* user); |
| 130 | 130 |
| 131 // Returns the locale used by the application. | 131 // Returns the locale used by the application. |
| 132 virtual const std::string& GetApplicationLocale() const = 0; | 132 virtual const std::string& GetApplicationLocale() const = 0; |
| 133 | 133 |
| 134 // Returns "Local State" PrefService instance. | 134 // Returns "Local State" PrefService instance. |
| 135 virtual PrefService* GetLocalState() const = 0; | 135 virtual PrefService* GetLocalState() const = 0; |
| 136 | 136 |
| 137 // Loads |users_| from Local State if the list has not been loaded yet. | 137 // Loads |users_| from Local State if the list has not been loaded yet. |
| 138 // Subsequent calls have no effect. Must be called on the UI thread. | 138 // Subsequent calls have no effect. Must be called on the UI thread. |
| 139 void EnsureUsersLoaded(); | 139 virtual void EnsureUsersLoaded(); |
| 140 | 140 |
| 141 // Handle OAuth token |status| change for |user_id|. | 141 // Handle OAuth token |status| change for |user_id|. |
| 142 virtual void HandleUserOAuthTokenStatusChange( | 142 virtual void HandleUserOAuthTokenStatusChange( |
| 143 const std::string& user_id, | 143 const std::string& user_id, |
| 144 User::OAuthTokenStatus status) const = 0; | 144 User::OAuthTokenStatus status) const = 0; |
| 145 | 145 |
| 146 // Returns true if device is enterprise managed. | 146 // Returns true if device is enterprise managed. |
| 147 virtual bool IsEnterpriseManaged() const = 0; | 147 virtual bool IsEnterpriseManaged() const = 0; |
| 148 | 148 |
| 149 // Helper function that copies users from |users_list| to |users_vector| and | 149 // Helper function that copies users from |users_list| to |users_vector| and |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 // The primary user of the current session. It is recorded for the first | 254 // The primary user of the current session. It is recorded for the first |
| 255 // signed-in user and does not change thereafter. | 255 // signed-in user and does not change thereafter. |
| 256 User* primary_user_; | 256 User* primary_user_; |
| 257 | 257 |
| 258 // List of all known users. User instances are owned by |this|. Regular users | 258 // List of all known users. User instances are owned by |this|. Regular users |
| 259 // are removed by |RemoveUserFromList|, public accounts by | 259 // are removed by |RemoveUserFromList|, public accounts by |
| 260 // |UpdateAndCleanUpPublicAccounts|. | 260 // |UpdateAndCleanUpPublicAccounts|. |
| 261 UserList users_; | 261 UserList users_; |
| 262 | 262 |
| 263 // List of all users that are logged in current session. These point to User |
| 264 // instances in |users_|. Only one of them could be marked as active. |
| 265 UserList logged_in_users_; |
| 266 |
| 267 // A list of all users that are logged in the current session. In contrast to |
| 268 // |logged_in_users|, the order of this list is least recently used so that |
| 269 // the active user should always be the first one in the list. |
| 270 UserList lru_logged_in_users_; |
| 271 |
| 263 private: | 272 private: |
| 264 // Stages of loading user list from preferences. Some methods can have | 273 // Stages of loading user list from preferences. Some methods can have |
| 265 // different behavior depending on stage. | 274 // different behavior depending on stage. |
| 266 enum UserLoadStage { STAGE_NOT_LOADED = 0, STAGE_LOADING, STAGE_LOADED }; | 275 enum UserLoadStage { STAGE_NOT_LOADED = 0, STAGE_LOADING, STAGE_LOADED }; |
| 267 | 276 |
| 268 // Returns a list of users who have logged into this device previously. | 277 // Returns a list of users who have logged into this device previously. |
| 269 // Same as GetUsers but used if you need to modify User from that list. | 278 // Same as GetUsers but used if you need to modify User from that list. |
| 270 UserList& GetUsersAndModify(); | 279 UserList& GetUsersAndModify(); |
| 271 | 280 |
| 272 // Returns the user with the given email address if found in the persistent | 281 // Returns the user with the given email address if found in the persistent |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 virtual void UpdateUserAccountLocale(const std::string& user_id, | 318 virtual void UpdateUserAccountLocale(const std::string& user_id, |
| 310 const std::string& locale); | 319 const std::string& locale); |
| 311 | 320 |
| 312 // Updates user account after locale was resolved. | 321 // Updates user account after locale was resolved. |
| 313 void DoUpdateAccountLocale(const std::string& user_id, | 322 void DoUpdateAccountLocale(const std::string& user_id, |
| 314 scoped_ptr<std::string> resolved_locale); | 323 scoped_ptr<std::string> resolved_locale); |
| 315 | 324 |
| 316 // Indicates stage of loading user from prefs. | 325 // Indicates stage of loading user from prefs. |
| 317 UserLoadStage user_loading_stage_; | 326 UserLoadStage user_loading_stage_; |
| 318 | 327 |
| 319 // List of all users that are logged in current session. These point to User | |
| 320 // instances in |users_|. Only one of them could be marked as active. | |
| 321 UserList logged_in_users_; | |
| 322 | |
| 323 // A list of all users that are logged in the current session. In contrast to | |
| 324 // |logged_in_users|, the order of this list is least recently used so that | |
| 325 // the active user should always be the first one in the list. | |
| 326 UserList lru_logged_in_users_; | |
| 327 | |
| 328 // True if SessionStarted() has been called. | 328 // True if SessionStarted() has been called. |
| 329 bool session_started_; | 329 bool session_started_; |
| 330 | 330 |
| 331 // Cached flag of whether currently logged-in user is owner or not. | 331 // Cached flag of whether currently logged-in user is owner or not. |
| 332 // May be accessed on different threads, requires locking. | 332 // May be accessed on different threads, requires locking. |
| 333 bool is_current_user_owner_; | 333 bool is_current_user_owner_; |
| 334 mutable base::Lock is_current_user_owner_lock_; | 334 mutable base::Lock is_current_user_owner_lock_; |
| 335 | 335 |
| 336 // Cached flag of whether the currently logged-in user existed before this | 336 // Cached flag of whether the currently logged-in user existed before this |
| 337 // login. | 337 // login. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 379 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
| 380 | 380 |
| 381 base::WeakPtrFactory<UserManagerBase> weak_factory_; | 381 base::WeakPtrFactory<UserManagerBase> weak_factory_; |
| 382 | 382 |
| 383 DISALLOW_COPY_AND_ASSIGN(UserManagerBase); | 383 DISALLOW_COPY_AND_ASSIGN(UserManagerBase); |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 } // namespace user_manager | 386 } // namespace user_manager |
| 387 | 387 |
| 388 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ | 388 #endif // COMPONENTS_USER_MANAGER_USER_MANAGER_BASE_H_ |
| OLD | NEW |