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/screens/user_selection_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/strings/utf_string_conversions.h" | |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/browser_process_platform_part.h" | 20 #include "chrome/browser/browser_process_platform_part.h" |
20 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 21 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
21 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" | 22 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" |
22 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" | 23 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
23 #include "chrome/browser/chromeos/login/reauth_stats.h" | 24 #include "chrome/browser/chromeos/login/reauth_stats.h" |
24 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 25 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
25 #include "chrome/browser/chromeos/login/ui/views/user_board_view.h" | 26 #include "chrome/browser/chromeos/login/ui/views/user_board_view.h" |
26 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 27 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
27 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 28 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 29 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
29 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 30 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
30 #include "chrome/browser/signin/easy_unlock_service.h" | 31 #include "chrome/browser/signin/easy_unlock_service.h" |
31 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 32 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
32 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 33 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
33 #include "chrome/grit/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
35 #include "chrome/grit/theme_resources.h" | |
34 #include "chromeos/chromeos_switches.h" | 36 #include "chromeos/chromeos_switches.h" |
35 #include "chromeos/cryptohome/cryptohome_parameters.h" | 37 #include "chromeos/cryptohome/cryptohome_parameters.h" |
36 #include "chromeos/dbus/cryptohome_client.h" | 38 #include "chromeos/dbus/cryptohome_client.h" |
37 #include "chromeos/dbus/dbus_method_call_status.h" | 39 #include "chromeos/dbus/dbus_method_call_status.h" |
38 #include "chromeos/dbus/dbus_thread_manager.h" | 40 #include "chromeos/dbus/dbus_thread_manager.h" |
39 #include "components/arc/arc_util.h" | 41 #include "components/arc/arc_util.h" |
40 #include "components/prefs/pref_service.h" | 42 #include "components/prefs/pref_service.h" |
41 #include "components/proximity_auth/screenlock_bridge.h" | 43 #include "components/proximity_auth/screenlock_bridge.h" |
42 #include "components/signin/core/account_id/account_id.h" | 44 #include "components/signin/core/account_id/account_id.h" |
43 #include "components/user_manager/known_user.h" | 45 #include "components/user_manager/known_user.h" |
44 #include "components/user_manager/user_manager.h" | 46 #include "components/user_manager/user_manager.h" |
45 #include "components/user_manager/user_type.h" | 47 #include "components/user_manager/user_type.h" |
46 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
49 #include "ui/base/resource/resource_bundle.h" | |
47 #include "ui/base/user_activity/user_activity_detector.h" | 50 #include "ui/base/user_activity/user_activity_detector.h" |
48 | 51 |
49 namespace chromeos { | 52 namespace chromeos { |
50 | 53 |
51 namespace { | 54 namespace { |
52 | 55 |
53 // User dictionary keys. | 56 // User dictionary keys. |
54 const char kKeyUsername[] = "username"; | 57 const char kKeyUsername[] = "username"; |
55 const char kKeyGaiaID[] = "gaiaId"; | 58 const char kKeyGaiaID[] = "gaiaId"; |
56 const char kKeyDisplayName[] = "displayName"; | 59 const char kKeyDisplayName[] = "displayName"; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 recommended_locales.size() >= 2); | 126 recommended_locales.size() >= 2); |
124 | 127 |
125 // Set |kKeyInitialKeyboardLayout| to the current keyboard layout. This | 128 // Set |kKeyInitialKeyboardLayout| to the current keyboard layout. This |
126 // value will be used temporarily only because the UI immediately requests a | 129 // value will be used temporarily only because the UI immediately requests a |
127 // list of keyboard layouts suitable for the currently selected locale. | 130 // list of keyboard layouts suitable for the currently selected locale. |
128 user_dict->Set(kKeyInitialKeyboardLayout, GetCurrentKeyboardLayout()); | 131 user_dict->Set(kKeyInitialKeyboardLayout, GetCurrentKeyboardLayout()); |
129 } | 132 } |
130 | 133 |
131 // Returns true if the fingerprint icon should be displayed for the given | 134 // Returns true if the fingerprint icon should be displayed for the given |
132 // |user|. | 135 // |user|. |
133 bool AllowFingerprintForUser(user_manager::User* user) { | 136 bool AllowFingerprintForUser(const user_manager::User* user) { |
134 if (!user->is_logged_in()) | 137 if (!user->is_logged_in()) |
135 return false; | 138 return false; |
136 | 139 |
137 quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 140 quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
138 quick_unlock::QuickUnlockFactory::GetForUser(user); | 141 quick_unlock::QuickUnlockFactory::GetForUser(user); |
139 if (!quick_unlock_storage) | 142 if (!quick_unlock_storage) |
140 return false; | 143 return false; |
141 | 144 |
142 return quick_unlock_storage->IsFingerprintAuthenticationAvailable(); | 145 return quick_unlock_storage->IsFingerprintAuthenticationAvailable(); |
143 } | 146 } |
144 | 147 |
145 // Returns true if dircrypto migration check should be performed. | 148 // Returns true if dircrypto migration check should be performed. |
146 bool ShouldCheckNeedDircryptoMigration() { | 149 bool ShouldCheckNeedDircryptoMigration() { |
147 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 150 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
148 switches::kDisableEncryptionMigration) && | 151 switches::kDisableEncryptionMigration) && |
149 arc::IsArcAvailable(); | 152 arc::IsArcAvailable(); |
150 } | 153 } |
151 | 154 |
152 // Returns true if the user can run ARC based on the user type. | 155 // Returns true if the user can run ARC based on the user type. |
153 bool IsUserAllowedForARC(const AccountId& account_id) { | 156 bool IsUserAllowedForARC(const AccountId& account_id) { |
154 return user_manager::UserManager::IsInitialized() && | 157 return user_manager::UserManager::IsInitialized() && |
155 arc::IsArcAllowedForUser( | 158 arc::IsArcAllowedForUser( |
156 user_manager::UserManager::Get()->FindUser(account_id)); | 159 user_manager::UserManager::Get()->FindUser(account_id)); |
157 } | 160 } |
158 | 161 |
162 AccountId GetOwnerAccountId() { | |
163 std::string owner_email; | |
164 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, | |
165 &owner_email); | |
166 const AccountId owner = user_manager::known_user::GetAccountId( | |
167 owner_email, std::string() /* id */, AccountType::UNKNOWN); | |
168 return owner; | |
169 } | |
170 | |
171 bool IsEnterpriseManaged() { | |
172 policy::BrowserPolicyConnectorChromeOS* connector = | |
173 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
174 return connector->IsEnterpriseManaged(); | |
175 } | |
176 | |
177 bool IsSigninToAdd() { | |
178 return LoginDisplayHost::default_host() && | |
179 user_manager::UserManager::Get()->IsUserLoggedIn(); | |
180 } | |
181 | |
182 bool CanRemoveUser(bool is_single_user, const user_manager::User* user) { | |
183 // Single user check here is necessary because owner info might not be | |
184 // available when running into login screen on first boot. | |
185 // See http://crosbug.com/12723 | |
186 if (is_single_user && !IsEnterpriseManaged()) | |
187 return false; | |
188 if (!user->GetAccountId().is_valid()) | |
189 return false; | |
190 if (user->GetAccountId() == GetOwnerAccountId()) | |
191 return false; | |
192 if (user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT || | |
193 user->is_logged_in() || IsSigninToAdd()) | |
194 return false; | |
195 | |
196 return true; | |
197 } | |
198 | |
199 void GetMultiProfilePolicy(const user_manager::User* user, | |
200 bool* out_is_allowed, | |
201 std::string* out_policy) { | |
202 const std::string& user_id = user->GetAccountId().GetUserEmail(); | |
203 MultiProfileUserController* multi_profile_user_controller = | |
204 ChromeUserManager::Get()->GetMultiProfileUserController(); | |
205 MultiProfileUserController::UserAllowedInSessionReason is_user_allowed_reason; | |
206 *out_is_allowed = multi_profile_user_controller->IsUserAllowedInSession( | |
207 user_id, &is_user_allowed_reason); | |
208 switch (is_user_allowed_reason) { | |
209 case MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY: | |
jdufault
2017/06/14 02:20:42
An if/else is probably simpler.
xiaoyinh(OOO Sep 11-29)
2017/06/15 18:39:37
Done.
| |
210 *out_policy = MultiProfileUserController::kBehaviorOwnerPrimaryOnly; | |
211 break; | |
212 default: | |
213 *out_policy = multi_profile_user_controller->GetCachedValue(user_id); | |
jdufault
2017/06/14 02:20:42
nit: break
xiaoyinh(OOO Sep 11-29)
2017/06/15 18:39:37
Changed to if/else.
| |
214 } | |
215 } | |
216 | |
159 } // namespace | 217 } // namespace |
160 | 218 |
161 // Helper class to call cryptohome to check whether a user needs dircrypto | 219 // Helper class to call cryptohome to check whether a user needs dircrypto |
162 // migration. The check results are cached to limit calls to cryptohome. | 220 // migration. The check results are cached to limit calls to cryptohome. |
163 class UserSelectionScreen::DircryptoMigrationChecker { | 221 class UserSelectionScreen::DircryptoMigrationChecker { |
164 public: | 222 public: |
165 explicit DircryptoMigrationChecker(UserSelectionScreen* owner) | 223 explicit DircryptoMigrationChecker(UserSelectionScreen* owner) |
166 : owner_(owner), weak_ptr_factory_(this) {} | 224 : owner_(owner), weak_ptr_factory_(this) {} |
167 ~DircryptoMigrationChecker() = default; | 225 ~DircryptoMigrationChecker() = default; |
168 | 226 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 if (user_manager::known_user::FindGaiaID(user->GetAccountId(), &gaia_id)) { | 370 if (user_manager::known_user::FindGaiaID(user->GetAccountId(), &gaia_id)) { |
313 user_dict->SetString(kKeyGaiaID, gaia_id); | 371 user_dict->SetString(kKeyGaiaID, gaia_id); |
314 } | 372 } |
315 } | 373 } |
316 | 374 |
317 // static | 375 // static |
318 void UserSelectionScreen::FillMultiProfileUserPrefs( | 376 void UserSelectionScreen::FillMultiProfileUserPrefs( |
319 user_manager::User* user, | 377 user_manager::User* user, |
320 base::DictionaryValue* user_dict, | 378 base::DictionaryValue* user_dict, |
321 bool is_signin_to_add) { | 379 bool is_signin_to_add) { |
322 const std::string& user_id = user->GetAccountId().GetUserEmail(); | 380 if (!is_signin_to_add) { |
381 user_dict->SetBoolean(kKeyMultiProfilesAllowed, true); | |
382 return; | |
383 } | |
323 | 384 |
324 if (is_signin_to_add) { | 385 bool is_user_allowed; |
325 MultiProfileUserController* multi_profile_user_controller = | 386 std::string policy; |
326 ChromeUserManager::Get()->GetMultiProfileUserController(); | 387 GetMultiProfilePolicy(user, &is_user_allowed, &policy); |
327 MultiProfileUserController::UserAllowedInSessionReason isUserAllowedReason; | 388 user_dict->SetBoolean(kKeyMultiProfilesAllowed, is_user_allowed); |
328 bool isUserAllowed = multi_profile_user_controller->IsUserAllowedInSession( | 389 user_dict->SetString(kKeyMultiProfilesPolicy, policy); |
329 user_id, &isUserAllowedReason); | |
330 user_dict->SetBoolean(kKeyMultiProfilesAllowed, isUserAllowed); | |
331 | |
332 std::string behavior; | |
333 switch (isUserAllowedReason) { | |
334 case MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY: | |
335 behavior = MultiProfileUserController::kBehaviorOwnerPrimaryOnly; | |
336 break; | |
337 default: | |
338 behavior = multi_profile_user_controller->GetCachedValue(user_id); | |
339 } | |
340 user_dict->SetString(kKeyMultiProfilesPolicy, behavior); | |
341 } else { | |
342 user_dict->SetBoolean(kKeyMultiProfilesAllowed, true); | |
343 } | |
344 } | 390 } |
345 | 391 |
346 // static | 392 // static |
347 bool UserSelectionScreen::ShouldForceOnlineSignIn( | 393 bool UserSelectionScreen::ShouldForceOnlineSignIn( |
348 const user_manager::User* user) { | 394 const user_manager::User* user) { |
349 // Public sessions are always allowed to log in offline. | 395 // Public sessions are always allowed to log in offline. |
350 // Supervised users are always allowed to log in offline. | 396 // Supervised users are always allowed to log in offline. |
351 // For all other users, force online sign in if: | 397 // For all other users, force online sign in if: |
352 // * The flag to force online sign-in is set for the user. | 398 // * The flag to force online sign-in is set for the user. |
353 // * The user's OAuth token is invalid or unknown. | 399 // * The user's OAuth token is invalid or unknown. |
(...skipping 23 matching lines...) Expand all Loading... | |
377 // We need to force an online signin if the user is marked as requiring it, | 423 // We need to force an online signin if the user is marked as requiring it, |
378 // or if the user's session never completed initialization (still need to | 424 // or if the user's session never completed initialization (still need to |
379 // check for policy/management state) or if there's an invalid OAUTH token | 425 // check for policy/management state) or if there's an invalid OAUTH token |
380 // that needs to be refreshed. | 426 // that needs to be refreshed. |
381 return user->force_online_signin() || !user->profile_ever_initialized() || | 427 return user->force_online_signin() || !user->profile_ever_initialized() || |
382 (has_gaia_account && | 428 (has_gaia_account && |
383 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID || | 429 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID || |
384 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN)); | 430 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN)); |
385 } | 431 } |
386 | 432 |
433 // static | |
434 void UserSelectionScreen::FillUserMojoStruct( | |
435 const user_manager::User* user, | |
436 bool is_owner, | |
437 bool is_signin_to_add, | |
438 AuthType auth_type, | |
439 ash::mojom::LoginUserInfo* user_info) { | |
440 user_info->basic_user_info = ash::mojom::UserInfo::New(); | |
441 user_info->basic_user_info->type = user->GetType(); | |
442 user_info->basic_user_info->account_id = user->GetAccountId(); | |
443 user_info->basic_user_info->display_name = | |
444 base::UTF16ToUTF8(user->GetDisplayName()); | |
445 user_info->basic_user_info->display_email = user->display_email(); | |
446 user_info->basic_user_info->avatar = user->GetImage(); | |
447 if (user_info->basic_user_info->avatar.isNull()) { | |
448 user_info->basic_user_info->avatar = | |
449 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
450 IDR_PROFILE_PICTURE_LOADING); | |
451 } | |
452 user_info->is_desktop_user = false; | |
453 user_info->auth_type = static_cast<ash::mojom::AuthType>(auth_type); | |
454 user_info->is_signed_in = user->is_logged_in(); | |
455 user_info->is_owner = is_owner; | |
456 user_info->allow_fingerprint_unlock = AllowFingerprintForUser(user); | |
457 | |
458 // Fill multi-profile data. | |
459 if (!is_signin_to_add) { | |
460 user_info->is_multiprofile_allowed = true; | |
461 } else { | |
462 bool is_user_allowed; | |
463 std::string policy; | |
464 GetMultiProfilePolicy(user, &is_user_allowed, &policy); | |
465 user_info->is_multiprofile_allowed = is_user_allowed; | |
jdufault
2017/06/14 02:20:42
Instead of using temporaries just write directly t
xiaoyinh(OOO Sep 11-29)
2017/06/15 18:39:37
Done.
| |
466 user_info->multiprofile_policy = policy; | |
467 } | |
468 } | |
469 | |
387 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { | 470 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { |
388 handler_ = handler; | 471 handler_ = handler; |
389 | 472 |
390 if (handler_) { | 473 if (handler_) { |
391 // Forcibly refresh all of the user images, as the |handler_| instance may | 474 // Forcibly refresh all of the user images, as the |handler_| instance may |
392 // have been reused. | 475 // have been reused. |
393 for (user_manager::User* user : users_) | 476 for (user_manager::User* user : users_) |
394 handler_->OnUserImageChanged(*user); | 477 handler_->OnUserImageChanged(*user); |
395 } | 478 } |
396 } | 479 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 users_to_send.erase(users_to_send.begin() + kMaxUsers); | 558 users_to_send.erase(users_to_send.begin() + kMaxUsers); |
476 } else if (users_to_send.size() < kMaxUsers) { | 559 } else if (users_to_send.size() < kMaxUsers) { |
477 users_to_send.push_back(*it); | 560 users_to_send.push_back(*it); |
478 } | 561 } |
479 } | 562 } |
480 } | 563 } |
481 return users_to_send; | 564 return users_to_send; |
482 } | 565 } |
483 | 566 |
484 void UserSelectionScreen::SendUserList() { | 567 void UserSelectionScreen::SendUserList() { |
485 std::unique_ptr<base::ListValue> users_list = PrepareUserList(); | 568 std::unique_ptr<base::ListValue> users_list = UpdateAndReturnUserList(); |
486 handler_->LoadUsers(users_to_send_, *users_list); | 569 handler_->LoadUsers(users_to_send_, *users_list); |
487 } | 570 } |
488 | 571 |
489 void UserSelectionScreen::HandleGetUsers() { | 572 void UserSelectionScreen::HandleGetUsers() { |
490 SendUserList(); | 573 SendUserList(); |
491 } | 574 } |
492 | 575 |
493 void UserSelectionScreen::CheckUserStatus(const AccountId& account_id) { | 576 void UserSelectionScreen::CheckUserStatus(const AccountId& account_id) { |
494 // No checks on lock screen. | 577 // No checks on lock screen. |
495 if (ScreenLocker::default_screen_locker()) | 578 if (ScreenLocker::default_screen_locker()) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 service->AttemptAuth(account_id); | 702 service->AttemptAuth(account_id); |
620 } | 703 } |
621 | 704 |
622 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) { | 705 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) { |
623 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); | 706 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); |
624 if (!service) | 707 if (!service) |
625 return; | 708 return; |
626 service->RecordClickOnLockIcon(); | 709 service->RecordClickOnLockIcon(); |
627 } | 710 } |
628 | 711 |
629 std::unique_ptr<base::ListValue> UserSelectionScreen::PrepareUserList() { | 712 std::unique_ptr<base::ListValue> |
713 UserSelectionScreen::UpdateAndReturnUserList() { | |
630 std::unique_ptr<base::ListValue> users_list = | 714 std::unique_ptr<base::ListValue> users_list = |
631 base::MakeUnique<base::ListValue>(); | 715 base::MakeUnique<base::ListValue>(); |
632 | 716 |
633 // TODO(nkostylev): Move to a separate method in UserManager. | 717 // TODO(nkostylev): Move to a separate method in UserManager. |
634 // http://crbug.com/230852 | 718 // http://crbug.com/230852 |
635 bool single_user = users_.size() == 1; | 719 const bool single_user = users_.size() == 1; |
636 bool is_signin_to_add = LoginDisplayHost::default_host() && | 720 const AccountId owner = GetOwnerAccountId(); |
637 user_manager::UserManager::Get()->IsUserLoggedIn(); | 721 const bool is_signin_to_add = IsSigninToAdd(); |
638 std::string owner_email; | |
639 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, | |
640 &owner_email); | |
641 const AccountId owner = user_manager::known_user::GetAccountId( | |
642 owner_email, std::string() /* id */, AccountType::UNKNOWN); | |
643 | |
644 policy::BrowserPolicyConnectorChromeOS* connector = | |
645 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
646 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | |
647 | 722 |
648 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); | 723 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); |
649 | 724 |
650 user_auth_type_map_.clear(); | 725 user_auth_type_map_.clear(); |
651 | 726 |
652 const std::vector<std::string> kEmptyRecommendedLocales; | 727 const std::vector<std::string> kEmptyRecommendedLocales; |
653 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); | 728 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); |
654 it != users_to_send_.end(); ++it) { | 729 it != users_to_send_.end(); ++it) { |
655 const AccountId& account_id = (*it)->GetAccountId(); | 730 const AccountId& account_id = (*it)->GetAccountId(); |
656 bool is_owner = (account_id == owner); | 731 bool is_owner = (account_id == owner); |
657 const bool is_public_account = | 732 const bool is_public_account = |
658 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 733 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
659 const AuthType initial_auth_type = | 734 const AuthType initial_auth_type = |
660 is_public_account ? EXPAND_THEN_USER_CLICK | 735 is_public_account ? EXPAND_THEN_USER_CLICK |
661 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN | 736 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN |
662 : OFFLINE_PASSWORD); | 737 : OFFLINE_PASSWORD); |
663 user_auth_type_map_[account_id] = initial_auth_type; | 738 user_auth_type_map_[account_id] = initial_auth_type; |
664 | 739 |
665 auto user_dict = base::MakeUnique<base::DictionaryValue>(); | 740 auto user_dict = base::MakeUnique<base::DictionaryValue>(); |
666 const std::vector<std::string>* public_session_recommended_locales = | 741 const std::vector<std::string>* public_session_recommended_locales = |
667 public_session_recommended_locales_.find(account_id) == | 742 public_session_recommended_locales_.find(account_id) == |
668 public_session_recommended_locales_.end() | 743 public_session_recommended_locales_.end() |
669 ? &kEmptyRecommendedLocales | 744 ? &kEmptyRecommendedLocales |
670 : &public_session_recommended_locales_[account_id]; | 745 : &public_session_recommended_locales_[account_id]; |
671 FillUserDictionary(*it, is_owner, is_signin_to_add, initial_auth_type, | 746 FillUserDictionary(*it, is_owner, is_signin_to_add, initial_auth_type, |
672 public_session_recommended_locales, user_dict.get()); | 747 public_session_recommended_locales, user_dict.get()); |
673 bool signed_in = (*it)->is_logged_in(); | 748 user_dict->SetBoolean(kKeyCanRemove, CanRemoveUser(single_user, *it)); |
674 | |
675 // Single user check here is necessary because owner info might not be | |
676 // available when running into login screen on first boot. | |
677 // See http://crosbug.com/12723 | |
678 bool can_remove_user = | |
679 ((!single_user || is_enterprise_managed) && account_id.is_valid() && | |
680 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); | |
681 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); | |
682 users_list->Append(std::move(user_dict)); | 749 users_list->Append(std::move(user_dict)); |
683 } | 750 } |
684 | 751 |
685 return users_list; | 752 return users_list; |
686 } | 753 } |
687 | 754 |
755 std::vector<ash::mojom::LoginUserInfoPtr> | |
756 UserSelectionScreen::UpdateAndReturnUserListForMojo() { | |
757 std::vector<ash::mojom::LoginUserInfoPtr> user_info_list; | |
758 | |
759 const bool single_user = users_.size() == 1; | |
760 const AccountId owner = GetOwnerAccountId(); | |
761 const bool is_signin_to_add = IsSigninToAdd(); | |
762 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); | |
763 | |
764 user_auth_type_map_.clear(); | |
765 | |
766 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); | |
767 it != users_to_send_.end(); ++it) { | |
768 const AccountId& account_id = (*it)->GetAccountId(); | |
769 bool is_owner = owner == account_id; | |
770 const bool is_public_account = | |
771 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | |
772 const AuthType initial_auth_type = | |
773 is_public_account ? EXPAND_THEN_USER_CLICK | |
774 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN | |
775 : OFFLINE_PASSWORD); | |
776 user_auth_type_map_[account_id] = initial_auth_type; | |
777 | |
778 ash::mojom::LoginUserInfoPtr login_user_info = | |
779 ash::mojom::LoginUserInfo::New(); | |
780 FillUserMojoStruct(*it, is_owner, is_signin_to_add, initial_auth_type, | |
781 login_user_info.get()); | |
782 login_user_info->can_remove = CanRemoveUser(single_user, *it); | |
783 user_info_list.push_back(std::move(login_user_info)); | |
784 } | |
785 | |
786 return user_info_list; | |
787 } | |
788 | |
688 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( | 789 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( |
689 const AccountId& account_id) const { | 790 const AccountId& account_id) const { |
690 if (GetScreenType() == OTHER_SCREEN) | 791 if (GetScreenType() == OTHER_SCREEN) |
691 return nullptr; | 792 return nullptr; |
692 | 793 |
693 const user_manager::User* unlock_user = nullptr; | 794 const user_manager::User* unlock_user = nullptr; |
694 for (const user_manager::User* user : users_) { | 795 for (const user_manager::User* user : users_) { |
695 if (user->GetAccountId() == account_id) { | 796 if (user->GetAccountId() == account_id) { |
696 unlock_user = user; | 797 unlock_user = user; |
697 break; | 798 break; |
698 } | 799 } |
699 } | 800 } |
700 if (!unlock_user) | 801 if (!unlock_user) |
701 return nullptr; | 802 return nullptr; |
702 | 803 |
703 ProfileHelper* profile_helper = ProfileHelper::Get(); | 804 ProfileHelper* profile_helper = ProfileHelper::Get(); |
704 Profile* profile = profile_helper->GetProfileByUser(unlock_user); | 805 Profile* profile = profile_helper->GetProfileByUser(unlock_user); |
705 | 806 |
706 // The user profile should exist if and only if this is the lock screen. | 807 // The user profile should exist if and only if this is the lock screen. |
707 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 808 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
708 | 809 |
709 if (!profile) | 810 if (!profile) |
710 profile = profile_helper->GetSigninProfile(); | 811 profile = profile_helper->GetSigninProfile(); |
711 | 812 |
712 return EasyUnlockService::Get(profile); | 813 return EasyUnlockService::Get(profile); |
713 } | 814 } |
714 | 815 |
715 } // namespace chromeos | 816 } // namespace chromeos |
OLD | NEW |