Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/chromeos/login/screens/user_selection_screen.cc

Issue 2937553002: Create Mojo Struct for user information used in login/lock screen. (Closed)
Patch Set: reuse enum defined in mojom file. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 MultiProfileUserBehavior* 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
209 std::string policy;
210 if (is_user_allowed_reason ==
211 MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) {
212 policy = MultiProfileUserController::kBehaviorOwnerPrimaryOnly;
213 } else {
214 policy = multi_profile_user_controller->GetCachedValue(user_id);
215 }
216 *out_policy = MultiProfileUserController::UserBehaviorStringToEnum(policy);
217 }
218
159 } // namespace 219 } // namespace
160 220
161 // Helper class to call cryptohome to check whether a user needs dircrypto 221 // Helper class to call cryptohome to check whether a user needs dircrypto
162 // migration. The check results are cached to limit calls to cryptohome. 222 // migration. The check results are cached to limit calls to cryptohome.
163 class UserSelectionScreen::DircryptoMigrationChecker { 223 class UserSelectionScreen::DircryptoMigrationChecker {
164 public: 224 public:
165 explicit DircryptoMigrationChecker(UserSelectionScreen* owner) 225 explicit DircryptoMigrationChecker(UserSelectionScreen* owner)
166 : owner_(owner), weak_ptr_factory_(this) {} 226 : owner_(owner), weak_ptr_factory_(this) {}
167 ~DircryptoMigrationChecker() = default; 227 ~DircryptoMigrationChecker() = default;
168 228
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (user_manager::known_user::FindGaiaID(user->GetAccountId(), &gaia_id)) { 372 if (user_manager::known_user::FindGaiaID(user->GetAccountId(), &gaia_id)) {
313 user_dict->SetString(kKeyGaiaID, gaia_id); 373 user_dict->SetString(kKeyGaiaID, gaia_id);
314 } 374 }
315 } 375 }
316 376
317 // static 377 // static
318 void UserSelectionScreen::FillMultiProfileUserPrefs( 378 void UserSelectionScreen::FillMultiProfileUserPrefs(
319 user_manager::User* user, 379 user_manager::User* user,
320 base::DictionaryValue* user_dict, 380 base::DictionaryValue* user_dict,
321 bool is_signin_to_add) { 381 bool is_signin_to_add) {
322 const std::string& user_id = user->GetAccountId().GetUserEmail(); 382 if (!is_signin_to_add) {
383 user_dict->SetBoolean(kKeyMultiProfilesAllowed, true);
384 return;
385 }
323 386
324 if (is_signin_to_add) { 387 bool is_user_allowed;
325 MultiProfileUserController* multi_profile_user_controller = 388 MultiProfileUserBehavior policy;
326 ChromeUserManager::Get()->GetMultiProfileUserController(); 389 GetMultiProfilePolicy(user, &is_user_allowed, &policy);
327 MultiProfileUserController::UserAllowedInSessionReason isUserAllowedReason; 390 user_dict->SetBoolean(kKeyMultiProfilesAllowed, is_user_allowed);
328 bool isUserAllowed = multi_profile_user_controller->IsUserAllowedInSession( 391 user_dict->SetInteger(kKeyMultiProfilesPolicy, static_cast<int>(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 MultiProfileUserController::MultiProfileUserBehavior user_behavior =
341 MultiProfileUserController::UserBehaviorStringToEnum(behavior);
342 user_dict->SetInteger(kKeyMultiProfilesPolicy,
343 static_cast<int>(user_behavior));
344 } else {
345 user_dict->SetBoolean(kKeyMultiProfilesAllowed, true);
346 }
347 } 392 }
348 393
349 // static 394 // static
350 bool UserSelectionScreen::ShouldForceOnlineSignIn( 395 bool UserSelectionScreen::ShouldForceOnlineSignIn(
351 const user_manager::User* user) { 396 const user_manager::User* user) {
352 // Public sessions are always allowed to log in offline. 397 // Public sessions are always allowed to log in offline.
353 // Supervised users are always allowed to log in offline. 398 // Supervised users are always allowed to log in offline.
354 // For all other users, force online sign in if: 399 // For all other users, force online sign in if:
355 // * The flag to force online sign-in is set for the user. 400 // * The flag to force online sign-in is set for the user.
356 // * The user's OAuth token is invalid or unknown. 401 // * The user's OAuth token is invalid or unknown.
(...skipping 23 matching lines...) Expand all
380 // We need to force an online signin if the user is marked as requiring it, 425 // We need to force an online signin if the user is marked as requiring it,
381 // or if the user's session never completed initialization (still need to 426 // or if the user's session never completed initialization (still need to
382 // check for policy/management state) or if there's an invalid OAUTH token 427 // check for policy/management state) or if there's an invalid OAUTH token
383 // that needs to be refreshed. 428 // that needs to be refreshed.
384 return user->force_online_signin() || !user->profile_ever_initialized() || 429 return user->force_online_signin() || !user->profile_ever_initialized() ||
385 (has_gaia_account && 430 (has_gaia_account &&
386 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID || 431 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID ||
387 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN)); 432 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN));
388 } 433 }
389 434
435 // static
436 void UserSelectionScreen::FillUserMojoStruct(
437 const user_manager::User* user,
438 bool is_owner,
439 bool is_signin_to_add,
440 AuthType auth_type,
441 ash::mojom::LoginUserInfo* user_info) {
442 user_info->basic_user_info = ash::mojom::UserInfo::New();
443 user_info->basic_user_info->type = user->GetType();
444 user_info->basic_user_info->account_id = user->GetAccountId();
445 user_info->basic_user_info->display_name =
446 base::UTF16ToUTF8(user->GetDisplayName());
447 user_info->basic_user_info->display_email = user->display_email();
448 user_info->basic_user_info->avatar = user->GetImage();
449 if (user_info->basic_user_info->avatar.isNull()) {
450 user_info->basic_user_info->avatar =
451 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
452 IDR_PROFILE_PICTURE_LOADING);
453 }
454 user_info->auth_type = static_cast<ash::mojom::AuthType>(auth_type);
455 user_info->is_signed_in = user->is_logged_in();
456 user_info->is_device_owner = is_owner;
457 user_info->allow_fingerprint_unlock = AllowFingerprintForUser(user);
458
459 // Fill multi-profile data.
460 if (!is_signin_to_add) {
461 user_info->is_multiprofile_allowed = true;
462 } else {
463 GetMultiProfilePolicy(user, &user_info->is_multiprofile_allowed,
464 &user_info->multiprofile_policy);
465 }
466 }
467
390 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { 468 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) {
391 handler_ = handler; 469 handler_ = handler;
392 470
393 if (handler_) { 471 if (handler_) {
394 // Forcibly refresh all of the user images, as the |handler_| instance may 472 // Forcibly refresh all of the user images, as the |handler_| instance may
395 // have been reused. 473 // have been reused.
396 for (user_manager::User* user : users_) 474 for (user_manager::User* user : users_)
397 handler_->OnUserImageChanged(*user); 475 handler_->OnUserImageChanged(*user);
398 } 476 }
399 } 477 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 users_to_send.erase(users_to_send.begin() + kMaxUsers); 556 users_to_send.erase(users_to_send.begin() + kMaxUsers);
479 } else if (users_to_send.size() < kMaxUsers) { 557 } else if (users_to_send.size() < kMaxUsers) {
480 users_to_send.push_back(*it); 558 users_to_send.push_back(*it);
481 } 559 }
482 } 560 }
483 } 561 }
484 return users_to_send; 562 return users_to_send;
485 } 563 }
486 564
487 void UserSelectionScreen::SendUserList() { 565 void UserSelectionScreen::SendUserList() {
488 std::unique_ptr<base::ListValue> users_list = PrepareUserList(); 566 std::unique_ptr<base::ListValue> users_list =
567 UpdateAndReturnUserListForWebUI();
489 handler_->LoadUsers(users_to_send_, *users_list); 568 handler_->LoadUsers(users_to_send_, *users_list);
490 } 569 }
491 570
492 void UserSelectionScreen::HandleGetUsers() { 571 void UserSelectionScreen::HandleGetUsers() {
493 SendUserList(); 572 SendUserList();
494 } 573 }
495 574
496 void UserSelectionScreen::CheckUserStatus(const AccountId& account_id) { 575 void UserSelectionScreen::CheckUserStatus(const AccountId& account_id) {
497 // No checks on lock screen. 576 // No checks on lock screen.
498 if (ScreenLocker::default_screen_locker()) 577 if (ScreenLocker::default_screen_locker())
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 service->AttemptAuth(account_id); 701 service->AttemptAuth(account_id);
623 } 702 }
624 703
625 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) { 704 void UserSelectionScreen::RecordClickOnLockIcon(const AccountId& account_id) {
626 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id); 705 EasyUnlockService* service = GetEasyUnlockServiceForUser(account_id);
627 if (!service) 706 if (!service)
628 return; 707 return;
629 service->RecordClickOnLockIcon(); 708 service->RecordClickOnLockIcon();
630 } 709 }
631 710
632 std::unique_ptr<base::ListValue> UserSelectionScreen::PrepareUserList() { 711 std::unique_ptr<base::ListValue>
712 UserSelectionScreen::UpdateAndReturnUserListForWebUI() {
633 std::unique_ptr<base::ListValue> users_list = 713 std::unique_ptr<base::ListValue> users_list =
634 base::MakeUnique<base::ListValue>(); 714 base::MakeUnique<base::ListValue>();
635 715
636 // TODO(nkostylev): Move to a separate method in UserManager. 716 // TODO(nkostylev): Move to a separate method in UserManager.
637 // http://crbug.com/230852 717 // http://crbug.com/230852
638 bool single_user = users_.size() == 1; 718 const bool single_user = users_.size() == 1;
639 bool is_signin_to_add = LoginDisplayHost::default_host() && 719 const AccountId owner = GetOwnerAccountId();
640 user_manager::UserManager::Get()->IsUserLoggedIn(); 720 const bool is_signin_to_add = IsSigninToAdd();
641 std::string owner_email;
642 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner,
643 &owner_email);
644 const AccountId owner = user_manager::known_user::GetAccountId(
645 owner_email, std::string() /* id */, AccountType::UNKNOWN);
646
647 policy::BrowserPolicyConnectorChromeOS* connector =
648 g_browser_process->platform_part()->browser_policy_connector_chromeos();
649 bool is_enterprise_managed = connector->IsEnterpriseManaged();
650 721
651 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add); 722 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add);
652 723
653 user_auth_type_map_.clear(); 724 user_auth_type_map_.clear();
654 725
655 const std::vector<std::string> kEmptyRecommendedLocales; 726 const std::vector<std::string> kEmptyRecommendedLocales;
656 for (user_manager::UserList::const_iterator it = users_to_send_.begin(); 727 for (user_manager::UserList::const_iterator it = users_to_send_.begin();
657 it != users_to_send_.end(); ++it) { 728 it != users_to_send_.end(); ++it) {
658 const AccountId& account_id = (*it)->GetAccountId(); 729 const AccountId& account_id = (*it)->GetAccountId();
659 bool is_owner = (account_id == owner); 730 bool is_owner = (account_id == owner);
660 const bool is_public_account = 731 const bool is_public_account =
661 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); 732 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
662 const AuthType initial_auth_type = 733 const AuthType initial_auth_type =
663 is_public_account ? EXPAND_THEN_USER_CLICK 734 is_public_account ? EXPAND_THEN_USER_CLICK
664 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN 735 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN
665 : OFFLINE_PASSWORD); 736 : OFFLINE_PASSWORD);
666 user_auth_type_map_[account_id] = initial_auth_type; 737 user_auth_type_map_[account_id] = initial_auth_type;
667 738
668 auto user_dict = base::MakeUnique<base::DictionaryValue>(); 739 auto user_dict = base::MakeUnique<base::DictionaryValue>();
669 const std::vector<std::string>* public_session_recommended_locales = 740 const std::vector<std::string>* public_session_recommended_locales =
670 public_session_recommended_locales_.find(account_id) == 741 public_session_recommended_locales_.find(account_id) ==
671 public_session_recommended_locales_.end() 742 public_session_recommended_locales_.end()
672 ? &kEmptyRecommendedLocales 743 ? &kEmptyRecommendedLocales
673 : &public_session_recommended_locales_[account_id]; 744 : &public_session_recommended_locales_[account_id];
674 FillUserDictionary(*it, is_owner, is_signin_to_add, initial_auth_type, 745 FillUserDictionary(*it, is_owner, is_signin_to_add, initial_auth_type,
675 public_session_recommended_locales, user_dict.get()); 746 public_session_recommended_locales, user_dict.get());
676 bool signed_in = (*it)->is_logged_in(); 747 user_dict->SetBoolean(kKeyCanRemove, CanRemoveUser(single_user, *it));
677
678 // Single user check here is necessary because owner info might not be
679 // available when running into login screen on first boot.
680 // See http://crosbug.com/12723
681 bool can_remove_user =
682 ((!single_user || is_enterprise_managed) && account_id.is_valid() &&
683 !is_owner && !is_public_account && !signed_in && !is_signin_to_add);
684 user_dict->SetBoolean(kKeyCanRemove, can_remove_user);
685 users_list->Append(std::move(user_dict)); 748 users_list->Append(std::move(user_dict));
686 } 749 }
687 750
688 return users_list; 751 return users_list;
689 } 752 }
690 753
754 std::vector<ash::mojom::LoginUserInfoPtr>
755 UserSelectionScreen::UpdateAndReturnUserListForMojo() {
756 std::vector<ash::mojom::LoginUserInfoPtr> user_info_list;
757
758 const bool single_user = users_.size() == 1;
759 const AccountId owner = GetOwnerAccountId();
760 const bool is_signin_to_add = IsSigninToAdd();
761 users_to_send_ = PrepareUserListForSending(users_, owner, is_signin_to_add);
762
763 user_auth_type_map_.clear();
764
765 for (user_manager::UserList::const_iterator it = users_to_send_.begin();
766 it != users_to_send_.end(); ++it) {
767 const AccountId& account_id = (*it)->GetAccountId();
768 bool is_owner = owner == account_id;
769 const bool is_public_account =
770 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT);
771 const AuthType initial_auth_type =
772 is_public_account ? EXPAND_THEN_USER_CLICK
773 : (ShouldForceOnlineSignIn(*it) ? ONLINE_SIGN_IN
774 : OFFLINE_PASSWORD);
775 user_auth_type_map_[account_id] = initial_auth_type;
776
777 ash::mojom::LoginUserInfoPtr login_user_info =
778 ash::mojom::LoginUserInfo::New();
779 FillUserMojoStruct(*it, is_owner, is_signin_to_add, initial_auth_type,
780 login_user_info.get());
781 login_user_info->can_remove = CanRemoveUser(single_user, *it);
782 user_info_list.push_back(std::move(login_user_info));
783 }
784
785 return user_info_list;
786 }
787
691 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser( 788 EasyUnlockService* UserSelectionScreen::GetEasyUnlockServiceForUser(
692 const AccountId& account_id) const { 789 const AccountId& account_id) const {
693 if (GetScreenType() == OTHER_SCREEN) 790 if (GetScreenType() == OTHER_SCREEN)
694 return nullptr; 791 return nullptr;
695 792
696 const user_manager::User* unlock_user = nullptr; 793 const user_manager::User* unlock_user = nullptr;
697 for (const user_manager::User* user : users_) { 794 for (const user_manager::User* user : users_) {
698 if (user->GetAccountId() == account_id) { 795 if (user->GetAccountId() == account_id) {
699 unlock_user = user; 796 unlock_user = user;
700 break; 797 break;
701 } 798 }
702 } 799 }
703 if (!unlock_user) 800 if (!unlock_user)
704 return nullptr; 801 return nullptr;
705 802
706 ProfileHelper* profile_helper = ProfileHelper::Get(); 803 ProfileHelper* profile_helper = ProfileHelper::Get();
707 Profile* profile = profile_helper->GetProfileByUser(unlock_user); 804 Profile* profile = profile_helper->GetProfileByUser(unlock_user);
708 805
709 // The user profile should exist if and only if this is the lock screen. 806 // The user profile should exist if and only if this is the lock screen.
710 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); 807 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN);
711 808
712 if (!profile) 809 if (!profile)
713 profile = profile_helper->GetSigninProfile(); 810 profile = profile_helper->GetSigninProfile();
714 811
715 return EasyUnlockService::Get(profile); 812 return EasyUnlockService::Get(profile);
716 } 813 }
717 814
718 } // namespace chromeos 815 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698