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_H_ | 5 #ifndef COMPONENTS_USER_MANAGER_USER_H_ |
6 #define COMPONENTS_USER_MANAGER_USER_H_ | 6 #define COMPONENTS_USER_MANAGER_USER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // True if image is being loaded from file. | 164 // True if image is being loaded from file. |
165 bool image_is_loading() const { return image_is_loading_; } | 165 bool image_is_loading() const { return image_is_loading_; } |
166 | 166 |
167 // OAuth token status for this user. | 167 // OAuth token status for this user. |
168 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } | 168 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } |
169 | 169 |
170 // Whether online authentication against GAIA should be enforced during the | 170 // Whether online authentication against GAIA should be enforced during the |
171 // user's next sign-in. | 171 // user's next sign-in. |
172 bool force_online_signin() const { return force_online_signin_; } | 172 bool force_online_signin() const { return force_online_signin_; } |
173 | 173 |
| 174 // Whether the user's session has completed initialization yet. |
| 175 bool profile_ever_initialized() const { return profile_ever_initialized_; } |
| 176 |
174 // True if the user's session can be locked (i.e. the user has a password with | 177 // True if the user's session can be locked (i.e. the user has a password with |
175 // which to unlock the session). | 178 // which to unlock the session). |
176 bool can_lock() const; | 179 bool can_lock() const; |
177 | 180 |
178 // Returns empty string when home dir hasn't been mounted yet. | 181 // Returns empty string when home dir hasn't been mounted yet. |
179 std::string username_hash() const; | 182 std::string username_hash() const; |
180 | 183 |
181 // True if current user is logged in. | 184 // True if current user is logged in. |
182 bool is_logged_in() const; | 185 bool is_logged_in() const; |
183 | 186 |
184 // True if current user is active within the current session. | 187 // True if current user is active within the current session. |
185 bool is_active() const; | 188 bool is_active() const; |
186 | 189 |
187 // True if the user Profile is created. | 190 // True if the user Profile is created. |
188 bool is_profile_created() const { return profile_is_created_; } | 191 bool is_profile_created() const { return profile_is_created_; } |
189 | 192 |
190 protected: | 193 protected: |
191 friend class UserManagerBase; | 194 friend class UserManagerBase; |
192 friend class chromeos::ChromeUserManagerImpl; | 195 friend class chromeos::ChromeUserManagerImpl; |
193 friend class chromeos::SupervisedUserManagerImpl; | 196 friend class chromeos::SupervisedUserManagerImpl; |
194 friend class chromeos::UserImageManagerImpl; | 197 friend class chromeos::UserImageManagerImpl; |
195 friend class chromeos::UserSessionManager; | 198 friend class chromeos::UserSessionManager; |
196 | 199 |
197 // For testing: | 200 // For testing: |
198 friend class FakeUserManager; | 201 friend class FakeUserManager; |
199 friend class chromeos::FakeChromeUserManager; | 202 friend class chromeos::FakeChromeUserManager; |
200 friend class chromeos::MockUserManager; | 203 friend class chromeos::MockUserManager; |
201 friend class chromeos::UserAddingScreenTest; | 204 friend class chromeos::UserAddingScreenTest; |
202 FRIEND_TEST_ALL_PREFIXES(UserTest, DeviceLocalAccountAffiliation); | 205 FRIEND_TEST_ALL_PREFIXES(UserTest, DeviceLocalAccountAffiliation); |
| 206 FRIEND_TEST_ALL_PREFIXES(UserTest, UserSessionInitialized); |
203 | 207 |
204 // Do not allow anyone else to create new User instances. | 208 // Do not allow anyone else to create new User instances. |
205 static User* CreateRegularUser(const AccountId& account_id); | 209 static User* CreateRegularUser(const AccountId& account_id); |
206 static User* CreateGuestUser(const AccountId& guest_account_id); | 210 static User* CreateGuestUser(const AccountId& guest_account_id); |
207 static User* CreateKioskAppUser(const AccountId& kiosk_app_account_id); | 211 static User* CreateKioskAppUser(const AccountId& kiosk_app_account_id); |
208 static User* CreateArcKioskAppUser(const AccountId& arc_kiosk_account_id); | 212 static User* CreateArcKioskAppUser(const AccountId& arc_kiosk_account_id); |
209 static User* CreateSupervisedUser(const AccountId& account_id); | 213 static User* CreateSupervisedUser(const AccountId& account_id); |
210 static User* CreatePublicAccountUser(const AccountId& account_id); | 214 static User* CreatePublicAccountUser(const AccountId& account_id); |
211 | 215 |
212 const std::string* GetAccountLocale() const { return account_locale_.get(); } | 216 const std::string* GetAccountLocale() const { return account_locale_.get(); } |
(...skipping 29 matching lines...) Expand all Loading... |
242 const UserImage& user_image() const { return *user_image_; } | 246 const UserImage& user_image() const { return *user_image_; } |
243 | 247 |
244 void set_oauth_token_status(OAuthTokenStatus status) { | 248 void set_oauth_token_status(OAuthTokenStatus status) { |
245 oauth_token_status_ = status; | 249 oauth_token_status_ = status; |
246 } | 250 } |
247 | 251 |
248 void set_force_online_signin(bool force_online_signin) { | 252 void set_force_online_signin(bool force_online_signin) { |
249 force_online_signin_ = force_online_signin; | 253 force_online_signin_ = force_online_signin; |
250 } | 254 } |
251 | 255 |
| 256 void set_profile_ever_initialized(bool profile_ever_initialized) { |
| 257 profile_ever_initialized_ = profile_ever_initialized; |
| 258 } |
| 259 |
252 void set_username_hash(const std::string& username_hash) { | 260 void set_username_hash(const std::string& username_hash) { |
253 username_hash_ = username_hash; | 261 username_hash_ = username_hash; |
254 } | 262 } |
255 | 263 |
256 void set_is_logged_in(bool is_logged_in) { is_logged_in_ = is_logged_in; } | 264 void set_is_logged_in(bool is_logged_in) { is_logged_in_ = is_logged_in; } |
257 | 265 |
258 void set_can_lock(bool can_lock) { can_lock_ = can_lock; } | 266 void set_can_lock(bool can_lock) { can_lock_ = can_lock; } |
259 | 267 |
260 void set_is_active(bool is_active) { is_active_ = is_active; } | 268 void set_is_active(bool is_active) { is_active_ = is_active; } |
261 | 269 |
262 void set_profile_is_created() { profile_is_created_ = true; } | 270 void set_profile_is_created() { profile_is_created_ = true; } |
263 | 271 |
264 // True if user has google account (not a guest or managed user). | 272 // True if user has google account (not a guest or managed user). |
265 bool has_gaia_account() const; | 273 bool has_gaia_account() const; |
266 | 274 |
267 virtual void SetAffiliation(bool is_affiliated); | 275 virtual void SetAffiliation(bool is_affiliated); |
268 | 276 |
269 private: | 277 private: |
270 AccountId account_id_; | 278 AccountId account_id_; |
271 base::string16 display_name_; | 279 base::string16 display_name_; |
272 base::string16 given_name_; | 280 base::string16 given_name_; |
273 // The displayed user email, defaults to |email_|. | 281 // The displayed user email, defaults to |email_|. |
274 std::string display_email_; | 282 std::string display_email_; |
275 bool using_saml_ = false; | 283 bool using_saml_ = false; |
276 std::unique_ptr<UserImage> user_image_; | 284 std::unique_ptr<UserImage> user_image_; |
277 OAuthTokenStatus oauth_token_status_ = OAUTH_TOKEN_STATUS_UNKNOWN; | 285 OAuthTokenStatus oauth_token_status_ = OAUTH_TOKEN_STATUS_UNKNOWN; |
278 bool force_online_signin_ = false; | 286 bool force_online_signin_ = false; |
| 287 bool profile_ever_initialized_ = false; |
279 | 288 |
280 // This is set to chromeos locale if account data has been downloaded. | 289 // This is set to chromeos locale if account data has been downloaded. |
281 // (Or failed to download, but at least one download attempt finished). | 290 // (Or failed to download, but at least one download attempt finished). |
282 // An empty string indicates error in data load, or in | 291 // An empty string indicates error in data load, or in |
283 // translation of Account locale to chromeos locale. | 292 // translation of Account locale to chromeos locale. |
284 std::unique_ptr<std::string> account_locale_; | 293 std::unique_ptr<std::string> account_locale_; |
285 | 294 |
286 // Used to identify homedir mount point. | 295 // Used to identify homedir mount point. |
287 std::string username_hash_; | 296 std::string username_hash_; |
288 | 297 |
(...skipping 24 matching lines...) Expand all Loading... |
313 | 322 |
314 DISALLOW_COPY_AND_ASSIGN(User); | 323 DISALLOW_COPY_AND_ASSIGN(User); |
315 }; | 324 }; |
316 | 325 |
317 // List of known users. | 326 // List of known users. |
318 using UserList = std::vector<User*>; | 327 using UserList = std::vector<User*>; |
319 | 328 |
320 } // namespace user_manager | 329 } // namespace user_manager |
321 | 330 |
322 #endif // COMPONENTS_USER_MANAGER_USER_H_ | 331 #endif // COMPONENTS_USER_MANAGER_USER_H_ |
OLD | NEW |