OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ui/webui/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 25 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
26 #include "chrome/browser/browser_shutdown.h" | 26 #include "chrome/browser/browser_shutdown.h" |
27 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
28 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 28 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
29 #include "chrome/browser/chromeos/boot_times_loader.h" | 29 #include "chrome/browser/chromeos/boot_times_loader.h" |
30 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 30 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 32 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
32 #include "chrome/browser/chromeos/login/hwid_checker.h" | 33 #include "chrome/browser/chromeos/login/hwid_checker.h" |
33 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 34 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
34 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 35 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
| 36 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
35 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 37 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
36 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 38 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
37 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 39 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
38 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 40 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
39 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 41 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
40 #include "chrome/browser/chromeos/login/wizard_controller.h" | 42 #include "chrome/browser/chromeos/login/wizard_controller.h" |
41 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 43 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
42 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 44 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
43 #include "chrome/browser/chromeos/policy/device_local_account.h" | 45 #include "chrome/browser/chromeos/policy/device_local_account.h" |
44 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 46 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
(...skipping 22 matching lines...) Expand all Loading... |
67 #include "chromeos/network/network_state_handler.h" | 69 #include "chromeos/network/network_state_handler.h" |
68 #include "chromeos/network/portal_detector/network_portal_detector.h" | 70 #include "chromeos/network/portal_detector/network_portal_detector.h" |
69 #include "components/user_manager/user.h" | 71 #include "components/user_manager/user.h" |
70 #include "components/user_manager/user_manager.h" | 72 #include "components/user_manager/user_manager.h" |
71 #include "components/user_manager/user_type.h" | 73 #include "components/user_manager/user_type.h" |
72 #include "content/public/browser/render_frame_host.h" | 74 #include "content/public/browser/render_frame_host.h" |
73 #include "content/public/browser/web_contents.h" | 75 #include "content/public/browser/web_contents.h" |
74 #include "google_apis/gaia/gaia_auth_util.h" | 76 #include "google_apis/gaia/gaia_auth_util.h" |
75 #include "net/url_request/url_request_context_getter.h" | 77 #include "net/url_request/url_request_context_getter.h" |
76 #include "third_party/cros_system_api/dbus/service_constants.h" | 78 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 79 #include "ui/base/l10n/l10n_util.h" |
77 #include "ui/base/webui/web_ui_util.h" | 80 #include "ui/base/webui/web_ui_util.h" |
78 | 81 |
79 #if defined(USE_AURA) | 82 #if defined(USE_AURA) |
80 #include "ash/shell.h" | 83 #include "ash/shell.h" |
81 #include "ash/wm/lock_state_controller.h" | 84 #include "ash/wm/lock_state_controller.h" |
82 #endif | 85 #endif |
83 | 86 |
84 namespace { | 87 namespace { |
85 | 88 |
86 // Max number of users to show. | 89 // Max number of users to show. |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, | 1046 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, |
1044 const std::string& password) { | 1047 const std::string& password) { |
1045 if (!delegate_) | 1048 if (!delegate_) |
1046 return; | 1049 return; |
1047 UserContext user_context(username); | 1050 UserContext user_context(username); |
1048 user_context.SetKey(Key(password)); | 1051 user_context.SetKey(Key(password)); |
1049 delegate_->Login(user_context, SigninSpecifics()); | 1052 delegate_->Login(user_context, SigninSpecifics()); |
1050 } | 1053 } |
1051 | 1054 |
1052 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { | 1055 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { |
1053 DCHECK(ScreenLocker::default_screen_locker()); | 1056 if (ScreenLocker::default_screen_locker()) { |
| 1057 // Lock screen |
| 1058 const user_manager::User* unlock_user = NULL; |
| 1059 const user_manager::UserList& users = delegate_->GetUsers(); |
| 1060 for (user_manager::UserList::const_iterator it = users.begin(); |
| 1061 it != users.end(); |
| 1062 ++it) { |
| 1063 if ((*it)->email() == username) { |
| 1064 unlock_user = *it; |
| 1065 break; |
| 1066 } |
| 1067 } |
| 1068 if (!unlock_user) |
| 1069 return; |
1054 | 1070 |
1055 const user_manager::User* unlock_user = NULL; | 1071 Profile* profile = |
1056 const user_manager::UserList& users = delegate_->GetUsers(); | 1072 ProfileHelper::Get()->GetProfileByUserUnsafe(unlock_user); |
1057 for (user_manager::UserList::const_iterator it = users.begin(); | 1073 extensions::ScreenlockPrivateEventRouter* router = |
1058 it != users.end(); | 1074 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( |
1059 ++it) { | 1075 profile); |
1060 if ((*it)->email() == username) { | 1076 router->OnAuthAttempted(GetAuthType(username), ""); |
1061 unlock_user = *it; | 1077 return; |
1062 break; | |
1063 } | |
1064 } | 1078 } |
1065 if (!unlock_user) | 1079 |
| 1080 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); |
| 1081 if (oobe_ui->display_type() != OobeUI::kLoginDisplay) |
1066 return; | 1082 return; |
1067 | 1083 |
1068 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(unlock_user); | 1084 EasyUnlockKeyManager* key_manager = |
1069 extensions::ScreenlockPrivateEventRouter* router = | 1085 UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); |
1070 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( | 1086 if (!key_manager) |
1071 profile); | 1087 return; |
1072 router->OnAuthAttempted(GetAuthType(username), ""); | 1088 |
| 1089 // TODO(xiyuan,tengs): Trigger decrypt message. |
| 1090 key_manager->GetDeviceDataList( |
| 1091 UserContext(username), |
| 1092 base::Bind(&SigninScreenHandler::OnEasyUnlockDeviceListFetchedForSignIn, |
| 1093 weak_factory_.GetWeakPtr(), |
| 1094 username)); |
1073 } | 1095 } |
1074 | 1096 |
1075 void SigninScreenHandler::HandleLaunchDemoUser() { | 1097 void SigninScreenHandler::HandleLaunchDemoUser() { |
1076 UserContext context(user_manager::USER_TYPE_RETAIL_MODE, std::string()); | 1098 UserContext context(user_manager::USER_TYPE_RETAIL_MODE, std::string()); |
1077 if (delegate_) | 1099 if (delegate_) |
1078 delegate_->Login(context, SigninSpecifics()); | 1100 delegate_->Login(context, SigninSpecifics()); |
1079 } | 1101 } |
1080 | 1102 |
1081 void SigninScreenHandler::HandleLaunchIncognito() { | 1103 void SigninScreenHandler::HandleLaunchIncognito() { |
1082 UserContext context(user_manager::USER_TYPE_GUEST, std::string()); | 1104 UserContext context(user_manager::USER_TYPE_GUEST, std::string()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1205 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1184 if (delegate_ && !connector->IsEnterpriseManaged()) | 1206 if (delegate_ && !connector->IsEnterpriseManaged()) |
1185 delegate_->ShowKioskAutolaunchScreen(); | 1207 delegate_->ShowKioskAutolaunchScreen(); |
1186 } | 1208 } |
1187 | 1209 |
1188 void SigninScreenHandler::LoadUsers(const base::ListValue& users_list, | 1210 void SigninScreenHandler::LoadUsers(const base::ListValue& users_list, |
1189 bool showGuest) { | 1211 bool showGuest) { |
1190 CallJS("login.AccountPickerScreen.loadUsers", | 1212 CallJS("login.AccountPickerScreen.loadUsers", |
1191 users_list, | 1213 users_list, |
1192 delegate_->IsShowGuest()); | 1214 delegate_->IsShowGuest()); |
| 1215 |
| 1216 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); |
| 1217 if (oobe_ui->display_type() == OobeUI::kLoginDisplay) |
| 1218 FetchEasyUnlockKeysForUserList(users_list); |
1193 } | 1219 } |
1194 | 1220 |
1195 void SigninScreenHandler::HandleAccountPickerReady() { | 1221 void SigninScreenHandler::HandleAccountPickerReady() { |
1196 VLOG(0) << "Login WebUI >> AccountPickerReady"; | 1222 VLOG(0) << "Login WebUI >> AccountPickerReady"; |
1197 | 1223 |
1198 if (delegate_ && !ScreenLocker::default_screen_locker() && | 1224 if (delegate_ && !ScreenLocker::default_screen_locker() && |
1199 !chromeos::IsMachineHWIDCorrect() && | 1225 !chromeos::IsMachineHWIDCorrect() && |
1200 !oobe_ui_) { | 1226 !oobe_ui_) { |
1201 delegate_->ShowWrongHWIDScreen(); | 1227 delegate_->ShowWrongHWIDScreen(); |
1202 return; | 1228 return; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 DCHECK(gaia_screen_handler_); | 1537 DCHECK(gaia_screen_handler_); |
1512 return gaia_screen_handler_->frame_error(); | 1538 return gaia_screen_handler_->frame_error(); |
1513 } | 1539 } |
1514 | 1540 |
1515 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1541 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
1516 caps_lock_enabled_ = enabled; | 1542 caps_lock_enabled_ = enabled; |
1517 if (page_is_ready()) | 1543 if (page_is_ready()) |
1518 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1544 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
1519 } | 1545 } |
1520 | 1546 |
| 1547 void SigninScreenHandler::FetchEasyUnlockKeysForUserList( |
| 1548 const base::ListValue& users_list) { |
| 1549 EasyUnlockKeyManager* key_manager = |
| 1550 UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); |
| 1551 if (!key_manager) |
| 1552 return; |
| 1553 |
| 1554 for (size_t i = 0; i < users_list.GetSize(); ++i) { |
| 1555 const base::DictionaryValue* user_dict; |
| 1556 if (!users_list.GetDictionary(i, &user_dict)) |
| 1557 continue; |
| 1558 |
| 1559 std::string user_id; |
| 1560 if (!user_dict->GetStringWithoutPathExpansion("username", &user_id)) |
| 1561 continue; |
| 1562 |
| 1563 key_manager->GetDeviceDataList( |
| 1564 UserContext(user_id), |
| 1565 base::Bind(&SigninScreenHandler::OnEasyUnlockDeviceListFetched, |
| 1566 weak_factory_.GetWeakPtr(), |
| 1567 user_id)); |
| 1568 } |
| 1569 } |
| 1570 |
| 1571 void SigninScreenHandler::OnEasyUnlockDeviceListFetched( |
| 1572 const std::string& user_id, |
| 1573 bool success, |
| 1574 const EasyUnlockDeviceKeyDataList& devices) { |
| 1575 if (!success || devices.empty()) |
| 1576 return; |
| 1577 |
| 1578 SetAuthType(user_id, |
| 1579 ScreenlockBridge::LockHandler::USER_CLICK, |
| 1580 l10n_util::GetStringUTF16( |
| 1581 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE)); |
| 1582 } |
| 1583 |
| 1584 void SigninScreenHandler::OnEasyUnlockDeviceListFetchedForSignIn( |
| 1585 const std::string& user_id, |
| 1586 bool success, |
| 1587 const EasyUnlockDeviceKeyDataList& devices) { |
| 1588 if (!delegate_) |
| 1589 return; |
| 1590 |
| 1591 if (!success || devices.empty()) { |
| 1592 LOG(ERROR) << "Easy unlock failed to get device to sign in."; |
| 1593 // Trigger a login failure. |
| 1594 delegate_->Login(UserContext(user_id), SigninSpecifics()); |
| 1595 return; |
| 1596 } |
| 1597 |
| 1598 UserContext user_context(user_id); |
| 1599 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); |
| 1600 |
| 1601 // Assumes the first phone. |
| 1602 const size_t device_index = 0; |
| 1603 user_context.SetKey(Key(devices[device_index].wrapped_secret)); |
| 1604 user_context.GetKey()->SetLabel( |
| 1605 EasyUnlockKeyManager::GetKeyLabel(device_index)); |
| 1606 |
| 1607 delegate_->Login(user_context, SigninSpecifics()); |
| 1608 } |
| 1609 |
1521 } // namespace chromeos | 1610 } // namespace chromeos |
OLD | NEW |