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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, user_manager::User* user) { | |
xiyuan
2017/06/13 18:00:18
nit: const user_manager::User*
xiaoyinh(OOO Sep 11-29)
2017/06/13 22:21:31
Done.
| |
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(user_manager::User* user, | |
xiyuan
2017/06/13 18:00:18
nit: const user_manager::User*
xiaoyinh(OOO Sep 11-29)
2017/06/13 22:21:31
Done.
| |
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 isUserAllowedReason; | |
xiyuan
2017/06/13 18:00:17
nit: isUserAllowedReason -> is_user_allowed_reason
xiaoyinh(OOO Sep 11-29)
2017/06/13 22:21:31
Done.
| |
206 *out_is_allowed = multi_profile_user_controller->IsUserAllowedInSession( | |
207 user_id, &isUserAllowedReason); | |
208 switch (isUserAllowedReason) { | |
209 case MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY: | |
210 *out_policy = MultiProfileUserController::kBehaviorOwnerPrimaryOnly; | |
211 break; | |
212 default: | |
213 *out_policy = multi_profile_user_controller->GetCachedValue(user_id); | |
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 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 FillMultiProfileUserPrefsInMojo(user, user_info, is_signin_to_add); | |
jdufault
2017/06/13 17:41:54
I think the existing code is structured like this
xiaoyinh(OOO Sep 11-29)
2017/06/13 22:21:31
Done.
| |
459 } | |
460 | |
461 // static | |
462 void UserSelectionScreen::FillMultiProfileUserPrefsInMojo( | |
463 user_manager::User* user, | |
464 ash::mojom::LoginUserInfo& user_info, | |
465 bool is_signin_to_add) { | |
466 if (!is_signin_to_add) { | |
467 user_info.is_multiprofile_allowed = true; | |
468 return; | |
469 } | |
470 | |
471 bool is_user_allowed; | |
472 std::string policy; | |
473 GetMultiProfilePolicy(user, &is_user_allowed, &policy); | |
474 user_info.is_multiprofile_allowed = is_user_allowed; | |
475 user_info.multiprofile_policy = policy; | |
476 } | |
477 | |
387 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { | 478 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { |
388 handler_ = handler; | 479 handler_ = handler; |
389 | 480 |
390 if (handler_) { | 481 if (handler_) { |
391 // Forcibly refresh all of the user images, as the |handler_| instance may | 482 // Forcibly refresh all of the user images, as the |handler_| instance may |
392 // have been reused. | 483 // have been reused. |
393 for (user_manager::User* user : users_) | 484 for (user_manager::User* user : users_) |
394 handler_->OnUserImageChanged(*user); | 485 handler_->OnUserImageChanged(*user); |
395 } | 486 } |
396 } | 487 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 service->RecordClickOnLockIcon(); | 717 service->RecordClickOnLockIcon(); |
627 } | 718 } |
628 | 719 |
629 std::unique_ptr<base::ListValue> UserSelectionScreen::PrepareUserList() { | 720 std::unique_ptr<base::ListValue> UserSelectionScreen::PrepareUserList() { |
630 std::unique_ptr<base::ListValue> users_list = | 721 std::unique_ptr<base::ListValue> users_list = |
631 base::MakeUnique<base::ListValue>(); | 722 base::MakeUnique<base::ListValue>(); |
632 | 723 |
633 // TODO(nkostylev): Move to a separate method in UserManager. | 724 // TODO(nkostylev): Move to a separate method in UserManager. |
634 // http://crbug.com/230852 | 725 // http://crbug.com/230852 |
635 bool single_user = users_.size() == 1; | 726 bool single_user = users_.size() == 1; |
636 bool is_signin_to_add = LoginDisplayHost::default_host() && | 727 AccountId owner = GetOwnerAccountId(); |
637 user_manager::UserManager::Get()->IsUserLoggedIn(); | 728 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 | 729 |
648 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); | 730 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); |
649 | 731 |
650 user_auth_type_map_.clear(); | 732 user_auth_type_map_.clear(); |
651 | 733 |
652 const std::vector<std::string> kEmptyRecommendedLocales; | 734 const std::vector<std::string> kEmptyRecommendedLocales; |
653 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); | 735 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); |
654 it != users_to_send_.end(); ++it) { | 736 it != users_to_send_.end(); ++it) { |
655 const AccountId& account_id = (*it)->GetAccountId(); | 737 const AccountId& account_id = (*it)->GetAccountId(); |
656 bool is_owner = (account_id == owner); | 738 bool is_owner = (account_id == owner); |
657 const bool is_public_account = | 739 const bool is_public_account = |
658 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 740 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
659 const AuthType initial_auth_type = | 741 const AuthType initial_auth_type = |
660 is_public_account ? EXPAND_THEN_USER_CLICK | 742 is_public_account ? EXPAND_THEN_USER_CLICK |
661 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN | 743 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN |
662 : OFFLINE_PASSWORD); | 744 : OFFLINE_PASSWORD); |
663 user_auth_type_map_[account_id] = initial_auth_type; | 745 user_auth_type_map_[account_id] = initial_auth_type; |
664 | 746 |
665 auto user_dict = base::MakeUnique<base::DictionaryValue>(); | 747 auto user_dict = base::MakeUnique<base::DictionaryValue>(); |
666 const std::vector<std::string>* public_session_recommended_locales = | 748 const std::vector<std::string>* public_session_recommended_locales = |
667 public_session_recommended_locales_.find(account_id) == | 749 public_session_recommended_locales_.find(account_id) == |
668 public_session_recommended_locales_.end() | 750 public_session_recommended_locales_.end() |
669 ? &kEmptyRecommendedLocales | 751 ? &kEmptyRecommendedLocales |
670 : &public_session_recommended_locales_[account_id]; | 752 : &public_session_recommended_locales_[account_id]; |
671 FillUserDictionary(*it, is_owner, is_signin_to_add, initial_auth_type, | 753 FillUserDictionary(*it, is_owner, is_signin_to_add, initial_auth_type, |
672 public_session_recommended_locales, user_dict.get()); | 754 public_session_recommended_locales, user_dict.get()); |
673 bool signed_in = (*it)->is_logged_in(); | 755 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)); | 756 users_list->Append(std::move(user_dict)); |
683 } | 757 } |
684 | 758 |
685 return users_list; | 759 return users_list; |
686 } | 760 } |
687 | 761 |
762 std::vector<ash::mojom::LoginUserInfoPtr> | |
763 UserSelectionScreen::PrepareUserListToMojo() { | |
764 std::vector<ash::mojom::LoginUserInfoPtr> user_info_list; | |
765 | |
766 bool single_user = users_.size() == 1; | |
xiyuan
2017/06/13 18:00:18
nit: Declare it as "const" since the rest of the f
xiaoyinh(OOO Sep 11-29)
2017/06/13 22:21:31
Done.
| |
767 AccountId owner = GetOwnerAccountId(); | |
768 bool is_signin_to_add = IsSigninToAdd(); | |
769 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); | |
770 | |
771 user_auth_type_map_.clear(); | |
jdufault
2017/06/13 17:41:54
:(, it is a bit unexpected that this method change
xiaoyinh(OOO Sep 11-29)
2017/06/13 22:21:31
Thanks! Both this and PrepareUserList will update
| |
772 | |
773 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); | |
774 it != users_to_send_.end(); ++it) { | |
775 const AccountId& account_id = (*it)->GetAccountId(); | |
776 bool is_owner = owner == account_id; | |
777 const bool is_public_account = | |
778 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | |
779 const AuthType initial_auth_type = | |
780 is_public_account ? EXPAND_THEN_USER_CLICK | |
781 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN | |
782 : OFFLINE_PASSWORD); | |
783 user_auth_type_map_[account_id] = initial_auth_type; | |
784 | |
785 ash::mojom::LoginUserInfoPtr login_user_info = | |
786 ash::mojom::LoginUserInfo::New(); | |
787 FillUserMojoStruct(*it, is_owner, is_signin_to_add, initial_auth_type, | |
788 *login_user_info); | |
789 login_user_info->can_remove = CanRemoveUser(single_user, *it); | |
790 user_info_list.push_back(std::move(login_user_info)); | |
791 } | |
792 | |
793 return user_info_list; | |
794 } | |
795 | |
688 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( | 796 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( |
689 const AccountId& account_id) const { | 797 const AccountId& account_id) const { |
690 if (GetScreenType() == OTHER_SCREEN) | 798 if (GetScreenType() == OTHER_SCREEN) |
691 return nullptr; | 799 return nullptr; |
692 | 800 |
693 const user_manager::User* unlock_user = nullptr; | 801 const user_manager::User* unlock_user = nullptr; |
694 for (const user_manager::User* user : users_) { | 802 for (const user_manager::User* user : users_) { |
695 if (user->GetAccountId() == account_id) { | 803 if (user->GetAccountId() == account_id) { |
696 unlock_user = user; | 804 unlock_user = user; |
697 break; | 805 break; |
698 } | 806 } |
699 } | 807 } |
700 if (!unlock_user) | 808 if (!unlock_user) |
701 return nullptr; | 809 return nullptr; |
702 | 810 |
703 ProfileHelper* profile_helper = ProfileHelper::Get(); | 811 ProfileHelper* profile_helper = ProfileHelper::Get(); |
704 Profile* profile = profile_helper->GetProfileByUser(unlock_user); | 812 Profile* profile = profile_helper->GetProfileByUser(unlock_user); |
705 | 813 |
706 // The user profile should exist if and only if this is the lock screen. | 814 // The user profile should exist if and only if this is the lock screen. |
707 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 815 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
708 | 816 |
709 if (!profile) | 817 if (!profile) |
710 profile = profile_helper->GetSigninProfile(); | 818 profile = profile_helper->GetSigninProfile(); |
711 | 819 |
712 return EasyUnlockService::Get(profile); | 820 return EasyUnlockService::Get(profile); |
713 } | 821 } |
714 | 822 |
715 } // namespace chromeos | 823 } // namespace chromeos |
OLD | NEW |