OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/fake_chrome_user_manager.h" | 5 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 user_manager::User* FakeChromeUserManager::AddArcKioskAppUser( | 96 user_manager::User* FakeChromeUserManager::AddArcKioskAppUser( |
97 const AccountId& account_id) { | 97 const AccountId& account_id) { |
98 user_manager::User* user = | 98 user_manager::User* user = |
99 user_manager::User::CreateArcKioskAppUser(account_id); | 99 user_manager::User::CreateArcKioskAppUser(account_id); |
100 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( | 100 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( |
101 account_id.GetUserEmail())); | 101 account_id.GetUserEmail())); |
102 users_.push_back(user); | 102 users_.push_back(user); |
103 return user; | 103 return user; |
104 } | 104 } |
105 | 105 |
| 106 user_manager::User* FakeChromeUserManager::AddSupervisedUser( |
| 107 const AccountId& account_id) { |
| 108 user_manager::User* user = |
| 109 user_manager::User::CreateSupervisedUser(account_id); |
| 110 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( |
| 111 account_id.GetUserEmail())); |
| 112 users_.push_back(user); |
| 113 return user; |
| 114 } |
| 115 |
106 const user_manager::User* FakeChromeUserManager::AddPublicAccountUser( | 116 const user_manager::User* FakeChromeUserManager::AddPublicAccountUser( |
107 const AccountId& account_id) { | 117 const AccountId& account_id) { |
108 user_manager::User* user = | 118 user_manager::User* user = |
109 user_manager::User::CreatePublicAccountUser(account_id); | 119 user_manager::User::CreatePublicAccountUser(account_id); |
110 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( | 120 user->set_username_hash(ProfileHelper::GetUserIdHashByUserIdForTesting( |
111 account_id.GetUserEmail())); | 121 account_id.GetUserEmail())); |
112 user->SetStubImage(base::MakeUnique<user_manager::UserImage>( | 122 user->SetStubImage(base::MakeUnique<user_manager::UserImage>( |
113 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 123 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
114 IDR_PROFILE_PICTURE_LOADING)), | 124 IDR_PROFILE_PICTURE_LOADING)), |
115 user_manager::User::USER_IMAGE_PROFILE, false); | 125 user_manager::User::USER_IMAGE_PROFILE, false); |
116 users_.push_back(user); | 126 users_.push_back(user); |
117 chromeos::ProfileHelper::Get()->SetProfileToUserMappingForTesting(user); | 127 chromeos::ProfileHelper::Get()->SetProfileToUserMappingForTesting(user); |
118 return user; | 128 return user; |
119 } | 129 } |
120 | 130 |
121 bool FakeChromeUserManager::AreEphemeralUsersEnabled() const { | 131 bool FakeChromeUserManager::AreEphemeralUsersEnabled() const { |
122 return fake_ephemeral_users_enabled_; | 132 return fake_ephemeral_users_enabled_; |
123 } | 133 } |
124 | 134 |
125 void FakeChromeUserManager::LoginUser(const AccountId& account_id) { | 135 void FakeChromeUserManager::LoginUser(const AccountId& account_id) { |
126 UserLoggedIn(account_id, ProfileHelper::GetUserIdHashByUserIdForTesting( | 136 UserLoggedIn(account_id, ProfileHelper::GetUserIdHashByUserIdForTesting( |
127 account_id.GetUserEmail()), | 137 account_id.GetUserEmail()), |
128 false /* browser_restart */); | 138 false /* browser_restart */); |
| 139 |
| 140 // NOTE: This does not match production. See function comment. |
| 141 for (auto* user : users_) { |
| 142 if (user->GetAccountId() == account_id) { |
| 143 user->set_profile_is_created(); |
| 144 break; |
| 145 } |
| 146 } |
129 } | 147 } |
130 | 148 |
131 BootstrapManager* FakeChromeUserManager::GetBootstrapManager() { | 149 BootstrapManager* FakeChromeUserManager::GetBootstrapManager() { |
132 return bootstrap_manager_; | 150 return bootstrap_manager_; |
133 } | 151 } |
134 | 152 |
135 MultiProfileUserController* | 153 MultiProfileUserController* |
136 FakeChromeUserManager::GetMultiProfileUserController() { | 154 FakeChromeUserManager::GetMultiProfileUserController() { |
137 return multi_profile_user_controller_; | 155 return multi_profile_user_controller_; |
138 } | 156 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 user_manager::UserList FakeChromeUserManager::GetUnlockUsers() const { | 381 user_manager::UserList FakeChromeUserManager::GetUnlockUsers() const { |
364 return users_; | 382 return users_; |
365 } | 383 } |
366 | 384 |
367 void FakeChromeUserManager::UserLoggedIn(const AccountId& account_id, | 385 void FakeChromeUserManager::UserLoggedIn(const AccountId& account_id, |
368 const std::string& username_hash, | 386 const std::string& username_hash, |
369 bool browser_restart) { | 387 bool browser_restart) { |
370 for (auto* user : users_) { | 388 for (auto* user : users_) { |
371 if (user->username_hash() == username_hash) { | 389 if (user->username_hash() == username_hash) { |
372 user->set_is_logged_in(true); | 390 user->set_is_logged_in(true); |
373 user->set_profile_is_created(); | |
374 logged_in_users_.push_back(user); | 391 logged_in_users_.push_back(user); |
375 | 392 |
376 if (!primary_user_) | 393 if (!primary_user_) |
377 primary_user_ = user; | 394 primary_user_ = user; |
378 break; | 395 break; |
379 } | 396 } |
380 } | 397 } |
| 398 // TODO(jamescook): This should set active_user_ and call NotifyOnLogin(). |
381 } | 399 } |
382 | 400 |
383 void FakeChromeUserManager::SwitchToLastActiveUser() { | 401 void FakeChromeUserManager::SwitchToLastActiveUser() { |
384 NOTREACHED(); | 402 NOTREACHED(); |
385 } | 403 } |
386 | 404 |
387 bool FakeChromeUserManager::IsKnownUser(const AccountId& account_id) const { | 405 bool FakeChromeUserManager::IsKnownUser(const AccountId& account_id) const { |
388 return true; | 406 return true; |
389 } | 407 } |
390 | 408 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 if (active_account_id_.is_valid()) { | 649 if (active_account_id_.is_valid()) { |
632 for (auto* user : users_) { | 650 for (auto* user : users_) { |
633 if (user->GetAccountId() == active_account_id_) | 651 if (user->GetAccountId() == active_account_id_) |
634 return user; | 652 return user; |
635 } | 653 } |
636 } | 654 } |
637 return users_[0]; | 655 return users_[0]; |
638 } | 656 } |
639 | 657 |
640 } // namespace chromeos | 658 } // namespace chromeos |
OLD | NEW |