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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/values.h" | |
16 #include "chrome/browser/api/sync/profile_sync_service_observer.h" | 15 #include "chrome/browser/api/sync/profile_sync_service_observer.h" |
17 #include "chrome/browser/chromeos/login/user.h" | 16 #include "chrome/browser/chromeos/login/user.h" |
18 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" | 17 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" |
19 #include "chrome/browser/chromeos/login/user_manager.h" | 18 #include "chrome/browser/chromeos/login/user_manager.h" |
20 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 19 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
21 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
22 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 20 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
23 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
24 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
25 | 23 |
26 class FilePath; | 24 class FilePath; |
27 class PrefService; | 25 class PrefService; |
28 class ProfileSyncService; | 26 class ProfileSyncService; |
29 | 27 |
30 namespace chromeos { | 28 namespace chromeos { |
31 | 29 |
32 class RemoveUserDelegate; | 30 class RemoveUserDelegate; |
33 | 31 |
34 // Implementation of the UserManager. | 32 // Implementation of the UserManager. |
35 class UserManagerImpl : public UserManager, | 33 class UserManagerImpl : public UserManager, |
36 public ProfileSyncServiceObserver, | 34 public ProfileSyncServiceObserver, |
37 public content::NotificationObserver { | 35 public content::NotificationObserver { |
38 public: | 36 public: |
39 virtual ~UserManagerImpl(); | 37 virtual ~UserManagerImpl(); |
40 | 38 |
41 // UserManager implementation: | 39 // UserManager implementation: |
42 virtual void Shutdown() OVERRIDE; | |
43 virtual UserImageManager* GetUserImageManager() OVERRIDE; | 40 virtual UserImageManager* GetUserImageManager() OVERRIDE; |
44 virtual const UserList& GetUsers() const OVERRIDE; | 41 virtual const UserList& GetUsers() const OVERRIDE; |
45 virtual void UserLoggedIn(const std::string& email, | 42 virtual void UserLoggedIn(const std::string& email, |
46 bool browser_restart) OVERRIDE; | 43 bool browser_restart) OVERRIDE; |
47 virtual void RetailModeUserLoggedIn() OVERRIDE; | 44 virtual void RetailModeUserLoggedIn() OVERRIDE; |
48 virtual void GuestUserLoggedIn() OVERRIDE; | 45 virtual void GuestUserLoggedIn() OVERRIDE; |
49 virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE; | 46 virtual void EphemeralUserLoggedIn(const std::string& email) OVERRIDE; |
50 virtual void SessionStarted() OVERRIDE; | 47 virtual void SessionStarted() OVERRIDE; |
51 virtual void RemoveUser(const std::string& email, | 48 virtual void RemoveUser(const std::string& email, |
52 RemoveUserDelegate* delegate) OVERRIDE; | 49 RemoveUserDelegate* delegate) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
64 const std::string& username) const OVERRIDE; | 61 const std::string& username) const OVERRIDE; |
65 virtual void SaveUserDisplayEmail(const std::string& username, | 62 virtual void SaveUserDisplayEmail(const std::string& username, |
66 const std::string& display_email) OVERRIDE; | 63 const std::string& display_email) OVERRIDE; |
67 virtual std::string GetUserDisplayEmail( | 64 virtual std::string GetUserDisplayEmail( |
68 const std::string& username) const OVERRIDE; | 65 const std::string& username) const OVERRIDE; |
69 virtual bool IsCurrentUserOwner() const OVERRIDE; | 66 virtual bool IsCurrentUserOwner() const OVERRIDE; |
70 virtual bool IsCurrentUserNew() const OVERRIDE; | 67 virtual bool IsCurrentUserNew() const OVERRIDE; |
71 virtual bool IsCurrentUserEphemeral() const OVERRIDE; | 68 virtual bool IsCurrentUserEphemeral() const OVERRIDE; |
72 virtual bool CanCurrentUserLock() const OVERRIDE; | 69 virtual bool CanCurrentUserLock() const OVERRIDE; |
73 virtual bool IsUserLoggedIn() const OVERRIDE; | 70 virtual bool IsUserLoggedIn() const OVERRIDE; |
74 virtual bool IsLoggedInAsRegularUser() const OVERRIDE; | |
75 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; | 71 virtual bool IsLoggedInAsDemoUser() const OVERRIDE; |
76 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE; | 72 virtual bool IsLoggedInAsPublicAccount() const OVERRIDE; |
77 virtual bool IsLoggedInAsGuest() const OVERRIDE; | 73 virtual bool IsLoggedInAsGuest() const OVERRIDE; |
78 virtual bool IsLoggedInAsStub() const OVERRIDE; | 74 virtual bool IsLoggedInAsStub() const OVERRIDE; |
79 virtual bool IsSessionStarted() const OVERRIDE; | 75 virtual bool IsSessionStarted() const OVERRIDE; |
80 virtual bool IsEphemeralUser(const std::string& email) const OVERRIDE; | 76 virtual bool IsEphemeralUser(const std::string& email) const OVERRIDE; |
81 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; | 77 virtual void AddObserver(UserManager::Observer* obs) OVERRIDE; |
82 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; | 78 virtual void RemoveObserver(UserManager::Observer* obs) OVERRIDE; |
83 virtual void NotifyLocalStateChanged() OVERRIDE; | 79 virtual void NotifyLocalStateChanged() OVERRIDE; |
84 | 80 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 118 |
123 void SetCurrentUserIsOwner(bool is_current_user_owner); | 119 void SetCurrentUserIsOwner(bool is_current_user_owner); |
124 | 120 |
125 // Updates current user ownership on UI thread. | 121 // Updates current user ownership on UI thread. |
126 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status, | 122 void UpdateOwnership(DeviceSettingsService::OwnershipStatus status, |
127 bool is_owner); | 123 bool is_owner); |
128 | 124 |
129 // Triggers an asynchronous ownership check. | 125 // Triggers an asynchronous ownership check. |
130 void CheckOwnership(); | 126 void CheckOwnership(); |
131 | 127 |
132 // Removes data stored or cached outside the user's cryptohome (wallpaper, | 128 // Removes the user from the persistent list only. Also removes the user's |
133 // avatar, OAuth token status, display name, display email). | 129 // picture. |
134 void RemoveNonCryptohomeData(const std::string& email); | 130 void RemoveUserFromListInternal(const std::string& email); |
135 | 131 |
136 // Removes a regular user from the user list. Returns the user if found or | 132 // List of all known users. User instances are owned by |this| and deleted |
137 // NULL otherwise. Also removes the user from the persistent regular user | 133 // when users are removed by |RemoveUserFromListInternal|. |
138 // list. | 134 mutable UserList users_; |
139 User *RemoveRegularUserFromList(const std::string& email); | |
140 | |
141 // Replaces the list of public accounts with |public_accounts|. Ensures that | |
142 // data belonging to accounts no longer on the list is removed. Returns |true| | |
143 // if the list has changed. | |
144 // Public accounts are defined by policy. This method is called whenever an | |
145 // updated list of public accounts is received from policy. | |
146 bool UpdateAndCleanUpPublicAccounts(const base::ListValue& public_accounts); | |
147 | |
148 // Interface to the signed settings store. | |
149 CrosSettings* cros_settings_; | |
150 | |
151 // True if users have been loaded from prefs already. | |
152 bool users_loaded_; | |
153 | |
154 // List of all known users. User instances are owned by |this|. Regular users | |
155 // are removed by |RemoveUserFromList|, public accounts by | |
156 // |UpdateAndCleanUpPublicAccounts|. | |
157 UserList users_; | |
158 | 135 |
159 // The logged-in user. NULL until a user has logged in, then points to one | 136 // The logged-in user. NULL until a user has logged in, then points to one |
160 // of the User instances in |users_|, the |guest_user_| instance or an | 137 // of the User instances in |users_|, the |guest_user_| instance or an |
161 // ephemeral user instance. | 138 // ephemeral user instance. |
162 User* logged_in_user_; | 139 User* logged_in_user_; |
163 | 140 |
164 // True if SessionStarted() has been called. | 141 // True if SessionStarted() has been called. |
165 bool session_started_; | 142 bool session_started_; |
166 | 143 |
167 // Cached flag of whether currently logged-in user is owner or not. | 144 // Cached flag of whether currently logged-in user is owner or not. |
(...skipping 24 matching lines...) Expand all Loading... |
192 | 169 |
193 content::NotificationRegistrar registrar_; | 170 content::NotificationRegistrar registrar_; |
194 | 171 |
195 // Profile sync service which is observed to take actions after sync | 172 // Profile sync service which is observed to take actions after sync |
196 // errors appear. NOTE: there is no guarantee that it is the current sync | 173 // errors appear. NOTE: there is no guarantee that it is the current sync |
197 // service, so do NOT use it outside |OnStateChanged| method. | 174 // service, so do NOT use it outside |OnStateChanged| method. |
198 ProfileSyncService* observed_sync_service_; | 175 ProfileSyncService* observed_sync_service_; |
199 | 176 |
200 ObserverList<UserManager::Observer> observer_list_; | 177 ObserverList<UserManager::Observer> observer_list_; |
201 | 178 |
202 // User avatar manager. | |
203 scoped_ptr<UserImageManagerImpl> user_image_manager_; | 179 scoped_ptr<UserImageManagerImpl> user_image_manager_; |
204 | 180 |
205 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); | 181 DISALLOW_COPY_AND_ASSIGN(UserManagerImpl); |
206 }; | 182 }; |
207 | 183 |
208 } // namespace chromeos | 184 } // namespace chromeos |
209 | 185 |
210 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ | 186 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_IMPL_H_ |
OLD | NEW |