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/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "chrome/browser/chromeos/login/login_utils.h" | |
16 #include "chrome/browser/chromeos/login/user.h" | 17 #include "chrome/browser/chromeos/login/user.h" |
17 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" | 18 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" |
18 #include "chrome/browser/chromeos/login/user_manager.h" | 19 #include "chrome/browser/chromeos/login/user_manager.h" |
19 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 20 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
20 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 21 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
21 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
22 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
23 #include "chrome/browser/sync/profile_sync_service_observer.h" | 24 #include "chrome/browser/sync/profile_sync_service_observer.h" |
24 #include "chromeos/dbus/session_manager_client.h" | 25 #include "chromeos/dbus/session_manager_client.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 | 28 |
28 class PrefService; | 29 class PrefService; |
29 class ProfileSyncService; | 30 class ProfileSyncService; |
30 | 31 |
31 namespace policy { | 32 namespace policy { |
32 struct DeviceLocalAccount; | 33 struct DeviceLocalAccount; |
33 } | 34 } |
34 | 35 |
35 namespace chromeos { | 36 namespace chromeos { |
36 | 37 |
37 class RemoveUserDelegate; | 38 class RemoveUserDelegate; |
38 class SessionLengthLimiter; | 39 class SessionLengthLimiter; |
39 | 40 |
40 // Implementation of the UserManager. | 41 // Implementation of the UserManager. |
41 class UserManagerImpl | 42 class UserManagerImpl |
42 : public UserManager, | 43 : public UserManager, |
44 public LoginUtils::Delegate, | |
43 public ProfileSyncServiceObserver, | 45 public ProfileSyncServiceObserver, |
44 public content::NotificationObserver, | 46 public content::NotificationObserver, |
45 public policy::DeviceLocalAccountPolicyService::Observer { | 47 public policy::DeviceLocalAccountPolicyService::Observer { |
46 public: | 48 public: |
47 virtual ~UserManagerImpl(); | 49 virtual ~UserManagerImpl(); |
48 | 50 |
49 // UserManager implementation: | 51 // UserManager implementation: |
50 virtual void Shutdown() OVERRIDE; | 52 virtual void Shutdown() OVERRIDE; |
51 virtual UserImageManager* GetUserImageManager() OVERRIDE; | 53 virtual UserImageManager* GetUserImageManager() OVERRIDE; |
52 virtual const UserList& GetUsers() const OVERRIDE; | 54 virtual const UserList& GetUsers() const OVERRIDE; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; | 142 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; |
141 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | 143 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; |
142 | 144 |
143 private: | 145 private: |
144 friend class UserManager; | 146 friend class UserManager; |
145 friend class WallpaperManager; | 147 friend class WallpaperManager; |
146 friend class UserManagerTest; | 148 friend class UserManagerTest; |
147 | 149 |
148 UserManagerImpl(); | 150 UserManagerImpl(); |
149 | 151 |
152 // LoginUtils::Delegate implementation: | |
153 // Used when restoring user sessions after crash. | |
154 virtual void OnProfilePrepared(Profile* profile) OVERRIDE; | |
155 | |
150 // Loads |users_| from Local State if the list has not been loaded yet. | 156 // Loads |users_| from Local State if the list has not been loaded yet. |
151 // Subsequent calls have no effect. Must be called on the UI thread. | 157 // Subsequent calls have no effect. Must be called on the UI thread. |
152 void EnsureUsersLoaded(); | 158 void EnsureUsersLoaded(); |
153 | 159 |
154 // Retrieves trusted device policies and removes users from the persistent | 160 // Retrieves trusted device policies and removes users from the persistent |
155 // list if ephemeral users are enabled. Schedules a callback to itself if | 161 // list if ephemeral users are enabled. Schedules a callback to itself if |
156 // trusted device policies are not yet available. | 162 // trusted device policies are not yet available. |
157 void RetrieveTrustedDevicePolicies(); | 163 void RetrieveTrustedDevicePolicies(); |
158 | 164 |
159 // Returns true if trusted device policies have successfully been retrieved | 165 // Returns true if trusted device policies have successfully been retrieved |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 void UpdateLoginState(); | 273 void UpdateLoginState(); |
268 | 274 |
269 // Insert |user| at the front of the LRU user list.. | 275 // Insert |user| at the front of the LRU user list.. |
270 void SetLRUUser(User* user); | 276 void SetLRUUser(User* user); |
271 | 277 |
272 // Callback to process RetrieveActiveSessions() request results. | 278 // Callback to process RetrieveActiveSessions() request results. |
273 void OnRestoreActiveSessions( | 279 void OnRestoreActiveSessions( |
274 const SessionManagerClient::ActiveSessionsMap& sessions, | 280 const SessionManagerClient::ActiveSessionsMap& sessions, |
275 bool success); | 281 bool success); |
276 | 282 |
283 // Called by OnRestoreActiveSessions() when there're user sessions in | |
284 // |pending_user_sessions_| that has to be restored one by one. | |
285 // Also called after first user session from that list is restored and so on. | |
286 // Process continues till |pending_user_sessions_| map is not empty. | |
287 void RestorePendingUserSessions(); | |
288 | |
277 // Interface to the signed settings store. | 289 // Interface to the signed settings store. |
278 CrosSettings* cros_settings_; | 290 CrosSettings* cros_settings_; |
279 | 291 |
280 // Interface to device-local account definitions and associated policy. | 292 // Interface to device-local account definitions and associated policy. |
281 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; | 293 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; |
282 | 294 |
283 // True if users have been loaded from prefs already. | 295 // True if users have been loaded from prefs already. |
284 bool users_loaded_; | 296 bool users_loaded_; |
285 | 297 |
286 // List of all known users. User instances are owned by |this|. Regular users | 298 // List of all known users. User instances are owned by |this|. Regular users |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 scoped_ptr<SessionLengthLimiter> session_length_limiter_; | 373 scoped_ptr<SessionLengthLimiter> session_length_limiter_; |
362 | 374 |
363 typedef std::map<std::string, UserFlow*> FlowMap; | 375 typedef std::map<std::string, UserFlow*> FlowMap; |
364 | 376 |
365 // Lazy-initialized default flow. | 377 // Lazy-initialized default flow. |
366 mutable scoped_ptr<UserFlow> default_flow_; | 378 mutable scoped_ptr<UserFlow> default_flow_; |
367 | 379 |
368 // Specific flows by user e-mail. | 380 // Specific flows by user e-mail. |
369 FlowMap specific_flows_; | 381 FlowMap specific_flows_; |
370 | 382 |
383 // User sessions that has to be restored after browser crash. | |
Dmitry Polukhin
2013/05/27 13:51:04
s/has/have/
Nikita (slow)
2013/05/27 14:22:06
Done.
| |
384 // [user_id] > [user_id_hash] | |
385 SessionManagerClient::ActiveSessionsMap pending_user_sessions_; | |
386 | |
371 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 387 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
372 }; | 388 }; |
373 | 389 |
374 } // namespace chromeos | 390 } // namespace chromeos |
375 | 391 |
376 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 392 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
OLD | NEW |