Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/chromeos/login/users/chrome_user_manager_impl.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // Creates ChromeUserManagerImpl instance. 62 // Creates ChromeUserManagerImpl instance.
63 static scoped_ptr<ChromeUserManager> CreateChromeUserManager(); 63 static scoped_ptr<ChromeUserManager> CreateChromeUserManager();
64 64
65 // Registers user manager preferences. 65 // Registers user manager preferences.
66 static void RegisterPrefs(PrefRegistrySimple* registry); 66 static void RegisterPrefs(PrefRegistrySimple* registry);
67 67
68 // UserManagerInterface implementation: 68 // UserManagerInterface implementation:
69 BootstrapManager* GetBootstrapManager() override; 69 BootstrapManager* GetBootstrapManager() override;
70 MultiProfileUserController* GetMultiProfileUserController() override; 70 MultiProfileUserController* GetMultiProfileUserController() override;
71 UserImageManager* GetUserImageManager(const std::string& user_id) override; 71 UserImageManager* GetUserImageManager(const user_manager::UserID& user_id) ove rride;
72 SupervisedUserManager* GetSupervisedUserManager() override; 72 SupervisedUserManager* GetSupervisedUserManager() override;
73 UserFlow* GetCurrentUserFlow() const override; 73 UserFlow* GetCurrentUserFlow() const override;
74 UserFlow* GetUserFlow(const std::string& user_id) const override; 74 UserFlow* GetUserFlow(const user_manager::UserID& user_id) const override;
75 void SetUserFlow(const std::string& user_id, UserFlow* flow) override; 75 void SetUserFlow(const user_manager::UserID& user_id, UserFlow* flow) override ;
76 void ResetUserFlow(const std::string& user_id) override; 76 void ResetUserFlow(const user_manager::UserID& user_id) override;
77 77
78 // UserManager implementation: 78 // UserManager implementation:
79 void Shutdown() override; 79 void Shutdown() override;
80 user_manager::UserList GetUsersAllowedForMultiProfile() const override; 80 user_manager::UserList GetUsersAllowedForMultiProfile() const override;
81 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation() 81 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation()
82 const override; 82 const override;
83 user_manager::UserList GetUnlockUsers() const override; 83 user_manager::UserList GetUnlockUsers() const override;
84 void SessionStarted() override; 84 void SessionStarted() override;
85 void SaveUserOAuthStatus( 85 void SaveUserOAuthStatus(
86 const std::string& user_id, 86 const user_manager::UserID& user_id,
87 user_manager::User::OAuthTokenStatus oauth_token_status) override; 87 user_manager::User::OAuthTokenStatus oauth_token_status) override;
88 void SaveUserDisplayName(const std::string& user_id, 88 void SaveUserDisplayName(const user_manager::UserID& user_id,
89 const base::string16& display_name) override; 89 const base::string16& display_name) override;
90 bool CanCurrentUserLock() const override; 90 bool CanCurrentUserLock() const override;
91 bool IsUserNonCryptohomeDataEphemeral( 91 bool IsUserNonCryptohomeDataEphemeral(
92 const std::string& user_id) const override; 92 const user_manager::UserID& user_id) const override;
93 bool AreSupervisedUsersAllowed() const override; 93 bool AreSupervisedUsersAllowed() const override;
94 94
95 // content::NotificationObserver implementation. 95 // content::NotificationObserver implementation.
96 void Observe(int type, 96 void Observe(int type,
97 const content::NotificationSource& source, 97 const content::NotificationSource& source,
98 const content::NotificationDetails& details) override; 98 const content::NotificationDetails& details) override;
99 99
100 // policy::CloudExternalDataPolicyObserver::Delegate: 100 // policy::CloudExternalDataPolicyObserver::Delegate:
101 void OnExternalDataSet(const std::string& policy, 101 void OnExternalDataSet(const std::string& policy,
102 const std::string& user_id) override; 102 const user_manager::UserID& user_id) override;
103 void OnExternalDataCleared(const std::string& policy, 103 void OnExternalDataCleared(const std::string& policy,
104 const std::string& user_id) override; 104 const user_manager::UserID& user_id) override;
105 void OnExternalDataFetched(const std::string& policy, 105 void OnExternalDataFetched(const std::string& policy,
106 const std::string& user_id, 106 const user_manager::UserID& user_id,
107 scoped_ptr<std::string> data) override; 107 scoped_ptr<std::string> data) override;
108 108
109 // policy::DeviceLocalAccountPolicyService::Observer implementation. 109 // policy::DeviceLocalAccountPolicyService::Observer implementation.
110 void OnPolicyUpdated(const std::string& user_id) override; 110 void OnPolicyUpdated(const user_manager::UserID& user_id) override;
111 void OnDeviceLocalAccountsChanged() override; 111 void OnDeviceLocalAccountsChanged() override;
112 112
113 void StopPolicyObserverForTesting(); 113 void StopPolicyObserverForTesting();
114 114
115 // UserManagerBase implementation: 115 // UserManagerBase implementation:
116 bool AreEphemeralUsersEnabled() const override; 116 bool AreEphemeralUsersEnabled() const override;
117 117
118 protected: 118 protected:
119 const std::string& GetApplicationLocale() const override; 119 const std::string& GetApplicationLocale() const override;
120 PrefService* GetLocalState() const override; 120 PrefService* GetLocalState() const override;
121 void HandleUserOAuthTokenStatusChange( 121 void HandleUserOAuthTokenStatusChange(
122 const std::string& user_id, 122 const user_manager::UserID& user_id,
123 user_manager::User::OAuthTokenStatus status) const override; 123 user_manager::User::OAuthTokenStatus status) const override;
124 bool IsEnterpriseManaged() const override; 124 bool IsEnterpriseManaged() const override;
125 void LoadPublicAccounts(std::set<std::string>* users_set) override; 125 void LoadPublicAccounts(std::set<std::string>* users_set) override;
126 void NotifyOnLogin() override; 126 void NotifyOnLogin() override;
127 void NotifyUserAddedToSession(const user_manager::User* added_user, 127 void NotifyUserAddedToSession(const user_manager::User* added_user,
128 bool user_switch_pending) override; 128 bool user_switch_pending) override;
129 void PerformPreUserListLoadingActions() override; 129 void PerformPreUserListLoadingActions() override;
130 void PerformPostUserListLoadingActions() override; 130 void PerformPostUserListLoadingActions() override;
131 void PerformPostUserLoggedInActions(bool browser_restart) override; 131 void PerformPostUserLoggedInActions(bool browser_restart) override;
132 void RemoveNonCryptohomeData(const std::string& user_id) override; 132 void RemoveNonCryptohomeData(const user_manager::UserID& user_id) override;
133 void RemoveUserInternal(const std::string& user_email, 133 void RemoveUserInternal(const user_manager::UserID& user_id,
134 user_manager::RemoveUserDelegate* delegate) override; 134 user_manager::RemoveUserDelegate* delegate) override;
135 bool IsDemoApp(const std::string& user_id) const override; 135 bool IsDemoApp(const user_manager::UserID& user_id) const override;
136 bool IsKioskApp(const std::string& user_id) const override; 136 bool IsKioskApp(const user_manager::UserID& user_id) const override;
137 bool IsPublicAccountMarkedForRemoval( 137 bool IsPublicAccountMarkedForRemoval(
138 const std::string& user_id) const override; 138 const user_manager::UserID& user_id) const override;
139 void DemoAccountLoggedIn() override; 139 void DemoAccountLoggedIn() override;
140 void GuestUserLoggedIn() override; 140 void GuestUserLoggedIn() override;
141 void KioskAppLoggedIn(const std::string& app_id) override; 141 void KioskAppLoggedIn(const std::string& app_id) override;
142 void PublicAccountUserLoggedIn(user_manager::User* user) override; 142 void PublicAccountUserLoggedIn(user_manager::User* user) override;
143 void RegularUserLoggedIn(const std::string& user_id) override; 143 void RegularUserLoggedIn(const user_manager::UserID& user_id) override;
144 void RegularUserLoggedInAsEphemeral(const std::string& user_id) override; 144 void RegularUserLoggedInAsEphemeral(const user_manager::UserID& user_id) overr ide;
145 void SupervisedUserLoggedIn(const std::string& user_id) override; 145 void SupervisedUserLoggedIn(const user_manager::UserID& user_id) override;
146 bool HasPendingBootstrap(const std::string& user_id) const override; 146 bool HasPendingBootstrap(const user_manager::UserID& user_id) const override;
147 147
148 private: 148 private:
149 friend class SupervisedUserManagerImpl; 149 friend class SupervisedUserManagerImpl;
150 friend class UserManagerTest; 150 friend class UserManagerTest;
151 friend class WallpaperManager; 151 friend class WallpaperManager;
152 friend class WallpaperManagerTest; 152 friend class WallpaperManagerTest;
153 153
154 typedef base::hash_map<std::string, linked_ptr<UserImageManager> > 154 typedef base::hash_map<user_manager::UserID, linked_ptr<UserImageManager> >
155 UserImageManagerMap; 155 UserImageManagerMap;
156 156
157 ChromeUserManagerImpl(); 157 ChromeUserManagerImpl();
158 158
159 // Retrieves trusted device policies and removes users from the persistent 159 // Retrieves trusted device policies and removes users from the persistent
160 // list if ephemeral users are enabled. Schedules a callback to itself if 160 // list if ephemeral users are enabled. Schedules a callback to itself if
161 // trusted device policies are not yet available. 161 // trusted device policies are not yet available.
162 void RetrieveTrustedDevicePolicies(); 162 void RetrieveTrustedDevicePolicies();
163 163
164 // Updates current user ownership on UI thread. 164 // Updates current user ownership on UI thread.
165 void UpdateOwnership(); 165 void UpdateOwnership();
166 166
167 // If data for a public account is marked as pending removal and the user is 167 // If data for a public account is marked as pending removal and the user is
168 // no longer logged into that account, removes the data. 168 // no longer logged into that account, removes the data.
169 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); 169 void CleanUpPublicAccountNonCryptohomeDataPendingRemoval();
170 170
171 // Removes data belonging to public accounts that are no longer found on the 171 // Removes data belonging to public accounts that are no longer found on the
172 // user list. If the user is currently logged into one of these accounts, the 172 // user list. If the user is currently logged into one of these accounts, the
173 // data for that account is not removed immediately but marked as pending 173 // data for that account is not removed immediately but marked as pending
174 // removal after logout. 174 // removal after logout.
175 void CleanUpPublicAccountNonCryptohomeData( 175 void CleanUpPublicAccountNonCryptohomeData(
176 const std::vector<std::string>& old_public_accounts); 176 const std::vector<user_manager::UserID>& old_public_accounts);
177 177
178 // Replaces the list of public accounts with those found in 178 // Replaces the list of public accounts with those found in
179 // |device_local_accounts|. Ensures that data belonging to accounts no longer 179 // |device_local_accounts|. Ensures that data belonging to accounts no longer
180 // on the list is removed. Returns |true| if the list has changed. 180 // on the list is removed. Returns |true| if the list has changed.
181 // Public accounts are defined by policy. This method is called whenever an 181 // Public accounts are defined by policy. This method is called whenever an
182 // updated list of public accounts is received from policy. 182 // updated list of public accounts is received from policy.
183 bool UpdateAndCleanUpPublicAccounts( 183 bool UpdateAndCleanUpPublicAccounts(
184 const std::vector<policy::DeviceLocalAccount>& device_local_accounts); 184 const std::vector<policy::DeviceLocalAccount>& device_local_accounts);
185 185
186 // Updates the display name for public account |username| from policy settings 186 // Updates the display name for public account |username| from policy settings
187 // associated with that username. 187 // associated with that username.
188 void UpdatePublicAccountDisplayName(const std::string& user_id); 188 void UpdatePublicAccountDisplayName(const user_manager::UserID& user_id);
189 189
190 // Notifies the UI about a change to the user list. 190 // Notifies the UI about a change to the user list.
191 void NotifyUserListChanged(); 191 void NotifyUserListChanged();
192 192
193 // Lazily creates default user flow. 193 // Lazily creates default user flow.
194 UserFlow* GetDefaultUserFlow() const; 194 UserFlow* GetDefaultUserFlow() const;
195 195
196 // MultiProfileUserControllerDelegate implementation: 196 // MultiProfileUserControllerDelegate implementation:
197 void OnUserNotAllowed(const std::string& user_email) override; 197 void OnUserNotAllowed(const user_manager::UserID& user_id) override;
198 198
199 // BootstrapManager::Delegate implementation: 199 // BootstrapManager::Delegate implementation:
200 void RemovePendingBootstrapUser(const std::string& user_id) override; 200 void RemovePendingBootstrapUser(const user_manager::UserID& user_id) override;
201 201
202 // Update the number of users. 202 // Update the number of users.
203 void UpdateNumberOfUsers(); 203 void UpdateNumberOfUsers();
204 204
205 // Starts (or stops) automatic timezone refresh on geolocation, 205 // Starts (or stops) automatic timezone refresh on geolocation,
206 // depending on user preferences. 206 // depending on user preferences.
207 void UpdateUserTimeZoneRefresher(Profile* profile); 207 void UpdateUserTimeZoneRefresher(Profile* profile);
208 208
209 // Interface to the signed settings store. 209 // Interface to the signed settings store.
210 CrosSettings* cros_settings_; 210 CrosSettings* cros_settings_;
211 211
212 // Interface to device-local account definitions and associated policy. 212 // Interface to device-local account definitions and associated policy.
213 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; 213 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_;
214 214
215 content::NotificationRegistrar registrar_; 215 content::NotificationRegistrar registrar_;
216 216
217 // User avatar managers. 217 // User avatar managers.
218 UserImageManagerMap user_image_managers_; 218 UserImageManagerMap user_image_managers_;
219 219
220 // Supervised user manager. 220 // Supervised user manager.
221 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_; 221 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_;
222 222
223 // Session length limiter. 223 // Session length limiter.
224 scoped_ptr<SessionLengthLimiter> session_length_limiter_; 224 scoped_ptr<SessionLengthLimiter> session_length_limiter_;
225 225
226 typedef std::map<std::string, UserFlow*> FlowMap; 226 typedef std::map<user_manager::UserID, UserFlow*> FlowMap;
227 227
228 // Lazy-initialized default flow. 228 // Lazy-initialized default flow.
229 mutable scoped_ptr<UserFlow> default_flow_; 229 mutable scoped_ptr<UserFlow> default_flow_;
230 230
231 // Specific flows by user e-mail. Keys should be canonicalized before 231 // Specific flows by user id.
232 // access.
233 FlowMap specific_flows_; 232 FlowMap specific_flows_;
234 233
235 scoped_ptr<CrosSettings::ObserverSubscription> local_accounts_subscription_; 234 scoped_ptr<CrosSettings::ObserverSubscription> local_accounts_subscription_;
236 235
237 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_; 236 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_;
238 237
239 // Observer for the policy that can be used to manage user images. 238 // Observer for the policy that can be used to manage user images.
240 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_; 239 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_;
241 240
242 // Observer for the policy that can be used to manage wallpapers. 241 // Observer for the policy that can be used to manage wallpapers.
243 scoped_ptr<policy::CloudExternalDataPolicyObserver> 242 scoped_ptr<policy::CloudExternalDataPolicyObserver>
244 wallpaper_policy_observer_; 243 wallpaper_policy_observer_;
245 244
246 scoped_ptr<BootstrapManager> bootstrap_manager_; 245 scoped_ptr<BootstrapManager> bootstrap_manager_;
247 246
248 base::WeakPtrFactory<ChromeUserManagerImpl> weak_factory_; 247 base::WeakPtrFactory<ChromeUserManagerImpl> weak_factory_;
249 248
250 DISALLOW_COPY_AND_ASSIGN(ChromeUserManagerImpl); 249 DISALLOW_COPY_AND_ASSIGN(ChromeUserManagerImpl);
251 }; 250 };
252 251
253 } // namespace chromeos 252 } // namespace chromeos
254 253
255 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ 254 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698