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 "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browser_process_platform_part.h" | 12 #include "chrome/browser/browser_process_platform_part.h" |
13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
14 #include "chrome/browser/chromeos/login/reauth_stats.h" | 14 #include "chrome/browser/chromeos/login/reauth_stats.h" |
15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 15 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
16 #include "chrome/browser/chromeos/login/ui/views/user_board_view.h" | 16 #include "chrome/browser/chromeos/login/ui/views/user_board_view.h" |
17 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 17 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
18 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 18 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
21 #include "chrome/browser/signin/easy_unlock_service.h" | 21 #include "chrome/browser/signin/easy_unlock_service.h" |
22 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 22 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
23 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 23 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
24 #include "components/proximity_auth/screenlock_bridge.h" | 24 #include "components/proximity_auth/screenlock_bridge.h" |
25 #include "components/user_manager/user_id.h" | 25 #include "components/signin/core/account_id/account_id.h" |
26 #include "components/user_manager/user_manager.h" | 26 #include "components/user_manager/user_manager.h" |
27 #include "components/user_manager/user_type.h" | 27 #include "components/user_manager/user_type.h" |
28 #include "ui/base/user_activity/user_activity_detector.h" | 28 #include "ui/base/user_activity/user_activity_detector.h" |
29 | 29 |
30 namespace chromeos { | 30 namespace chromeos { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // User dictionary keys. | 34 // User dictionary keys. |
35 const char kKeyUsername[] = "username"; | 35 const char kKeyUsername[] = "username"; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 } | 135 } |
136 | 136 |
137 // static | 137 // static |
138 void UserSelectionScreen::FillUserDictionary( | 138 void UserSelectionScreen::FillUserDictionary( |
139 user_manager::User* user, | 139 user_manager::User* user, |
140 bool is_owner, | 140 bool is_owner, |
141 bool is_signin_to_add, | 141 bool is_signin_to_add, |
142 AuthType auth_type, | 142 AuthType auth_type, |
143 const std::vector<std::string>* public_session_recommended_locales, | 143 const std::vector<std::string>* public_session_recommended_locales, |
144 base::DictionaryValue* user_dict) { | 144 base::DictionaryValue* user_dict) { |
145 const user_manager::UserID user_id = user->email(); | |
146 const bool is_public_session = | 145 const bool is_public_session = |
147 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 146 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
148 const bool is_legacy_supervised_user = | 147 const bool is_legacy_supervised_user = |
149 user->GetType() == user_manager::USER_TYPE_SUPERVISED; | 148 user->GetType() == user_manager::USER_TYPE_SUPERVISED; |
150 const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD; | 149 const bool is_child_user = user->GetType() == user_manager::USER_TYPE_CHILD; |
151 | 150 |
152 user_dict->SetString(kKeyUsername, user_id); | 151 user_dict->SetString(kKeyUsername, user->GetUserID().GetUserEmail()); |
153 user_dict->SetString(kKeyEmailAddress, user->display_email()); | 152 user_dict->SetString(kKeyEmailAddress, user->display_email()); |
154 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); | 153 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); |
155 user_dict->SetBoolean(kKeyPublicAccount, is_public_session); | 154 user_dict->SetBoolean(kKeyPublicAccount, is_public_session); |
156 user_dict->SetBoolean(kKeyLegacySupervisedUser, is_legacy_supervised_user); | 155 user_dict->SetBoolean(kKeyLegacySupervisedUser, is_legacy_supervised_user); |
157 user_dict->SetBoolean(kKeyChildUser, is_child_user); | 156 user_dict->SetBoolean(kKeyChildUser, is_child_user); |
158 user_dict->SetBoolean(kKeyDesktopUser, false); | 157 user_dict->SetBoolean(kKeyDesktopUser, false); |
159 user_dict->SetInteger(kKeyInitialAuthType, auth_type); | 158 user_dict->SetInteger(kKeyInitialAuthType, auth_type); |
160 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); | 159 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); |
161 user_dict->SetBoolean(kKeyIsOwner, is_owner); | 160 user_dict->SetBoolean(kKeyIsOwner, is_owner); |
162 | 161 |
163 FillMultiProfileUserPrefs(user, user_dict, is_signin_to_add); | 162 FillMultiProfileUserPrefs(user, user_dict, is_signin_to_add); |
164 FillKnownUserPrefs(user, user_dict); | 163 FillKnownUserPrefs(user, user_dict); |
165 | 164 |
166 if (is_public_session) { | 165 if (is_public_session) { |
167 AddPublicSessionDetailsToUserDictionaryEntry( | 166 AddPublicSessionDetailsToUserDictionaryEntry( |
168 user_dict, public_session_recommended_locales); | 167 user_dict, public_session_recommended_locales); |
169 } | 168 } |
170 } | 169 } |
171 | 170 |
172 // static | 171 // static |
173 void UserSelectionScreen::FillKnownUserPrefs(user_manager::User* user, | 172 void UserSelectionScreen::FillKnownUserPrefs(user_manager::User* user, |
174 base::DictionaryValue* user_dict) { | 173 base::DictionaryValue* user_dict) { |
175 std::string gaia_id; | 174 std::string gaia_id; |
176 if (user_manager::UserManager::Get()->FindGaiaID(user->email(), &gaia_id)) { | 175 if (user_manager::UserManager::Get()->FindGaiaID(user->GetUserID(), |
176 &gaia_id)) { | |
177 user_dict->SetString(kKeyGaiaID, gaia_id); | 177 user_dict->SetString(kKeyGaiaID, gaia_id); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 // static | 181 // static |
182 void UserSelectionScreen::FillMultiProfileUserPrefs( | 182 void UserSelectionScreen::FillMultiProfileUserPrefs( |
183 user_manager::User* user, | 183 user_manager::User* user, |
184 base::DictionaryValue* user_dict, | 184 base::DictionaryValue* user_dict, |
185 bool is_signin_to_add) { | 185 bool is_signin_to_add) { |
186 const std::string& user_id = user->email(); | 186 const std::string& user_id = user->email(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN) { | 232 token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN) { |
233 return false; | 233 return false; |
234 } | 234 } |
235 | 235 |
236 if (is_public_session) | 236 if (is_public_session) |
237 return false; | 237 return false; |
238 | 238 |
239 // At this point the reason for invalid token should be already set. If not, | 239 // At this point the reason for invalid token should be already set. If not, |
240 // this might be a leftover from an old version. | 240 // this might be a leftover from an old version. |
241 if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) | 241 if (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) |
242 RecordReauthReason(user->email(), ReauthReason::OTHER); | 242 RecordReauthReason(user->GetUserID(), ReauthReason::OTHER); |
243 | 243 |
244 return user->force_online_signin() || | 244 return user->force_online_signin() || |
245 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) || | 245 (token_status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) || |
246 (token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN); | 246 (token_status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN); |
247 } | 247 } |
248 | 248 |
249 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { | 249 void UserSelectionScreen::SetHandler(LoginDisplayWebUIHandler* handler) { |
250 handler_ = handler; | 250 handler_ = handler; |
251 } | 251 } |
252 | 252 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 users_list.Append(user_dict); | 397 users_list.Append(user_dict); |
398 } | 398 } |
399 | 399 |
400 handler_->LoadUsers(users_list, show_guest_); | 400 handler_->LoadUsers(users_list, show_guest_); |
401 } | 401 } |
402 | 402 |
403 void UserSelectionScreen::HandleGetUsers() { | 403 void UserSelectionScreen::HandleGetUsers() { |
404 SendUserList(); | 404 SendUserList(); |
405 } | 405 } |
406 | 406 |
407 void UserSelectionScreen::CheckUserStatus(const std::string& user_id) { | 407 void UserSelectionScreen::CheckUserStatus(const std::string& user_email) { |
408 // No checks on lock screen. | 408 // No checks on lock screen. |
409 if (ScreenLocker::default_screen_locker()) | 409 if (ScreenLocker::default_screen_locker()) |
410 return; | 410 return; |
411 | 411 |
412 if (!token_handle_util_.get()) { | 412 if (!token_handle_util_.get()) { |
413 token_handle_util_.reset( | 413 token_handle_util_.reset( |
414 new TokenHandleUtil(user_manager::UserManager::Get())); | 414 new TokenHandleUtil(user_manager::UserManager::Get())); |
415 } | 415 } |
416 | 416 |
417 if (token_handle_util_->HasToken(user_id)) { | 417 const AccountId account_id = AccountId::FromUserEmail(user_email); |
418 if (token_handle_util_->HasToken(account_id)) { | |
418 token_handle_util_->CheckToken( | 419 token_handle_util_->CheckToken( |
419 user_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, | 420 account_id, base::Bind(&UserSelectionScreen::OnUserStatusChecked, |
420 weak_factory_.GetWeakPtr())); | 421 weak_factory_.GetWeakPtr())); |
421 } | 422 } |
422 } | 423 } |
423 | 424 |
424 void UserSelectionScreen::OnUserStatusChecked( | 425 void UserSelectionScreen::OnUserStatusChecked( |
425 const user_manager::UserID& user_id, | 426 const AccountId& user_id, |
achuithb
2015/10/23 00:08:50
account_id
Alexander Alekseev
2015/10/23 09:11:21
Done.
| |
426 TokenHandleUtil::TokenHandleStatus status) { | 427 TokenHandleUtil::TokenHandleStatus status) { |
427 if (status == TokenHandleUtil::INVALID) { | 428 if (status == TokenHandleUtil::INVALID) { |
428 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); | 429 RecordReauthReason(user_id, ReauthReason::INVALID_TOKEN_HANDLE); |
429 token_handle_util_->MarkHandleInvalid(user_id); | 430 token_handle_util_->MarkHandleInvalid(user_id); |
430 SetAuthType(user_id, ONLINE_SIGN_IN, base::string16()); | 431 SetAuthType(user_id.GetUserEmail(), ONLINE_SIGN_IN, base::string16()); |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
434 // EasyUnlock stuff | 435 // EasyUnlock stuff |
435 | 436 |
436 void UserSelectionScreen::SetAuthType(const std::string& user_id, | 437 void UserSelectionScreen::SetAuthType(const std::string& user_id, |
437 AuthType auth_type, | 438 AuthType auth_type, |
438 const base::string16& initial_value) { | 439 const base::string16& initial_value) { |
439 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) | 440 if (GetAuthType(user_id) == FORCE_OFFLINE_PASSWORD) |
440 return; | 441 return; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 void UserSelectionScreen::Unlock(const std::string& user_email) { | 492 void UserSelectionScreen::Unlock(const std::string& user_email) { |
492 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); | 493 DCHECK_EQ(GetScreenType(), LOCK_SCREEN); |
493 ScreenLocker::Hide(); | 494 ScreenLocker::Hide(); |
494 } | 495 } |
495 | 496 |
496 void UserSelectionScreen::AttemptEasySignin(const std::string& user_id, | 497 void UserSelectionScreen::AttemptEasySignin(const std::string& user_id, |
497 const std::string& secret, | 498 const std::string& secret, |
498 const std::string& key_label) { | 499 const std::string& key_label) { |
499 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); | 500 DCHECK_EQ(GetScreenType(), SIGNIN_SCREEN); |
500 | 501 |
501 UserContext user_context(user_id); | 502 UserContext user_context(AccountId::FromUserEmail(user_id)); |
502 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); | 503 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); |
503 user_context.SetKey(Key(secret)); | 504 user_context.SetKey(Key(secret)); |
504 user_context.GetKey()->SetLabel(key_label); | 505 user_context.GetKey()->SetLabel(key_label); |
505 | 506 |
506 login_display_delegate_->Login(user_context, SigninSpecifics()); | 507 login_display_delegate_->Login(user_context, SigninSpecifics()); |
507 } | 508 } |
508 | 509 |
509 void UserSelectionScreen::HardLockPod(const std::string& user_id) { | 510 void UserSelectionScreen::HardLockPod(const std::string& user_id) { |
510 view_->SetAuthType(user_id, OFFLINE_PASSWORD, base::string16()); | 511 view_->SetAuthType(user_id, OFFLINE_PASSWORD, base::string16()); |
511 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); | 512 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 // The user profile should exist if and only if this is the lock screen. | 550 // The user profile should exist if and only if this is the lock screen. |
550 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); | 551 DCHECK_EQ(!!profile, GetScreenType() == LOCK_SCREEN); |
551 | 552 |
552 if (!profile) | 553 if (!profile) |
553 profile = profile_helper->GetSigninProfile(); | 554 profile = profile_helper->GetSigninProfile(); |
554 | 555 |
555 return EasyUnlockService::Get(profile); | 556 return EasyUnlockService::Get(profile); |
556 } | 557 } |
557 | 558 |
558 } // namespace chromeos | 559 } // namespace chromeos |
OLD | NEW |