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

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

Powered by Google App Engine
This is Rietveld 408576698