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 #include "chrome/browser/chromeos/login/users/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/users/user_manager_impl.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "chrome/common/crash_keys.h" | 52 #include "chrome/common/crash_keys.h" |
53 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
54 #include "chromeos/chromeos_switches.h" | 54 #include "chromeos/chromeos_switches.h" |
55 #include "chromeos/cryptohome/async_method_caller.h" | 55 #include "chromeos/cryptohome/async_method_caller.h" |
56 #include "chromeos/dbus/dbus_thread_manager.h" | 56 #include "chromeos/dbus/dbus_thread_manager.h" |
57 #include "chromeos/login/auth/user_context.h" | 57 #include "chromeos/login/auth/user_context.h" |
58 #include "chromeos/login/login_state.h" | 58 #include "chromeos/login/login_state.h" |
59 #include "chromeos/login/user_names.h" | 59 #include "chromeos/login/user_names.h" |
60 #include "chromeos/settings/cros_settings_names.h" | 60 #include "chromeos/settings/cros_settings_names.h" |
61 #include "components/session_manager/core/session_manager.h" | 61 #include "components/session_manager/core/session_manager.h" |
| 62 #include "components/user_manager/user_image/user_image.h" |
62 #include "components/user_manager/user_type.h" | 63 #include "components/user_manager/user_type.h" |
63 #include "content/public/browser/browser_thread.h" | 64 #include "content/public/browser/browser_thread.h" |
64 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
65 #include "google_apis/gaia/gaia_auth_util.h" | 66 #include "google_apis/gaia/gaia_auth_util.h" |
66 #include "google_apis/gaia/google_service_auth_error.h" | 67 #include "google_apis/gaia/google_service_auth_error.h" |
| 68 #include "grit/theme_resources.h" |
67 #include "policy/policy_constants.h" | 69 #include "policy/policy_constants.h" |
68 #include "ui/base/l10n/l10n_util.h" | 70 #include "ui/base/l10n/l10n_util.h" |
| 71 #include "ui/base/resource/resource_bundle.h" |
69 #include "ui/wm/core/wm_core_switches.h" | 72 #include "ui/wm/core/wm_core_switches.h" |
70 | 73 |
71 using content::BrowserThread; | 74 using content::BrowserThread; |
72 | 75 |
73 namespace chromeos { | 76 namespace chromeos { |
74 namespace { | 77 namespace { |
75 | 78 |
76 // A vector pref of the the regular users known on this device, arranged in LRU | 79 // A vector pref of the the regular users known on this device, arranged in LRU |
77 // order. | 80 // order. |
78 const char kRegularUsers[] = "LoggedInUsers"; | 81 const char kRegularUsers[] = "LoggedInUsers"; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 connector->GetDeviceLocalAccountPolicyService(), | 224 connector->GetDeviceLocalAccountPolicyService(), |
222 policy::key::kWallpaperImage, | 225 policy::key::kWallpaperImage, |
223 this)); | 226 this)); |
224 wallpaper_policy_observer_->Init(); | 227 wallpaper_policy_observer_->Init(); |
225 | 228 |
226 UpdateLoginState(); | 229 UpdateLoginState(); |
227 } | 230 } |
228 | 231 |
229 UserManagerImpl::~UserManagerImpl() { | 232 UserManagerImpl::~UserManagerImpl() { |
230 // Can't use STLDeleteElements because of the private destructor of User. | 233 // Can't use STLDeleteElements because of the private destructor of User. |
231 for (UserList::iterator it = users_.begin(); it != users_.end(); | 234 for (user_manager::UserList::iterator it = users_.begin(); it != users_.end(); |
232 it = users_.erase(it)) { | 235 it = users_.erase(it)) { |
233 DeleteUser(*it); | 236 DeleteUser(*it); |
234 } | 237 } |
235 // These are pointers to the same User instances that were in users_ list. | 238 // These are pointers to the same User instances that were in users_ list. |
236 logged_in_users_.clear(); | 239 logged_in_users_.clear(); |
237 lru_logged_in_users_.clear(); | 240 lru_logged_in_users_.clear(); |
238 | 241 |
239 DeleteUser(active_user_); | 242 DeleteUser(active_user_); |
240 } | 243 } |
241 | 244 |
(...skipping 28 matching lines...) Expand all Loading... |
270 return ui->second.get(); | 273 return ui->second.get(); |
271 linked_ptr<UserImageManagerImpl> mgr(new UserImageManagerImpl(user_id, this)); | 274 linked_ptr<UserImageManagerImpl> mgr(new UserImageManagerImpl(user_id, this)); |
272 user_image_managers_[user_id] = mgr; | 275 user_image_managers_[user_id] = mgr; |
273 return mgr.get(); | 276 return mgr.get(); |
274 } | 277 } |
275 | 278 |
276 SupervisedUserManager* UserManagerImpl::GetSupervisedUserManager() { | 279 SupervisedUserManager* UserManagerImpl::GetSupervisedUserManager() { |
277 return supervised_user_manager_.get(); | 280 return supervised_user_manager_.get(); |
278 } | 281 } |
279 | 282 |
280 const UserList& UserManagerImpl::GetUsers() const { | 283 const user_manager::UserList& UserManagerImpl::GetUsers() const { |
281 const_cast<UserManagerImpl*>(this)->EnsureUsersLoaded(); | 284 const_cast<UserManagerImpl*>(this)->EnsureUsersLoaded(); |
282 return users_; | 285 return users_; |
283 } | 286 } |
284 | 287 |
285 UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const { | 288 user_manager::UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() |
| 289 const { |
286 // Supervised users are not allowed to use multi-profiles. | 290 // Supervised users are not allowed to use multi-profiles. |
287 if (logged_in_users_.size() == 1 && | 291 if (logged_in_users_.size() == 1 && |
288 GetPrimaryUser()->GetType() != user_manager::USER_TYPE_REGULAR) { | 292 GetPrimaryUser()->GetType() != user_manager::USER_TYPE_REGULAR) { |
289 return UserList(); | 293 return user_manager::UserList(); |
290 } | 294 } |
291 | 295 |
292 UserList result; | 296 user_manager::UserList result; |
293 const UserList& users = GetUsers(); | 297 const user_manager::UserList& users = GetUsers(); |
294 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 298 for (user_manager::UserList::const_iterator it = users.begin(); |
| 299 it != users.end(); |
| 300 ++it) { |
295 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR && | 301 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR && |
296 !(*it)->is_logged_in()) { | 302 !(*it)->is_logged_in()) { |
297 MultiProfileUserController::UserAllowedInSessionResult check = | 303 MultiProfileUserController::UserAllowedInSessionResult check = |
298 multi_profile_user_controller_-> | 304 multi_profile_user_controller_-> |
299 IsUserAllowedInSession((*it)->email()); | 305 IsUserAllowedInSession((*it)->email()); |
300 if (check == MultiProfileUserController:: | 306 if (check == MultiProfileUserController:: |
301 NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) { | 307 NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) { |
302 return UserList(); | 308 return user_manager::UserList(); |
303 } | 309 } |
304 | 310 |
305 // Users with a policy that prevents them being added to a session will be | 311 // Users with a policy that prevents them being added to a session will be |
306 // shown in login UI but will be grayed out. | 312 // shown in login UI but will be grayed out. |
307 // Same applies to owner account (see http://crbug.com/385034). | 313 // Same applies to owner account (see http://crbug.com/385034). |
308 if (check == MultiProfileUserController::ALLOWED || | 314 if (check == MultiProfileUserController::ALLOWED || |
309 check == MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS || | 315 check == MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS || |
310 check == MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) { | 316 check == MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) { |
311 result.push_back(*it); | 317 result.push_back(*it); |
312 } | 318 } |
313 } | 319 } |
314 } | 320 } |
315 | 321 |
316 return result; | 322 return result; |
317 } | 323 } |
318 | 324 |
319 const UserList& UserManagerImpl::GetLoggedInUsers() const { | 325 const user_manager::UserList& UserManagerImpl::GetLoggedInUsers() const { |
320 return logged_in_users_; | 326 return logged_in_users_; |
321 } | 327 } |
322 | 328 |
323 const UserList& UserManagerImpl::GetLRULoggedInUsers() { | 329 const user_manager::UserList& UserManagerImpl::GetLRULoggedInUsers() { |
324 // If there is no user logged in, we return the active user as the only one. | 330 // If there is no user logged in, we return the active user as the only one. |
325 if (lru_logged_in_users_.empty() && active_user_) { | 331 if (lru_logged_in_users_.empty() && active_user_) { |
326 temp_single_logged_in_users_.clear(); | 332 temp_single_logged_in_users_.clear(); |
327 temp_single_logged_in_users_.insert(temp_single_logged_in_users_.begin(), | 333 temp_single_logged_in_users_.insert(temp_single_logged_in_users_.begin(), |
328 active_user_); | 334 active_user_); |
329 return temp_single_logged_in_users_; | 335 return temp_single_logged_in_users_; |
330 } | 336 } |
331 return lru_logged_in_users_; | 337 return lru_logged_in_users_; |
332 } | 338 } |
333 | 339 |
334 UserList UserManagerImpl::GetUnlockUsers() const { | 340 user_manager::UserList UserManagerImpl::GetUnlockUsers() const { |
335 const UserList& logged_in_users = GetLoggedInUsers(); | 341 const user_manager::UserList& logged_in_users = GetLoggedInUsers(); |
336 if (logged_in_users.empty()) | 342 if (logged_in_users.empty()) |
337 return UserList(); | 343 return user_manager::UserList(); |
338 | 344 |
339 UserList unlock_users; | 345 user_manager::UserList unlock_users; |
340 Profile* profile = ProfileHelper::Get()->GetProfileByUser(primary_user_); | 346 Profile* profile = ProfileHelper::Get()->GetProfileByUser(primary_user_); |
341 std::string primary_behavior = | 347 std::string primary_behavior = |
342 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); | 348 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); |
343 | 349 |
344 // Specific case: only one logged in user or | 350 // Specific case: only one logged in user or |
345 // primary user has primary-only multi-profile policy. | 351 // primary user has primary-only multi-profile policy. |
346 if (logged_in_users.size() == 1 || | 352 if (logged_in_users.size() == 1 || |
347 primary_behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { | 353 primary_behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { |
348 if (primary_user_->can_lock()) | 354 if (primary_user_->can_lock()) |
349 unlock_users.push_back(primary_user_); | 355 unlock_users.push_back(primary_user_); |
350 } else { | 356 } else { |
351 // Fill list of potential unlock users based on multi-profile policy state. | 357 // Fill list of potential unlock users based on multi-profile policy state. |
352 for (UserList::const_iterator it = logged_in_users.begin(); | 358 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); |
353 it != logged_in_users.end(); ++it) { | 359 it != logged_in_users.end(); |
354 User* user = (*it); | 360 ++it) { |
| 361 user_manager::User* user = (*it); |
355 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); | 362 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); |
356 const std::string behavior = | 363 const std::string behavior = |
357 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); | 364 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); |
358 if (behavior == MultiProfileUserController::kBehaviorUnrestricted && | 365 if (behavior == MultiProfileUserController::kBehaviorUnrestricted && |
359 user->can_lock()) { | 366 user->can_lock()) { |
360 unlock_users.push_back(user); | 367 unlock_users.push_back(user); |
361 } else if (behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { | 368 } else if (behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { |
362 NOTREACHED() | 369 NOTREACHED() |
363 << "Spotted primary-only multi-profile policy for non-primary user"; | 370 << "Spotted primary-only multi-profile policy for non-primary user"; |
364 } | 371 } |
365 } | 372 } |
366 } | 373 } |
367 | 374 |
368 return unlock_users; | 375 return unlock_users; |
369 } | 376 } |
370 | 377 |
371 const std::string& UserManagerImpl::GetOwnerEmail() { | 378 const std::string& UserManagerImpl::GetOwnerEmail() { |
372 return owner_email_; | 379 return owner_email_; |
373 } | 380 } |
374 | 381 |
375 void UserManagerImpl::UserLoggedIn(const std::string& user_id, | 382 void UserManagerImpl::UserLoggedIn(const std::string& user_id, |
376 const std::string& username_hash, | 383 const std::string& username_hash, |
377 bool browser_restart) { | 384 bool browser_restart) { |
378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
379 | 386 |
380 User* user = FindUserInListAndModify(user_id); | 387 user_manager::User* user = FindUserInListAndModify(user_id); |
381 if (active_user_ && user) { | 388 if (active_user_ && user) { |
382 user->set_is_logged_in(true); | 389 user->set_is_logged_in(true); |
383 user->set_username_hash(username_hash); | 390 user->set_username_hash(username_hash); |
384 logged_in_users_.push_back(user); | 391 logged_in_users_.push_back(user); |
385 lru_logged_in_users_.push_back(user); | 392 lru_logged_in_users_.push_back(user); |
386 // Reset the new user flag if the user already exists. | 393 // Reset the new user flag if the user already exists. |
387 is_current_user_new_ = false; | 394 is_current_user_new_ = false; |
388 NotifyUserAddedToSession(user); | 395 NotifyUserAddedToSession(user); |
389 // Remember that we need to switch to this user as soon as profile ready. | 396 // Remember that we need to switch to this user as soon as profile ready. |
390 pending_user_switch_ = user_id; | 397 pending_user_switch_ = user_id; |
(...skipping 18 matching lines...) Expand all Loading... |
409 if (user && user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 416 if (user && user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
410 PublicAccountUserLoggedIn(user); | 417 PublicAccountUserLoggedIn(user); |
411 } else if ((user && | 418 } else if ((user && |
412 user->GetType() == user_manager::USER_TYPE_SUPERVISED) || | 419 user->GetType() == user_manager::USER_TYPE_SUPERVISED) || |
413 (!user && | 420 (!user && |
414 gaia::ExtractDomainName(user_id) == | 421 gaia::ExtractDomainName(user_id) == |
415 chromeos::login::kSupervisedUserDomain)) { | 422 chromeos::login::kSupervisedUserDomain)) { |
416 SupervisedUserLoggedIn(user_id); | 423 SupervisedUserLoggedIn(user_id); |
417 } else if (browser_restart && user_id == g_browser_process->local_state()-> | 424 } else if (browser_restart && user_id == g_browser_process->local_state()-> |
418 GetString(kPublicAccountPendingDataRemoval)) { | 425 GetString(kPublicAccountPendingDataRemoval)) { |
419 PublicAccountUserLoggedIn(User::CreatePublicAccountUser(user_id)); | 426 PublicAccountUserLoggedIn( |
| 427 user_manager::User::CreatePublicAccountUser(user_id)); |
420 } else if (user_id != owner_email_ && !user && | 428 } else if (user_id != owner_email_ && !user && |
421 (AreEphemeralUsersEnabled() || browser_restart)) { | 429 (AreEphemeralUsersEnabled() || browser_restart)) { |
422 RegularUserLoggedInAsEphemeral(user_id); | 430 RegularUserLoggedInAsEphemeral(user_id); |
423 } else { | 431 } else { |
424 RegularUserLoggedIn(user_id); | 432 RegularUserLoggedIn(user_id); |
425 } | 433 } |
426 | 434 |
427 // Initialize the session length limiter and start it only if | 435 // Initialize the session length limiter and start it only if |
428 // session limit is defined by the policy. | 436 // session limit is defined by the policy. |
429 session_length_limiter_.reset(new SessionLengthLimiter(NULL, | 437 session_length_limiter_.reset(new SessionLengthLimiter(NULL, |
(...skipping 20 matching lines...) Expand all Loading... |
450 | 458 |
451 g_browser_process->local_state()->SetString( | 459 g_browser_process->local_state()->SetString( |
452 kLastLoggedInRegularUser, | 460 kLastLoggedInRegularUser, |
453 (active_user_->GetType() == user_manager::USER_TYPE_REGULAR) ? user_id | 461 (active_user_->GetType() == user_manager::USER_TYPE_REGULAR) ? user_id |
454 : ""); | 462 : ""); |
455 | 463 |
456 NotifyOnLogin(); | 464 NotifyOnLogin(); |
457 } | 465 } |
458 | 466 |
459 void UserManagerImpl::SwitchActiveUser(const std::string& user_id) { | 467 void UserManagerImpl::SwitchActiveUser(const std::string& user_id) { |
460 User* user = FindUserAndModify(user_id); | 468 user_manager::User* user = FindUserAndModify(user_id); |
461 if (!user) { | 469 if (!user) { |
462 NOTREACHED() << "Switching to a non-existing user"; | 470 NOTREACHED() << "Switching to a non-existing user"; |
463 return; | 471 return; |
464 } | 472 } |
465 if (user == active_user_) { | 473 if (user == active_user_) { |
466 NOTREACHED() << "Switching to a user who is already active"; | 474 NOTREACHED() << "Switching to a user who is already active"; |
467 return; | 475 return; |
468 } | 476 } |
469 if (!user->is_logged_in()) { | 477 if (!user->is_logged_in()) { |
470 NOTREACHED() << "Switching to a user that is not logged in"; | 478 NOTREACHED() << "Switching to a user that is not logged in"; |
(...skipping 24 matching lines...) Expand all Loading... |
495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
496 session_started_ = true; | 504 session_started_ = true; |
497 | 505 |
498 UpdateLoginState(); | 506 UpdateLoginState(); |
499 g_browser_process->platform_part()->SessionManager()->SetSessionState( | 507 g_browser_process->platform_part()->SessionManager()->SetSessionState( |
500 session_manager::SESSION_STATE_ACTIVE); | 508 session_manager::SESSION_STATE_ACTIVE); |
501 | 509 |
502 content::NotificationService::current()->Notify( | 510 content::NotificationService::current()->Notify( |
503 chrome::NOTIFICATION_SESSION_STARTED, | 511 chrome::NOTIFICATION_SESSION_STARTED, |
504 content::Source<UserManager>(this), | 512 content::Source<UserManager>(this), |
505 content::Details<const User>(active_user_)); | 513 content::Details<const user_manager::User>(active_user_)); |
506 if (is_current_user_new_) { | 514 if (is_current_user_new_) { |
507 // Make sure that the new user's data is persisted to Local State. | 515 // Make sure that the new user's data is persisted to Local State. |
508 g_browser_process->local_state()->CommitPendingWrite(); | 516 g_browser_process->local_state()->CommitPendingWrite(); |
509 } | 517 } |
510 } | 518 } |
511 | 519 |
512 void UserManagerImpl::RemoveUser(const std::string& user_id, | 520 void UserManagerImpl::RemoveUser(const std::string& user_id, |
513 RemoveUserDelegate* delegate) { | 521 RemoveUserDelegate* delegate) { |
514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
515 | 523 |
516 const User* user = FindUser(user_id); | 524 const user_manager::User* user = FindUser(user_id); |
517 if (!user || (user->GetType() != user_manager::USER_TYPE_REGULAR && | 525 if (!user || (user->GetType() != user_manager::USER_TYPE_REGULAR && |
518 user->GetType() != user_manager::USER_TYPE_SUPERVISED)) | 526 user->GetType() != user_manager::USER_TYPE_SUPERVISED)) |
519 return; | 527 return; |
520 | 528 |
521 // Sanity check: we must not remove single user unless it's an enterprise | 529 // Sanity check: we must not remove single user unless it's an enterprise |
522 // device. This check may seem redundant at a first sight because | 530 // device. This check may seem redundant at a first sight because |
523 // this single user must be an owner and we perform special check later | 531 // this single user must be an owner and we perform special check later |
524 // in order not to remove an owner. However due to non-instant nature of | 532 // in order not to remove an owner. However due to non-instant nature of |
525 // ownership assignment this later check may sometimes fail. | 533 // ownership assignment this later check may sometimes fail. |
526 // See http://crosbug.com/12723 | 534 // See http://crosbug.com/12723 |
527 policy::BrowserPolicyConnectorChromeOS* connector = | 535 policy::BrowserPolicyConnectorChromeOS* connector = |
528 g_browser_process->platform_part() | 536 g_browser_process->platform_part() |
529 ->browser_policy_connector_chromeos(); | 537 ->browser_policy_connector_chromeos(); |
530 if (users_.size() < 2 && !connector->IsEnterpriseManaged()) | 538 if (users_.size() < 2 && !connector->IsEnterpriseManaged()) |
531 return; | 539 return; |
532 | 540 |
533 // Sanity check: do not allow any of the the logged in users to be removed. | 541 // Sanity check: do not allow any of the the logged in users to be removed. |
534 for (UserList::const_iterator it = logged_in_users_.begin(); | 542 for (user_manager::UserList::const_iterator it = logged_in_users_.begin(); |
535 it != logged_in_users_.end(); ++it) { | 543 it != logged_in_users_.end(); |
| 544 ++it) { |
536 if ((*it)->email() == user_id) | 545 if ((*it)->email() == user_id) |
537 return; | 546 return; |
538 } | 547 } |
539 | 548 |
540 RemoveUserInternal(user_id, delegate); | 549 RemoveUserInternal(user_id, delegate); |
541 } | 550 } |
542 | 551 |
543 void UserManagerImpl::RemoveUserInternal(const std::string& user_email, | 552 void UserManagerImpl::RemoveUserInternal(const std::string& user_email, |
544 RemoveUserDelegate* delegate) { | 553 RemoveUserDelegate* delegate) { |
545 CrosSettings* cros_settings = CrosSettings::Get(); | 554 CrosSettings* cros_settings = CrosSettings::Get(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 return; | 601 return; |
593 } | 602 } |
594 // Make sure that new data is persisted to Local State. | 603 // Make sure that new data is persisted to Local State. |
595 g_browser_process->local_state()->CommitPendingWrite(); | 604 g_browser_process->local_state()->CommitPendingWrite(); |
596 } | 605 } |
597 | 606 |
598 bool UserManagerImpl::IsKnownUser(const std::string& user_id) const { | 607 bool UserManagerImpl::IsKnownUser(const std::string& user_id) const { |
599 return FindUser(user_id) != NULL; | 608 return FindUser(user_id) != NULL; |
600 } | 609 } |
601 | 610 |
602 const User* UserManagerImpl::FindUser(const std::string& user_id) const { | 611 const user_manager::User* UserManagerImpl::FindUser( |
| 612 const std::string& user_id) const { |
603 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 613 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
604 if (active_user_ && active_user_->email() == user_id) | 614 if (active_user_ && active_user_->email() == user_id) |
605 return active_user_; | 615 return active_user_; |
606 return FindUserInList(user_id); | 616 return FindUserInList(user_id); |
607 } | 617 } |
608 | 618 |
609 User* UserManagerImpl::FindUserAndModify(const std::string& user_id) { | 619 user_manager::User* UserManagerImpl::FindUserAndModify( |
| 620 const std::string& user_id) { |
610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
611 if (active_user_ && active_user_->email() == user_id) | 622 if (active_user_ && active_user_->email() == user_id) |
612 return active_user_; | 623 return active_user_; |
613 return FindUserInListAndModify(user_id); | 624 return FindUserInListAndModify(user_id); |
614 } | 625 } |
615 | 626 |
616 const User* UserManagerImpl::GetLoggedInUser() const { | 627 const user_manager::User* UserManagerImpl::GetLoggedInUser() const { |
617 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
618 return active_user_; | 629 return active_user_; |
619 } | 630 } |
620 | 631 |
621 User* UserManagerImpl::GetLoggedInUser() { | 632 user_manager::User* UserManagerImpl::GetLoggedInUser() { |
622 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 633 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
623 return active_user_; | 634 return active_user_; |
624 } | 635 } |
625 | 636 |
626 const User* UserManagerImpl::GetActiveUser() const { | 637 const user_manager::User* UserManagerImpl::GetActiveUser() const { |
627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 638 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
628 return active_user_; | 639 return active_user_; |
629 } | 640 } |
630 | 641 |
631 User* UserManagerImpl::GetActiveUser() { | 642 user_manager::User* UserManagerImpl::GetActiveUser() { |
632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 643 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
633 return active_user_; | 644 return active_user_; |
634 } | 645 } |
635 | 646 |
636 const User* UserManagerImpl::GetPrimaryUser() const { | 647 const user_manager::User* UserManagerImpl::GetPrimaryUser() const { |
637 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 648 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
638 return primary_user_; | 649 return primary_user_; |
639 } | 650 } |
640 | 651 |
641 void UserManagerImpl::SaveUserOAuthStatus( | 652 void UserManagerImpl::SaveUserOAuthStatus( |
642 const std::string& user_id, | 653 const std::string& user_id, |
643 User::OAuthTokenStatus oauth_token_status) { | 654 user_manager::User::OAuthTokenStatus oauth_token_status) { |
644 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
645 | 656 |
646 DVLOG(1) << "Saving user OAuth token status in Local State"; | 657 DVLOG(1) << "Saving user OAuth token status in Local State"; |
647 User* user = FindUserAndModify(user_id); | 658 user_manager::User* user = FindUserAndModify(user_id); |
648 if (user) | 659 if (user) |
649 user->set_oauth_token_status(oauth_token_status); | 660 user->set_oauth_token_status(oauth_token_status); |
650 | 661 |
651 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(oauth_token_status); | 662 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(oauth_token_status); |
652 | 663 |
653 // Do not update local state if data stored or cached outside the user's | 664 // Do not update local state if data stored or cached outside the user's |
654 // cryptohome is to be treated as ephemeral. | 665 // cryptohome is to be treated as ephemeral. |
655 if (IsUserNonCryptohomeDataEphemeral(user_id)) | 666 if (IsUserNonCryptohomeDataEphemeral(user_id)) |
656 return; | 667 return; |
657 | 668 |
(...skipping 16 matching lines...) Expand all Loading... |
674 DictionaryPrefUpdate force_online_update(g_browser_process->local_state(), | 685 DictionaryPrefUpdate force_online_update(g_browser_process->local_state(), |
675 kUserForceOnlineSignin); | 686 kUserForceOnlineSignin); |
676 force_online_update->SetBooleanWithoutPathExpansion(user_id, | 687 force_online_update->SetBooleanWithoutPathExpansion(user_id, |
677 force_online_signin); | 688 force_online_signin); |
678 } | 689 } |
679 | 690 |
680 void UserManagerImpl::SaveUserDisplayName(const std::string& user_id, | 691 void UserManagerImpl::SaveUserDisplayName(const std::string& user_id, |
681 const base::string16& display_name) { | 692 const base::string16& display_name) { |
682 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
683 | 694 |
684 if (User* user = FindUserAndModify(user_id)) { | 695 if (user_manager::User* user = FindUserAndModify(user_id)) { |
685 user->set_display_name(display_name); | 696 user->set_display_name(display_name); |
686 | 697 |
687 // Do not update local state if data stored or cached outside the user's | 698 // Do not update local state if data stored or cached outside the user's |
688 // cryptohome is to be treated as ephemeral. | 699 // cryptohome is to be treated as ephemeral. |
689 if (!IsUserNonCryptohomeDataEphemeral(user_id)) { | 700 if (!IsUserNonCryptohomeDataEphemeral(user_id)) { |
690 PrefService* local_state = g_browser_process->local_state(); | 701 PrefService* local_state = g_browser_process->local_state(); |
691 | 702 |
692 DictionaryPrefUpdate display_name_update(local_state, kUserDisplayName); | 703 DictionaryPrefUpdate display_name_update(local_state, kUserDisplayName); |
693 display_name_update->SetWithoutPathExpansion( | 704 display_name_update->SetWithoutPathExpansion( |
694 user_id, | 705 user_id, |
695 new base::StringValue(display_name)); | 706 new base::StringValue(display_name)); |
696 | 707 |
697 supervised_user_manager_->UpdateManagerName(user_id, display_name); | 708 supervised_user_manager_->UpdateManagerName(user_id, display_name); |
698 } | 709 } |
699 } | 710 } |
700 } | 711 } |
701 | 712 |
702 base::string16 UserManagerImpl::GetUserDisplayName( | 713 base::string16 UserManagerImpl::GetUserDisplayName( |
703 const std::string& user_id) const { | 714 const std::string& user_id) const { |
704 const User* user = FindUser(user_id); | 715 const user_manager::User* user = FindUser(user_id); |
705 return user ? user->display_name() : base::string16(); | 716 return user ? user->display_name() : base::string16(); |
706 } | 717 } |
707 | 718 |
708 void UserManagerImpl::SaveUserDisplayEmail(const std::string& user_id, | 719 void UserManagerImpl::SaveUserDisplayEmail(const std::string& user_id, |
709 const std::string& display_email) { | 720 const std::string& display_email) { |
710 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 721 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
711 | 722 |
712 User* user = FindUserAndModify(user_id); | 723 user_manager::User* user = FindUserAndModify(user_id); |
713 if (!user) | 724 if (!user) |
714 return; // Ignore if there is no such user. | 725 return; // Ignore if there is no such user. |
715 | 726 |
716 user->set_display_email(display_email); | 727 user->set_display_email(display_email); |
717 | 728 |
718 // Do not update local state if data stored or cached outside the user's | 729 // Do not update local state if data stored or cached outside the user's |
719 // cryptohome is to be treated as ephemeral. | 730 // cryptohome is to be treated as ephemeral. |
720 if (IsUserNonCryptohomeDataEphemeral(user_id)) | 731 if (IsUserNonCryptohomeDataEphemeral(user_id)) |
721 return; | 732 return; |
722 | 733 |
723 PrefService* local_state = g_browser_process->local_state(); | 734 PrefService* local_state = g_browser_process->local_state(); |
724 | 735 |
725 DictionaryPrefUpdate display_email_update(local_state, kUserDisplayEmail); | 736 DictionaryPrefUpdate display_email_update(local_state, kUserDisplayEmail); |
726 display_email_update->SetWithoutPathExpansion( | 737 display_email_update->SetWithoutPathExpansion( |
727 user_id, | 738 user_id, |
728 new base::StringValue(display_email)); | 739 new base::StringValue(display_email)); |
729 } | 740 } |
730 | 741 |
731 std::string UserManagerImpl::GetUserDisplayEmail( | 742 std::string UserManagerImpl::GetUserDisplayEmail( |
732 const std::string& user_id) const { | 743 const std::string& user_id) const { |
733 const User* user = FindUser(user_id); | 744 const user_manager::User* user = FindUser(user_id); |
734 return user ? user->display_email() : user_id; | 745 return user ? user->display_email() : user_id; |
735 } | 746 } |
736 | 747 |
737 void UserManagerImpl::UpdateUserAccountData( | 748 void UserManagerImpl::UpdateUserAccountData( |
738 const std::string& user_id, | 749 const std::string& user_id, |
739 const UserAccountData& account_data) { | 750 const UserAccountData& account_data) { |
740 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 751 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
741 | 752 |
742 SaveUserDisplayName(user_id, account_data.display_name()); | 753 SaveUserDisplayName(user_id, account_data.display_name()); |
743 | 754 |
744 if (User* user = FindUserAndModify(user_id)) { | 755 if (user_manager::User* user = FindUserAndModify(user_id)) { |
745 base::string16 given_name = account_data.given_name(); | 756 base::string16 given_name = account_data.given_name(); |
746 user->set_given_name(given_name); | 757 user->set_given_name(given_name); |
747 if (!IsUserNonCryptohomeDataEphemeral(user_id)) { | 758 if (!IsUserNonCryptohomeDataEphemeral(user_id)) { |
748 PrefService* local_state = g_browser_process->local_state(); | 759 PrefService* local_state = g_browser_process->local_state(); |
749 | 760 |
750 DictionaryPrefUpdate given_name_update(local_state, kUserGivenName); | 761 DictionaryPrefUpdate given_name_update(local_state, kUserGivenName); |
751 given_name_update->SetWithoutPathExpansion( | 762 given_name_update->SetWithoutPathExpansion( |
752 user_id, | 763 user_id, |
753 new base::StringValue(given_name)); | 764 new base::StringValue(given_name)); |
754 } | 765 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 AuthSyncObserver* sync_observer = | 804 AuthSyncObserver* sync_observer = |
794 AuthSyncObserverFactory::GetInstance()->GetForProfile(profile); | 805 AuthSyncObserverFactory::GetInstance()->GetForProfile(profile); |
795 sync_observer->StartObserving(); | 806 sync_observer->StartObserving(); |
796 multi_profile_user_controller_->StartObserving(profile); | 807 multi_profile_user_controller_->StartObserving(profile); |
797 } | 808 } |
798 } | 809 } |
799 break; | 810 break; |
800 } | 811 } |
801 case chrome::NOTIFICATION_PROFILE_CREATED: { | 812 case chrome::NOTIFICATION_PROFILE_CREATED: { |
802 Profile* profile = content::Source<Profile>(source).ptr(); | 813 Profile* profile = content::Source<Profile>(source).ptr(); |
803 User* user = ProfileHelper::Get()->GetUserByProfile(profile); | 814 user_manager::User* user = |
| 815 ProfileHelper::Get()->GetUserByProfile(profile); |
804 if (user != NULL) | 816 if (user != NULL) |
805 user->set_profile_is_created(); | 817 user->set_profile_is_created(); |
806 // If there is pending user switch, do it now. | 818 // If there is pending user switch, do it now. |
807 if (!pending_user_switch_.empty()) { | 819 if (!pending_user_switch_.empty()) { |
808 // Call SwitchActiveUser async because otherwise it may cause | 820 // Call SwitchActiveUser async because otherwise it may cause |
809 // ProfileManager::GetProfile before the profile gets registered | 821 // ProfileManager::GetProfile before the profile gets registered |
810 // in ProfileManager. It happens in case of sync profile load when | 822 // in ProfileManager. It happens in case of sync profile load when |
811 // NOTIFICATION_PROFILE_CREATED is called synchronously. | 823 // NOTIFICATION_PROFILE_CREATED is called synchronously. |
812 base::MessageLoop::current()->PostTask(FROM_HERE, | 824 base::MessageLoop::current()->PostTask(FROM_HERE, |
813 base::Bind(&UserManagerImpl::SwitchActiveUser, | 825 base::Bind(&UserManagerImpl::SwitchActiveUser, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 scoped_ptr<std::string> data) { | 859 scoped_ptr<std::string> data) { |
848 if (policy == policy::key::kUserAvatarImage) | 860 if (policy == policy::key::kUserAvatarImage) |
849 GetUserImageManager(user_id)->OnExternalDataFetched(policy, data.Pass()); | 861 GetUserImageManager(user_id)->OnExternalDataFetched(policy, data.Pass()); |
850 else if (policy == policy::key::kWallpaperImage) | 862 else if (policy == policy::key::kWallpaperImage) |
851 WallpaperManager::Get()->OnPolicyFetched(policy, user_id, data.Pass()); | 863 WallpaperManager::Get()->OnPolicyFetched(policy, user_id, data.Pass()); |
852 else | 864 else |
853 NOTREACHED(); | 865 NOTREACHED(); |
854 } | 866 } |
855 | 867 |
856 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) { | 868 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) { |
857 const User* user = FindUserInList(user_id); | 869 const user_manager::User* user = FindUserInList(user_id); |
858 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 870 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
859 return; | 871 return; |
860 UpdatePublicAccountDisplayName(user_id); | 872 UpdatePublicAccountDisplayName(user_id); |
861 NotifyUserListChanged(); | 873 NotifyUserListChanged(); |
862 } | 874 } |
863 | 875 |
864 void UserManagerImpl::OnDeviceLocalAccountsChanged() { | 876 void UserManagerImpl::OnDeviceLocalAccountsChanged() { |
865 // No action needed here, changes to the list of device-local accounts get | 877 // No action needed here, changes to the list of device-local accounts get |
866 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. | 878 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. |
867 } | 879 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 const base::DictionaryValue* prefs_display_emails = | 1051 const base::DictionaryValue* prefs_display_emails = |
1040 local_state->GetDictionary(kUserDisplayEmail); | 1052 local_state->GetDictionary(kUserDisplayEmail); |
1041 | 1053 |
1042 // Load public sessions first. | 1054 // Load public sessions first. |
1043 std::vector<std::string> public_sessions; | 1055 std::vector<std::string> public_sessions; |
1044 std::set<std::string> public_sessions_set; | 1056 std::set<std::string> public_sessions_set; |
1045 ParseUserList(*prefs_public_sessions, std::set<std::string>(), | 1057 ParseUserList(*prefs_public_sessions, std::set<std::string>(), |
1046 &public_sessions, &public_sessions_set); | 1058 &public_sessions, &public_sessions_set); |
1047 for (std::vector<std::string>::const_iterator it = public_sessions.begin(); | 1059 for (std::vector<std::string>::const_iterator it = public_sessions.begin(); |
1048 it != public_sessions.end(); ++it) { | 1060 it != public_sessions.end(); ++it) { |
1049 users_.push_back(User::CreatePublicAccountUser(*it)); | 1061 users_.push_back(user_manager::User::CreatePublicAccountUser(*it)); |
1050 UpdatePublicAccountDisplayName(*it); | 1062 UpdatePublicAccountDisplayName(*it); |
1051 } | 1063 } |
1052 | 1064 |
1053 // Load regular users and supervised users. | 1065 // Load regular users and supervised users. |
1054 std::vector<std::string> regular_users; | 1066 std::vector<std::string> regular_users; |
1055 std::set<std::string> regular_users_set; | 1067 std::set<std::string> regular_users_set; |
1056 ParseUserList(*prefs_regular_users, public_sessions_set, | 1068 ParseUserList(*prefs_regular_users, public_sessions_set, |
1057 ®ular_users, ®ular_users_set); | 1069 ®ular_users, ®ular_users_set); |
1058 for (std::vector<std::string>::const_iterator it = regular_users.begin(); | 1070 for (std::vector<std::string>::const_iterator it = regular_users.begin(); |
1059 it != regular_users.end(); ++it) { | 1071 it != regular_users.end(); ++it) { |
1060 User* user = NULL; | 1072 user_manager::User* user = NULL; |
1061 const std::string domain = gaia::ExtractDomainName(*it); | 1073 const std::string domain = gaia::ExtractDomainName(*it); |
1062 if (domain == chromeos::login::kSupervisedUserDomain) | 1074 if (domain == chromeos::login::kSupervisedUserDomain) |
1063 user = User::CreateSupervisedUser(*it); | 1075 user = user_manager::User::CreateSupervisedUser(*it); |
1064 else | 1076 else |
1065 user = User::CreateRegularUser(*it); | 1077 user = user_manager::User::CreateRegularUser(*it); |
1066 user->set_oauth_token_status(LoadUserOAuthStatus(*it)); | 1078 user->set_oauth_token_status(LoadUserOAuthStatus(*it)); |
1067 user->set_force_online_signin(LoadForceOnlineSignin(*it)); | 1079 user->set_force_online_signin(LoadForceOnlineSignin(*it)); |
1068 users_.push_back(user); | 1080 users_.push_back(user); |
1069 | 1081 |
1070 base::string16 display_name; | 1082 base::string16 display_name; |
1071 if (prefs_display_names->GetStringWithoutPathExpansion(*it, | 1083 if (prefs_display_names->GetStringWithoutPathExpansion(*it, |
1072 &display_name)) { | 1084 &display_name)) { |
1073 user->set_display_name(display_name); | 1085 user->set_display_name(display_name); |
1074 } | 1086 } |
1075 | 1087 |
1076 base::string16 given_name; | 1088 base::string16 given_name; |
1077 if (prefs_given_names->GetStringWithoutPathExpansion(*it, &given_name)) { | 1089 if (prefs_given_names->GetStringWithoutPathExpansion(*it, &given_name)) { |
1078 user->set_given_name(given_name); | 1090 user->set_given_name(given_name); |
1079 } | 1091 } |
1080 | 1092 |
1081 std::string display_email; | 1093 std::string display_email; |
1082 if (prefs_display_emails->GetStringWithoutPathExpansion(*it, | 1094 if (prefs_display_emails->GetStringWithoutPathExpansion(*it, |
1083 &display_email)) { | 1095 &display_email)) { |
1084 user->set_display_email(display_email); | 1096 user->set_display_email(display_email); |
1085 } | 1097 } |
1086 } | 1098 } |
1087 | 1099 |
1088 user_loading_stage_ = STAGE_LOADED; | 1100 user_loading_stage_ = STAGE_LOADED; |
1089 | 1101 |
1090 for (UserList::iterator ui = users_.begin(), ue = users_.end(); | 1102 for (user_manager::UserList::iterator ui = users_.begin(), ue = users_.end(); |
1091 ui != ue; ++ui) { | 1103 ui != ue; |
| 1104 ++ui) { |
1092 GetUserImageManager((*ui)->email())->LoadUserImage(); | 1105 GetUserImageManager((*ui)->email())->LoadUserImage(); |
1093 } | 1106 } |
1094 } | 1107 } |
1095 | 1108 |
1096 void UserManagerImpl::RetrieveTrustedDevicePolicies() { | 1109 void UserManagerImpl::RetrieveTrustedDevicePolicies() { |
1097 ephemeral_users_enabled_ = false; | 1110 ephemeral_users_enabled_ = false; |
1098 owner_email_.clear(); | 1111 owner_email_.clear(); |
1099 | 1112 |
1100 // Schedule a callback if device policy has not yet been verified. | 1113 // Schedule a callback if device policy has not yet been verified. |
1101 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( | 1114 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( |
(...skipping 10 matching lines...) Expand all Loading... |
1112 | 1125 |
1113 bool changed = UpdateAndCleanUpPublicAccounts( | 1126 bool changed = UpdateAndCleanUpPublicAccounts( |
1114 policy::GetDeviceLocalAccounts(cros_settings_)); | 1127 policy::GetDeviceLocalAccounts(cros_settings_)); |
1115 | 1128 |
1116 // If ephemeral users are enabled and we are on the login screen, take this | 1129 // If ephemeral users are enabled and we are on the login screen, take this |
1117 // opportunity to clean up by removing all regular users except the owner. | 1130 // opportunity to clean up by removing all regular users except the owner. |
1118 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) { | 1131 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) { |
1119 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), | 1132 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), |
1120 kRegularUsers); | 1133 kRegularUsers); |
1121 prefs_users_update->Clear(); | 1134 prefs_users_update->Clear(); |
1122 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { | 1135 for (user_manager::UserList::iterator it = users_.begin(); |
| 1136 it != users_.end();) { |
1123 const std::string user_email = (*it)->email(); | 1137 const std::string user_email = (*it)->email(); |
1124 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR && | 1138 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR && |
1125 user_email != owner_email_) { | 1139 user_email != owner_email_) { |
1126 RemoveNonCryptohomeData(user_email); | 1140 RemoveNonCryptohomeData(user_email); |
1127 DeleteUser(*it); | 1141 DeleteUser(*it); |
1128 it = users_.erase(it); | 1142 it = users_.erase(it); |
1129 changed = true; | 1143 changed = true; |
1130 } else { | 1144 } else { |
1131 if ((*it)->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 1145 if ((*it)->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
1132 prefs_users_update->Append(new base::StringValue(user_email)); | 1146 prefs_users_update->Append(new base::StringValue(user_email)); |
1133 ++it; | 1147 ++it; |
1134 } | 1148 } |
1135 } | 1149 } |
1136 } | 1150 } |
1137 | 1151 |
1138 if (changed) | 1152 if (changed) |
1139 NotifyUserListChanged(); | 1153 NotifyUserListChanged(); |
1140 } | 1154 } |
1141 | 1155 |
1142 bool UserManagerImpl::AreEphemeralUsersEnabled() const { | 1156 bool UserManagerImpl::AreEphemeralUsersEnabled() const { |
1143 policy::BrowserPolicyConnectorChromeOS* connector = | 1157 policy::BrowserPolicyConnectorChromeOS* connector = |
1144 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1158 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1145 return ephemeral_users_enabled_ && | 1159 return ephemeral_users_enabled_ && |
1146 (connector->IsEnterpriseManaged() || !owner_email_.empty()); | 1160 (connector->IsEnterpriseManaged() || !owner_email_.empty()); |
1147 } | 1161 } |
1148 | 1162 |
1149 UserList& UserManagerImpl::GetUsersAndModify() { | 1163 user_manager::UserList& UserManagerImpl::GetUsersAndModify() { |
1150 EnsureUsersLoaded(); | 1164 EnsureUsersLoaded(); |
1151 return users_; | 1165 return users_; |
1152 } | 1166 } |
1153 | 1167 |
1154 const User* UserManagerImpl::FindUserInList(const std::string& user_id) const { | 1168 const user_manager::User* UserManagerImpl::FindUserInList( |
1155 const UserList& users = GetUsers(); | 1169 const std::string& user_id) const { |
1156 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1170 const user_manager::UserList& users = GetUsers(); |
| 1171 for (user_manager::UserList::const_iterator it = users.begin(); |
| 1172 it != users.end(); |
| 1173 ++it) { |
1157 if ((*it)->email() == user_id) | 1174 if ((*it)->email() == user_id) |
1158 return *it; | 1175 return *it; |
1159 } | 1176 } |
1160 return NULL; | 1177 return NULL; |
1161 } | 1178 } |
1162 | 1179 |
1163 const bool UserManagerImpl::UserExistsInList(const std::string& user_id) const { | 1180 const bool UserManagerImpl::UserExistsInList(const std::string& user_id) const { |
1164 PrefService* local_state = g_browser_process->local_state(); | 1181 PrefService* local_state = g_browser_process->local_state(); |
1165 const base::ListValue* user_list = local_state->GetList(kRegularUsers); | 1182 const base::ListValue* user_list = local_state->GetList(kRegularUsers); |
1166 for (size_t i = 0; i < user_list->GetSize(); ++i) { | 1183 for (size_t i = 0; i < user_list->GetSize(); ++i) { |
1167 std::string email; | 1184 std::string email; |
1168 if (user_list->GetString(i, &email) && (user_id == email)) | 1185 if (user_list->GetString(i, &email) && (user_id == email)) |
1169 return true; | 1186 return true; |
1170 } | 1187 } |
1171 return false; | 1188 return false; |
1172 } | 1189 } |
1173 | 1190 |
1174 User* UserManagerImpl::FindUserInListAndModify(const std::string& user_id) { | 1191 user_manager::User* UserManagerImpl::FindUserInListAndModify( |
1175 UserList& users = GetUsersAndModify(); | 1192 const std::string& user_id) { |
1176 for (UserList::iterator it = users.begin(); it != users.end(); ++it) { | 1193 user_manager::UserList& users = GetUsersAndModify(); |
| 1194 for (user_manager::UserList::iterator it = users.begin(); it != users.end(); |
| 1195 ++it) { |
1177 if ((*it)->email() == user_id) | 1196 if ((*it)->email() == user_id) |
1178 return *it; | 1197 return *it; |
1179 } | 1198 } |
1180 return NULL; | 1199 return NULL; |
1181 } | 1200 } |
1182 | 1201 |
1183 void UserManagerImpl::GuestUserLoggedIn() { | 1202 void UserManagerImpl::GuestUserLoggedIn() { |
1184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1185 active_user_ = User::CreateGuestUser(); | 1204 active_user_ = user_manager::User::CreateGuestUser(); |
1186 // TODO(nkostylev): Add support for passing guest session cryptohome | 1205 // TODO(nkostylev): Add support for passing guest session cryptohome |
1187 // mount point. Legacy (--login-profile) value will be used for now. | 1206 // mount point. Legacy (--login-profile) value will be used for now. |
1188 // http://crosbug.com/230859 | 1207 // http://crosbug.com/230859 |
1189 active_user_->SetStubImage(User::kInvalidImageIndex, false); | 1208 active_user_->SetStubImage( |
| 1209 user_manager::UserImage( |
| 1210 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 1211 IDR_PROFILE_PICTURE_LOADING)), |
| 1212 user_manager::User::USER_IMAGE_INVALID, |
| 1213 false); |
1190 // Initializes wallpaper after active_user_ is set. | 1214 // Initializes wallpaper after active_user_ is set. |
1191 WallpaperManager::Get()->SetUserWallpaperNow(chromeos::login::kGuestUserName); | 1215 WallpaperManager::Get()->SetUserWallpaperNow(chromeos::login::kGuestUserName); |
1192 } | 1216 } |
1193 | 1217 |
1194 void UserManagerImpl::AddUserRecord(User* user) { | 1218 void UserManagerImpl::AddUserRecord(user_manager::User* user) { |
1195 // Add the user to the front of the user list. | 1219 // Add the user to the front of the user list. |
1196 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), | 1220 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), |
1197 kRegularUsers); | 1221 kRegularUsers); |
1198 prefs_users_update->Insert(0, new base::StringValue(user->email())); | 1222 prefs_users_update->Insert(0, new base::StringValue(user->email())); |
1199 users_.insert(users_.begin(), user); | 1223 users_.insert(users_.begin(), user); |
1200 } | 1224 } |
1201 | 1225 |
1202 void UserManagerImpl::RegularUserLoggedIn(const std::string& user_id) { | 1226 void UserManagerImpl::RegularUserLoggedIn(const std::string& user_id) { |
1203 // Remove the user from the user list. | 1227 // Remove the user from the user list. |
1204 active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); | 1228 active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); |
1205 | 1229 |
1206 // If the user was not found on the user list, create a new user. | 1230 // If the user was not found on the user list, create a new user. |
1207 is_current_user_new_ = !active_user_; | 1231 is_current_user_new_ = !active_user_; |
1208 if (!active_user_) { | 1232 if (!active_user_) { |
1209 active_user_ = User::CreateRegularUser(user_id); | 1233 active_user_ = user_manager::User::CreateRegularUser(user_id); |
1210 active_user_->set_oauth_token_status(LoadUserOAuthStatus(user_id)); | 1234 active_user_->set_oauth_token_status(LoadUserOAuthStatus(user_id)); |
1211 SaveUserDisplayName(active_user_->email(), | 1235 SaveUserDisplayName(active_user_->email(), |
1212 base::UTF8ToUTF16(active_user_->GetAccountName(true))); | 1236 base::UTF8ToUTF16(active_user_->GetAccountName(true))); |
1213 WallpaperManager::Get()->SetUserWallpaperNow(user_id); | 1237 WallpaperManager::Get()->SetUserWallpaperNow(user_id); |
1214 } | 1238 } |
1215 | 1239 |
1216 AddUserRecord(active_user_); | 1240 AddUserRecord(active_user_); |
1217 | 1241 |
1218 GetUserImageManager(user_id)->UserLoggedIn(is_current_user_new_, false); | 1242 GetUserImageManager(user_id)->UserLoggedIn(is_current_user_new_, false); |
1219 | 1243 |
1220 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 1244 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
1221 | 1245 |
1222 // Make sure that new data is persisted to Local State. | 1246 // Make sure that new data is persisted to Local State. |
1223 g_browser_process->local_state()->CommitPendingWrite(); | 1247 g_browser_process->local_state()->CommitPendingWrite(); |
1224 } | 1248 } |
1225 | 1249 |
1226 void UserManagerImpl::RegularUserLoggedInAsEphemeral( | 1250 void UserManagerImpl::RegularUserLoggedInAsEphemeral( |
1227 const std::string& user_id) { | 1251 const std::string& user_id) { |
1228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1229 is_current_user_new_ = true; | 1253 is_current_user_new_ = true; |
1230 is_current_user_ephemeral_regular_user_ = true; | 1254 is_current_user_ephemeral_regular_user_ = true; |
1231 active_user_ = User::CreateRegularUser(user_id); | 1255 active_user_ = user_manager::User::CreateRegularUser(user_id); |
1232 GetUserImageManager(user_id)->UserLoggedIn(is_current_user_new_, false); | 1256 GetUserImageManager(user_id)->UserLoggedIn(is_current_user_new_, false); |
1233 WallpaperManager::Get()->SetUserWallpaperNow(user_id); | 1257 WallpaperManager::Get()->SetUserWallpaperNow(user_id); |
1234 } | 1258 } |
1235 | 1259 |
1236 void UserManagerImpl::SupervisedUserLoggedIn( | 1260 void UserManagerImpl::SupervisedUserLoggedIn( |
1237 const std::string& user_id) { | 1261 const std::string& user_id) { |
1238 // TODO(nkostylev): Refactor, share code with RegularUserLoggedIn(). | 1262 // TODO(nkostylev): Refactor, share code with RegularUserLoggedIn(). |
1239 | 1263 |
1240 // Remove the user from the user list. | 1264 // Remove the user from the user list. |
1241 active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); | 1265 active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); |
1242 // If the user was not found on the user list, create a new user. | 1266 // If the user was not found on the user list, create a new user. |
1243 if (!active_user_) { | 1267 if (!active_user_) { |
1244 is_current_user_new_ = true; | 1268 is_current_user_new_ = true; |
1245 active_user_ = User::CreateSupervisedUser(user_id); | 1269 active_user_ = user_manager::User::CreateSupervisedUser(user_id); |
1246 // Leaving OAuth token status at the default state = unknown. | 1270 // Leaving OAuth token status at the default state = unknown. |
1247 WallpaperManager::Get()->SetUserWallpaperNow(user_id); | 1271 WallpaperManager::Get()->SetUserWallpaperNow(user_id); |
1248 } else { | 1272 } else { |
1249 if (supervised_user_manager_->CheckForFirstRun(user_id)) { | 1273 if (supervised_user_manager_->CheckForFirstRun(user_id)) { |
1250 is_current_user_new_ = true; | 1274 is_current_user_new_ = true; |
1251 WallpaperManager::Get()->SetUserWallpaperNow(user_id); | 1275 WallpaperManager::Get()->SetUserWallpaperNow(user_id); |
1252 } else { | 1276 } else { |
1253 is_current_user_new_ = false; | 1277 is_current_user_new_ = false; |
1254 } | 1278 } |
1255 } | 1279 } |
(...skipping 10 matching lines...) Expand all Loading... |
1266 active_user_->GetDisplayName()); | 1290 active_user_->GetDisplayName()); |
1267 } | 1291 } |
1268 | 1292 |
1269 GetUserImageManager(user_id)->UserLoggedIn(is_current_user_new_, true); | 1293 GetUserImageManager(user_id)->UserLoggedIn(is_current_user_new_, true); |
1270 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 1294 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
1271 | 1295 |
1272 // Make sure that new data is persisted to Local State. | 1296 // Make sure that new data is persisted to Local State. |
1273 g_browser_process->local_state()->CommitPendingWrite(); | 1297 g_browser_process->local_state()->CommitPendingWrite(); |
1274 } | 1298 } |
1275 | 1299 |
1276 void UserManagerImpl::PublicAccountUserLoggedIn(User* user) { | 1300 void UserManagerImpl::PublicAccountUserLoggedIn(user_manager::User* user) { |
1277 is_current_user_new_ = true; | 1301 is_current_user_new_ = true; |
1278 active_user_ = user; | 1302 active_user_ = user; |
1279 // The UserImageManager chooses a random avatar picture when a user logs in | 1303 // The UserImageManager chooses a random avatar picture when a user logs in |
1280 // for the first time. Tell the UserImageManager that this user is not new to | 1304 // for the first time. Tell the UserImageManager that this user is not new to |
1281 // prevent the avatar from getting changed. | 1305 // prevent the avatar from getting changed. |
1282 GetUserImageManager(user->email())->UserLoggedIn(false, true); | 1306 GetUserImageManager(user->email())->UserLoggedIn(false, true); |
1283 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 1307 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
1284 } | 1308 } |
1285 | 1309 |
1286 void UserManagerImpl::KioskAppLoggedIn(const std::string& app_id) { | 1310 void UserManagerImpl::KioskAppLoggedIn(const std::string& app_id) { |
1287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1288 policy::DeviceLocalAccount::Type device_local_account_type; | 1312 policy::DeviceLocalAccount::Type device_local_account_type; |
1289 DCHECK(policy::IsDeviceLocalAccountUser(app_id, | 1313 DCHECK(policy::IsDeviceLocalAccountUser(app_id, |
1290 &device_local_account_type)); | 1314 &device_local_account_type)); |
1291 DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP, | 1315 DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP, |
1292 device_local_account_type); | 1316 device_local_account_type); |
1293 | 1317 |
1294 active_user_ = User::CreateKioskAppUser(app_id); | 1318 active_user_ = user_manager::User::CreateKioskAppUser(app_id); |
1295 active_user_->SetStubImage(User::kInvalidImageIndex, false); | 1319 active_user_->SetStubImage( |
| 1320 user_manager::UserImage( |
| 1321 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 1322 IDR_PROFILE_PICTURE_LOADING)), |
| 1323 user_manager::User::USER_IMAGE_INVALID, |
| 1324 false); |
1296 | 1325 |
1297 WallpaperManager::Get()->SetUserWallpaperNow(app_id); | 1326 WallpaperManager::Get()->SetUserWallpaperNow(app_id); |
1298 | 1327 |
1299 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like | 1328 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like |
1300 // the kiosk_app_id in these objects, removing the need to re-parse the | 1329 // the kiosk_app_id in these objects, removing the need to re-parse the |
1301 // device-local account list here to extract the kiosk_app_id. | 1330 // device-local account list here to extract the kiosk_app_id. |
1302 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 1331 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
1303 policy::GetDeviceLocalAccounts(cros_settings_); | 1332 policy::GetDeviceLocalAccounts(cros_settings_); |
1304 const policy::DeviceLocalAccount* account = NULL; | 1333 const policy::DeviceLocalAccount* account = NULL; |
1305 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 1334 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
(...skipping 17 matching lines...) Expand all Loading... |
1323 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); | 1352 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); |
1324 | 1353 |
1325 // Disable window animation since kiosk app runs in a single full screen | 1354 // Disable window animation since kiosk app runs in a single full screen |
1326 // window and window animation causes start-up janks. | 1355 // window and window animation causes start-up janks. |
1327 command_line->AppendSwitch( | 1356 command_line->AppendSwitch( |
1328 wm::switches::kWindowAnimationsDisabled); | 1357 wm::switches::kWindowAnimationsDisabled); |
1329 } | 1358 } |
1330 | 1359 |
1331 void UserManagerImpl::DemoAccountLoggedIn() { | 1360 void UserManagerImpl::DemoAccountLoggedIn() { |
1332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1333 active_user_ = User::CreateKioskAppUser(DemoAppLauncher::kDemoUserName); | 1362 active_user_ = |
1334 active_user_->SetStubImage(User::kInvalidImageIndex, false); | 1363 user_manager::User::CreateKioskAppUser(DemoAppLauncher::kDemoUserName); |
| 1364 active_user_->SetStubImage( |
| 1365 user_manager::UserImage( |
| 1366 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 1367 IDR_PROFILE_PICTURE_LOADING)), |
| 1368 user_manager::User::USER_IMAGE_INVALID, |
| 1369 false); |
1335 WallpaperManager::Get()->SetUserWallpaperNow(DemoAppLauncher::kDemoUserName); | 1370 WallpaperManager::Get()->SetUserWallpaperNow(DemoAppLauncher::kDemoUserName); |
1336 | 1371 |
1337 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1372 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1338 command_line->AppendSwitch(::switches::kForceAppMode); | 1373 command_line->AppendSwitch(::switches::kForceAppMode); |
1339 command_line->AppendSwitchASCII(::switches::kAppId, | 1374 command_line->AppendSwitchASCII(::switches::kAppId, |
1340 DemoAppLauncher::kDemoAppId); | 1375 DemoAppLauncher::kDemoAppId); |
1341 | 1376 |
1342 // Disable window animation since the demo app runs in a single full screen | 1377 // Disable window animation since the demo app runs in a single full screen |
1343 // window and window animation causes start-up janks. | 1378 // window and window animation causes start-up janks. |
1344 CommandLine::ForCurrentProcess()->AppendSwitch( | 1379 CommandLine::ForCurrentProcess()->AppendSwitch( |
1345 wm::switches::kWindowAnimationsDisabled); | 1380 wm::switches::kWindowAnimationsDisabled); |
1346 } | 1381 } |
1347 | 1382 |
1348 void UserManagerImpl::RetailModeUserLoggedIn() { | 1383 void UserManagerImpl::RetailModeUserLoggedIn() { |
1349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1350 is_current_user_new_ = true; | 1385 is_current_user_new_ = true; |
1351 active_user_ = User::CreateRetailModeUser(); | 1386 active_user_ = user_manager::User::CreateRetailModeUser(); |
1352 GetUserImageManager(chromeos::login::kRetailModeUserName) | 1387 GetUserImageManager(chromeos::login::kRetailModeUserName) |
1353 ->UserLoggedIn(is_current_user_new_, true); | 1388 ->UserLoggedIn(is_current_user_new_, true); |
1354 WallpaperManager::Get()->SetUserWallpaperNow( | 1389 WallpaperManager::Get()->SetUserWallpaperNow( |
1355 chromeos::login::kRetailModeUserName); | 1390 chromeos::login::kRetailModeUserName); |
1356 } | 1391 } |
1357 | 1392 |
1358 void UserManagerImpl::NotifyOnLogin() { | 1393 void UserManagerImpl::NotifyOnLogin() { |
1359 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1394 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1360 | 1395 |
1361 UserSessionManager::OverrideHomedir(); | 1396 UserSessionManager::OverrideHomedir(); |
1362 | 1397 |
1363 UpdateNumberOfUsers(); | 1398 UpdateNumberOfUsers(); |
1364 NotifyActiveUserHashChanged(active_user_->username_hash()); | 1399 NotifyActiveUserHashChanged(active_user_->username_hash()); |
1365 NotifyActiveUserChanged(active_user_); | 1400 NotifyActiveUserChanged(active_user_); |
1366 UpdateLoginState(); | 1401 UpdateLoginState(); |
1367 | 1402 |
1368 // TODO(nkostylev): Deprecate this notification in favor of | 1403 // TODO(nkostylev): Deprecate this notification in favor of |
1369 // ActiveUserChanged() observer call. | 1404 // ActiveUserChanged() observer call. |
1370 content::NotificationService::current()->Notify( | 1405 content::NotificationService::current()->Notify( |
1371 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 1406 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
1372 content::Source<UserManager>(this), | 1407 content::Source<UserManager>(this), |
1373 content::Details<const User>(active_user_)); | 1408 content::Details<const user_manager::User>(active_user_)); |
1374 | 1409 |
1375 UserSessionManager::GetInstance()->PerformPostUserLoggedInActions(); | 1410 UserSessionManager::GetInstance()->PerformPostUserLoggedInActions(); |
1376 } | 1411 } |
1377 | 1412 |
1378 User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus( | 1413 user_manager::User::OAuthTokenStatus UserManagerImpl::LoadUserOAuthStatus( |
1379 const std::string& user_id) const { | 1414 const std::string& user_id) const { |
1380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1381 | 1416 |
1382 PrefService* local_state = g_browser_process->local_state(); | 1417 PrefService* local_state = g_browser_process->local_state(); |
1383 const base::DictionaryValue* prefs_oauth_status = | 1418 const base::DictionaryValue* prefs_oauth_status = |
1384 local_state->GetDictionary(kUserOAuthTokenStatus); | 1419 local_state->GetDictionary(kUserOAuthTokenStatus); |
1385 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; | 1420 int oauth_token_status = user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN; |
1386 if (prefs_oauth_status && | 1421 if (prefs_oauth_status && |
1387 prefs_oauth_status->GetIntegerWithoutPathExpansion( | 1422 prefs_oauth_status->GetIntegerWithoutPathExpansion( |
1388 user_id, &oauth_token_status)) { | 1423 user_id, &oauth_token_status)) { |
1389 User::OAuthTokenStatus result = | 1424 user_manager::User::OAuthTokenStatus result = |
1390 static_cast<User::OAuthTokenStatus>(oauth_token_status); | 1425 static_cast<user_manager::User::OAuthTokenStatus>(oauth_token_status); |
1391 if (result == User::OAUTH2_TOKEN_STATUS_INVALID) | 1426 if (result == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) |
1392 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(result); | 1427 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(result); |
1393 return result; | 1428 return result; |
1394 } | 1429 } |
1395 return User::OAUTH_TOKEN_STATUS_UNKNOWN; | 1430 return user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN; |
1396 } | 1431 } |
1397 | 1432 |
1398 bool UserManagerImpl::LoadForceOnlineSignin(const std::string& user_id) const { | 1433 bool UserManagerImpl::LoadForceOnlineSignin(const std::string& user_id) const { |
1399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1400 | 1435 |
1401 PrefService* local_state = g_browser_process->local_state(); | 1436 PrefService* local_state = g_browser_process->local_state(); |
1402 const base::DictionaryValue* prefs_force_online = | 1437 const base::DictionaryValue* prefs_force_online = |
1403 local_state->GetDictionary(kUserForceOnlineSignin); | 1438 local_state->GetDictionary(kUserForceOnlineSignin); |
1404 bool force_online_signin = false; | 1439 bool force_online_signin = false; |
1405 if (prefs_force_online) { | 1440 if (prefs_force_online) { |
(...skipping 28 matching lines...) Expand all Loading... |
1434 prefs_oauth_update->RemoveWithoutPathExpansion(user_id, NULL); | 1469 prefs_oauth_update->RemoveWithoutPathExpansion(user_id, NULL); |
1435 | 1470 |
1436 DictionaryPrefUpdate prefs_force_online_update(prefs, kUserForceOnlineSignin); | 1471 DictionaryPrefUpdate prefs_force_online_update(prefs, kUserForceOnlineSignin); |
1437 prefs_force_online_update->RemoveWithoutPathExpansion(user_id, NULL); | 1472 prefs_force_online_update->RemoveWithoutPathExpansion(user_id, NULL); |
1438 | 1473 |
1439 supervised_user_manager_->RemoveNonCryptohomeData(user_id); | 1474 supervised_user_manager_->RemoveNonCryptohomeData(user_id); |
1440 | 1475 |
1441 multi_profile_user_controller_->RemoveCachedValues(user_id); | 1476 multi_profile_user_controller_->RemoveCachedValues(user_id); |
1442 } | 1477 } |
1443 | 1478 |
1444 User* UserManagerImpl::RemoveRegularOrSupervisedUserFromList( | 1479 user_manager::User* UserManagerImpl::RemoveRegularOrSupervisedUserFromList( |
1445 const std::string& user_id) { | 1480 const std::string& user_id) { |
1446 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), | 1481 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), |
1447 kRegularUsers); | 1482 kRegularUsers); |
1448 prefs_users_update->Clear(); | 1483 prefs_users_update->Clear(); |
1449 User* user = NULL; | 1484 user_manager::User* user = NULL; |
1450 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { | 1485 for (user_manager::UserList::iterator it = users_.begin(); |
| 1486 it != users_.end();) { |
1451 const std::string user_email = (*it)->email(); | 1487 const std::string user_email = (*it)->email(); |
1452 if (user_email == user_id) { | 1488 if (user_email == user_id) { |
1453 user = *it; | 1489 user = *it; |
1454 it = users_.erase(it); | 1490 it = users_.erase(it); |
1455 } else { | 1491 } else { |
1456 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR || | 1492 if ((*it)->GetType() == user_manager::USER_TYPE_REGULAR || |
1457 (*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) { | 1493 (*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) { |
1458 prefs_users_update->Append(new base::StringValue(user_email)); | 1494 prefs_users_update->Append(new base::StringValue(user_email)); |
1459 } | 1495 } |
1460 ++it; | 1496 ++it; |
(...skipping 12 matching lines...) Expand all Loading... |
1473 return; | 1509 return; |
1474 } | 1510 } |
1475 | 1511 |
1476 RemoveNonCryptohomeData(public_account_pending_data_removal); | 1512 RemoveNonCryptohomeData(public_account_pending_data_removal); |
1477 local_state->ClearPref(kPublicAccountPendingDataRemoval); | 1513 local_state->ClearPref(kPublicAccountPendingDataRemoval); |
1478 } | 1514 } |
1479 | 1515 |
1480 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeData( | 1516 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeData( |
1481 const std::vector<std::string>& old_public_accounts) { | 1517 const std::vector<std::string>& old_public_accounts) { |
1482 std::set<std::string> users; | 1518 std::set<std::string> users; |
1483 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) | 1519 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 1520 it != users_.end(); |
| 1521 ++it) |
1484 users.insert((*it)->email()); | 1522 users.insert((*it)->email()); |
1485 | 1523 |
1486 // If the user is logged into a public account that has been removed from the | 1524 // If the user is logged into a public account that has been removed from the |
1487 // user list, mark the account's data as pending removal after logout. | 1525 // user list, mark the account's data as pending removal after logout. |
1488 if (IsLoggedInAsPublicAccount()) { | 1526 if (IsLoggedInAsPublicAccount()) { |
1489 const std::string active_user_id = GetActiveUser()->email(); | 1527 const std::string active_user_id = GetActiveUser()->email(); |
1490 if (users.find(active_user_id) == users.end()) { | 1528 if (users.find(active_user_id) == users.end()) { |
1491 g_browser_process->local_state()->SetString( | 1529 g_browser_process->local_state()->SetString( |
1492 kPublicAccountPendingDataRemoval, active_user_id); | 1530 kPublicAccountPendingDataRemoval, active_user_id); |
1493 users.insert(active_user_id); | 1531 users.insert(active_user_id); |
(...skipping 10 matching lines...) Expand all Loading... |
1504 } | 1542 } |
1505 } | 1543 } |
1506 | 1544 |
1507 bool UserManagerImpl::UpdateAndCleanUpPublicAccounts( | 1545 bool UserManagerImpl::UpdateAndCleanUpPublicAccounts( |
1508 const std::vector<policy::DeviceLocalAccount>& device_local_accounts) { | 1546 const std::vector<policy::DeviceLocalAccount>& device_local_accounts) { |
1509 // Try to remove any public account data marked as pending removal. | 1547 // Try to remove any public account data marked as pending removal. |
1510 CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); | 1548 CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); |
1511 | 1549 |
1512 // Get the current list of public accounts. | 1550 // Get the current list of public accounts. |
1513 std::vector<std::string> old_public_accounts; | 1551 std::vector<std::string> old_public_accounts; |
1514 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { | 1552 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 1553 it != users_.end(); |
| 1554 ++it) { |
1515 if ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 1555 if ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
1516 old_public_accounts.push_back((*it)->email()); | 1556 old_public_accounts.push_back((*it)->email()); |
1517 } | 1557 } |
1518 | 1558 |
1519 // Get the new list of public accounts from policy. | 1559 // Get the new list of public accounts from policy. |
1520 std::vector<std::string> new_public_accounts; | 1560 std::vector<std::string> new_public_accounts; |
1521 for (std::vector<policy::DeviceLocalAccount>::const_iterator it = | 1561 for (std::vector<policy::DeviceLocalAccount>::const_iterator it = |
1522 device_local_accounts.begin(); | 1562 device_local_accounts.begin(); |
1523 it != device_local_accounts.end(); ++it) { | 1563 it != device_local_accounts.end(); ++it) { |
1524 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the | 1564 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the |
(...skipping 19 matching lines...) Expand all Loading... |
1544 ListPrefUpdate prefs_public_accounts_update(g_browser_process->local_state(), | 1584 ListPrefUpdate prefs_public_accounts_update(g_browser_process->local_state(), |
1545 kPublicAccounts); | 1585 kPublicAccounts); |
1546 prefs_public_accounts_update->Clear(); | 1586 prefs_public_accounts_update->Clear(); |
1547 for (std::vector<std::string>::const_iterator it = | 1587 for (std::vector<std::string>::const_iterator it = |
1548 new_public_accounts.begin(); | 1588 new_public_accounts.begin(); |
1549 it != new_public_accounts.end(); ++it) { | 1589 it != new_public_accounts.end(); ++it) { |
1550 prefs_public_accounts_update->AppendString(*it); | 1590 prefs_public_accounts_update->AppendString(*it); |
1551 } | 1591 } |
1552 | 1592 |
1553 // Remove the old public accounts from the user list. | 1593 // Remove the old public accounts from the user list. |
1554 for (UserList::iterator it = users_.begin(); it != users_.end();) { | 1594 for (user_manager::UserList::iterator it = users_.begin(); |
| 1595 it != users_.end();) { |
1555 if ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 1596 if ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
1556 if (*it != GetLoggedInUser()) | 1597 if (*it != GetLoggedInUser()) |
1557 DeleteUser(*it); | 1598 DeleteUser(*it); |
1558 it = users_.erase(it); | 1599 it = users_.erase(it); |
1559 } else { | 1600 } else { |
1560 ++it; | 1601 ++it; |
1561 } | 1602 } |
1562 } | 1603 } |
1563 | 1604 |
1564 // Add the new public accounts to the front of the user list. | 1605 // Add the new public accounts to the front of the user list. |
1565 for (std::vector<std::string>::const_reverse_iterator it = | 1606 for (std::vector<std::string>::const_reverse_iterator it = |
1566 new_public_accounts.rbegin(); | 1607 new_public_accounts.rbegin(); |
1567 it != new_public_accounts.rend(); ++it) { | 1608 it != new_public_accounts.rend(); ++it) { |
1568 if (IsLoggedInAsPublicAccount() && *it == GetActiveUser()->email()) | 1609 if (IsLoggedInAsPublicAccount() && *it == GetActiveUser()->email()) |
1569 users_.insert(users_.begin(), GetLoggedInUser()); | 1610 users_.insert(users_.begin(), GetLoggedInUser()); |
1570 else | 1611 else |
1571 users_.insert(users_.begin(), User::CreatePublicAccountUser(*it)); | 1612 users_.insert(users_.begin(), |
| 1613 user_manager::User::CreatePublicAccountUser(*it)); |
1572 UpdatePublicAccountDisplayName(*it); | 1614 UpdatePublicAccountDisplayName(*it); |
1573 } | 1615 } |
1574 | 1616 |
1575 for (UserList::iterator ui = users_.begin(), | 1617 for (user_manager::UserList::iterator |
1576 ue = users_.begin() + new_public_accounts.size(); | 1618 ui = users_.begin(), |
1577 ui != ue; ++ui) { | 1619 ue = users_.begin() + new_public_accounts.size(); |
| 1620 ui != ue; |
| 1621 ++ui) { |
1578 GetUserImageManager((*ui)->email())->LoadUserImage(); | 1622 GetUserImageManager((*ui)->email())->LoadUserImage(); |
1579 } | 1623 } |
1580 | 1624 |
1581 // Remove data belonging to public accounts that are no longer found on the | 1625 // Remove data belonging to public accounts that are no longer found on the |
1582 // user list. | 1626 // user list. |
1583 CleanUpPublicAccountNonCryptohomeData(old_public_accounts); | 1627 CleanUpPublicAccountNonCryptohomeData(old_public_accounts); |
1584 | 1628 |
1585 return true; | 1629 return true; |
1586 } | 1630 } |
1587 | 1631 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 return default_flow_.get(); | 1688 return default_flow_.get(); |
1645 } | 1689 } |
1646 | 1690 |
1647 void UserManagerImpl::NotifyUserListChanged() { | 1691 void UserManagerImpl::NotifyUserListChanged() { |
1648 content::NotificationService::current()->Notify( | 1692 content::NotificationService::current()->Notify( |
1649 chrome::NOTIFICATION_USER_LIST_CHANGED, | 1693 chrome::NOTIFICATION_USER_LIST_CHANGED, |
1650 content::Source<UserManager>(this), | 1694 content::Source<UserManager>(this), |
1651 content::NotificationService::NoDetails()); | 1695 content::NotificationService::NoDetails()); |
1652 } | 1696 } |
1653 | 1697 |
1654 void UserManagerImpl::NotifyActiveUserChanged(const User* active_user) { | 1698 void UserManagerImpl::NotifyActiveUserChanged( |
| 1699 const user_manager::User* active_user) { |
1655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1700 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1656 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, | 1701 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, |
1657 session_state_observer_list_, | 1702 session_state_observer_list_, |
1658 ActiveUserChanged(active_user)); | 1703 ActiveUserChanged(active_user)); |
1659 } | 1704 } |
1660 | 1705 |
1661 void UserManagerImpl::NotifyUserAddedToSession(const User* added_user) { | 1706 void UserManagerImpl::NotifyUserAddedToSession( |
| 1707 const user_manager::User* added_user) { |
1662 UpdateNumberOfUsers(); | 1708 UpdateNumberOfUsers(); |
1663 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1664 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, | 1710 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, |
1665 session_state_observer_list_, | 1711 session_state_observer_list_, |
1666 UserAddedToSession(added_user)); | 1712 UserAddedToSession(added_user)); |
1667 } | 1713 } |
1668 | 1714 |
1669 void UserManagerImpl::NotifyActiveUserHashChanged(const std::string& hash) { | 1715 void UserManagerImpl::NotifyActiveUserHashChanged(const std::string& hash) { |
1670 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1716 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1671 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, | 1717 FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver, |
(...skipping 27 matching lines...) Expand all Loading... |
1699 login_user_type = LoginState::LOGGED_IN_USER_REGULAR; | 1745 login_user_type = LoginState::LOGGED_IN_USER_REGULAR; |
1700 | 1746 |
1701 if (primary_user_) { | 1747 if (primary_user_) { |
1702 LoginState::Get()->SetLoggedInStateAndPrimaryUser( | 1748 LoginState::Get()->SetLoggedInStateAndPrimaryUser( |
1703 logged_in_state, login_user_type, primary_user_->username_hash()); | 1749 logged_in_state, login_user_type, primary_user_->username_hash()); |
1704 } else { | 1750 } else { |
1705 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); | 1751 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); |
1706 } | 1752 } |
1707 } | 1753 } |
1708 | 1754 |
1709 void UserManagerImpl::SetLRUUser(User* user) { | 1755 void UserManagerImpl::SetLRUUser(user_manager::User* user) { |
1710 UserList::iterator it = std::find(lru_logged_in_users_.begin(), | 1756 user_manager::UserList::iterator it = |
1711 lru_logged_in_users_.end(), | 1757 std::find(lru_logged_in_users_.begin(), lru_logged_in_users_.end(), user); |
1712 user); | |
1713 if (it != lru_logged_in_users_.end()) | 1758 if (it != lru_logged_in_users_.end()) |
1714 lru_logged_in_users_.erase(it); | 1759 lru_logged_in_users_.erase(it); |
1715 lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user); | 1760 lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user); |
1716 } | 1761 } |
1717 | 1762 |
1718 void UserManagerImpl::SendRegularUserLoginMetrics(const std::string& user_id) { | 1763 void UserManagerImpl::SendRegularUserLoginMetrics(const std::string& user_id) { |
1719 // If this isn't the first time Chrome was run after the system booted, | 1764 // If this isn't the first time Chrome was run after the system booted, |
1720 // assume that Chrome was restarted because a previous session ended. | 1765 // assume that Chrome was restarted because a previous session ended. |
1721 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1766 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1722 switches::kFirstExecAfterBoot)) { | 1767 switches::kFirstExecAfterBoot)) { |
(...skipping 26 matching lines...) Expand all Loading... |
1749 base::Unretained(this), | 1794 base::Unretained(this), |
1750 user_id))); | 1795 user_id))); |
1751 } else { | 1796 } else { |
1752 DoUpdateAccountLocale(user_id, locale); | 1797 DoUpdateAccountLocale(user_id, locale); |
1753 } | 1798 } |
1754 } | 1799 } |
1755 | 1800 |
1756 void UserManagerImpl::DoUpdateAccountLocale( | 1801 void UserManagerImpl::DoUpdateAccountLocale( |
1757 const std::string& user_id, | 1802 const std::string& user_id, |
1758 const std::string& resolved_locale) { | 1803 const std::string& resolved_locale) { |
1759 if (User* user = FindUserAndModify(user_id)) | 1804 if (user_manager::User* user = FindUserAndModify(user_id)) |
1760 user->SetAccountLocale(resolved_locale); | 1805 user->SetAccountLocale(resolved_locale); |
1761 } | 1806 } |
1762 | 1807 |
1763 void UserManagerImpl::UpdateNumberOfUsers() { | 1808 void UserManagerImpl::UpdateNumberOfUsers() { |
1764 size_t users = GetLoggedInUsers().size(); | 1809 size_t users = GetLoggedInUsers().size(); |
1765 if (users) { | 1810 if (users) { |
1766 // Write the user number as UMA stat when a multi user session is possible. | 1811 // Write the user number as UMA stat when a multi user session is possible. |
1767 if ((users + GetUsersAdmittedForMultiProfile().size()) > 1) | 1812 if ((users + GetUsersAdmittedForMultiProfile().size()) > 1) |
1768 ash::MultiProfileUMA::RecordUserCount(users); | 1813 ash::MultiProfileUMA::RecordUserCount(users); |
1769 } | 1814 } |
1770 | 1815 |
1771 base::debug::SetCrashKeyValue(crash_keys::kNumberOfUsers, | 1816 base::debug::SetCrashKeyValue(crash_keys::kNumberOfUsers, |
1772 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); | 1817 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); |
1773 } | 1818 } |
1774 | 1819 |
1775 void UserManagerImpl::DeleteUser(User* user) { | 1820 void UserManagerImpl::DeleteUser(user_manager::User* user) { |
1776 const bool is_active_user = (user == active_user_); | 1821 const bool is_active_user = (user == active_user_); |
1777 delete user; | 1822 delete user; |
1778 if (is_active_user) | 1823 if (is_active_user) |
1779 active_user_ = NULL; | 1824 active_user_ = NULL; |
1780 } | 1825 } |
1781 | 1826 |
1782 } // namespace chromeos | 1827 } // namespace chromeos |
OLD | NEW |