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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, | 1090 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, |
1091 const std::string& password) { | 1091 const std::string& password) { |
1092 if (!delegate_) | 1092 if (!delegate_) |
1093 return; | 1093 return; |
1094 UserContext user_context(username); | 1094 UserContext user_context(username); |
1095 user_context.SetKey(Key(password)); | 1095 user_context.SetKey(Key(password)); |
1096 delegate_->Login(user_context, SigninSpecifics()); | 1096 delegate_->Login(user_context, SigninSpecifics()); |
1097 } | 1097 } |
1098 | 1098 |
1099 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { | 1099 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { |
1100 if (!ScreenLocker::default_screen_locker()) { | 1100 EasyUnlockService* service = GetEasyUnlockServiceForUser(username); |
1101 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); | 1101 if (!service) |
1102 if (oobe_ui->display_type() != OobeUI::kLoginDisplay) | |
1103 return; | |
1104 } | |
1105 | |
1106 const user_manager::User* unlock_user = NULL; | |
1107 const user_manager::UserList& users = delegate_->GetUsers(); | |
1108 for (user_manager::UserList::const_iterator it = users.begin(); | |
1109 it != users.end(); | |
1110 ++it) { | |
1111 if ((*it)->email() == username) { | |
1112 unlock_user = *it; | |
1113 break; | |
1114 } | |
1115 } | |
1116 if (!unlock_user) | |
1117 return; | 1102 return; |
1118 | 1103 service->AttemptAuth(username); |
1119 ProfileHelper* profile_helper = ProfileHelper::Get(); | |
1120 Profile* profile = profile_helper->GetProfileByUser(unlock_user); | |
1121 | |
1122 // The user profile should exists if and only if this is lock screen. | |
1123 DCHECK_NE(!profile, !ScreenLocker::default_screen_locker()); | |
1124 | |
1125 if (!profile) | |
1126 profile = profile_helper->GetSigninProfile(); | |
1127 | |
1128 EasyUnlockService::Get(profile)->AttemptAuth(username); | |
1129 } | 1104 } |
1130 | 1105 |
1131 void SigninScreenHandler::HandleLaunchDemoUser() { | 1106 void SigninScreenHandler::HandleLaunchDemoUser() { |
1132 UserContext context(user_manager::USER_TYPE_RETAIL_MODE, std::string()); | 1107 UserContext context(user_manager::USER_TYPE_RETAIL_MODE, std::string()); |
1133 if (delegate_) | 1108 if (delegate_) |
1134 delegate_->Login(context, SigninSpecifics()); | 1109 delegate_->Login(context, SigninSpecifics()); |
1135 } | 1110 } |
1136 | 1111 |
1137 void SigninScreenHandler::HandleLaunchIncognito() { | 1112 void SigninScreenHandler::HandleLaunchIncognito() { |
1138 UserContext context(user_manager::USER_TYPE_GUEST, std::string()); | 1113 UserContext context(user_manager::USER_TYPE_GUEST, std::string()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 // TODO(dpolukhin): crbug.com/408734. | 1360 // TODO(dpolukhin): crbug.com/408734. |
1386 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); | 1361 WallpaperManager::Get()->SetUserWallpaperDelayed(user_id); |
1387 #endif | 1362 #endif |
1388 ScreenlockBridge::Get()->SetFocusedUser(user_id); | 1363 ScreenlockBridge::Get()->SetFocusedUser(user_id); |
1389 if (!test_focus_pod_callback_.is_null()) | 1364 if (!test_focus_pod_callback_.is_null()) |
1390 test_focus_pod_callback_.Run(); | 1365 test_focus_pod_callback_.Run(); |
1391 } | 1366 } |
1392 | 1367 |
1393 void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) { | 1368 void SigninScreenHandler::HandleHardlockPod(const std::string& user_id) { |
1394 SetAuthType(user_id, | 1369 SetAuthType(user_id, |
1395 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 1370 ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, |
1396 base::string16()); | 1371 base::string16()); |
1397 HideUserPodCustomIcon(user_id); | 1372 EasyUnlockService* service = GetEasyUnlockServiceForUser(user_id); |
| 1373 if (!service) |
| 1374 return; |
| 1375 service->SetHardlocked(true); |
1398 } | 1376 } |
1399 | 1377 |
1400 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( | 1378 void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( |
1401 double attempt_token) { | 1379 double attempt_token) { |
1402 // TODO(antrim) : move GaiaSigninScreen dependency to GaiaSigninScreen. | 1380 // TODO(antrim) : move GaiaSigninScreen dependency to GaiaSigninScreen. |
1403 email_retriever_.reset(new AuthenticatedUserEmailRetriever( | 1381 email_retriever_.reset(new AuthenticatedUserEmailRetriever( |
1404 base::Bind(&SigninScreenHandler::CallJS<double, std::string>, | 1382 base::Bind(&SigninScreenHandler::CallJS<double, std::string>, |
1405 base::Unretained(this), | 1383 base::Unretained(this), |
1406 "login.GaiaSigninScreen.setAuthenticatedUserEmail", | 1384 "login.GaiaSigninScreen.setAuthenticatedUserEmail", |
1407 attempt_token), | 1385 attempt_token), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 if (delegate_) { | 1463 if (delegate_) { |
1486 ShowImpl(); | 1464 ShowImpl(); |
1487 delegate_->CancelPasswordChangedFlow(); | 1465 delegate_->CancelPasswordChangedFlow(); |
1488 } | 1466 } |
1489 } | 1467 } |
1490 | 1468 |
1491 OobeUI* SigninScreenHandler::GetOobeUI() const { | 1469 OobeUI* SigninScreenHandler::GetOobeUI() const { |
1492 return static_cast<OobeUI*>(web_ui()->GetController()); | 1470 return static_cast<OobeUI*>(web_ui()->GetController()); |
1493 } | 1471 } |
1494 | 1472 |
| 1473 EasyUnlockService* SigninScreenHandler::GetEasyUnlockServiceForUser( |
| 1474 const std::string& username) const { |
| 1475 if (!ScreenLocker::default_screen_locker() && |
| 1476 GetOobeUI()->display_type() != OobeUI::kLoginDisplay) |
| 1477 return NULL; |
| 1478 |
| 1479 const user_manager::User* unlock_user = NULL; |
| 1480 const user_manager::UserList& users = delegate_->GetUsers(); |
| 1481 for (user_manager::UserList::const_iterator it = users.begin(); |
| 1482 it != users.end(); |
| 1483 ++it) { |
| 1484 if ((*it)->email() == username) { |
| 1485 unlock_user = *it; |
| 1486 break; |
| 1487 } |
| 1488 } |
| 1489 if (!unlock_user) |
| 1490 return NULL; |
| 1491 |
| 1492 ProfileHelper* profile_helper = ProfileHelper::Get(); |
| 1493 Profile* profile = profile_helper->GetProfileByUser(unlock_user); |
| 1494 |
| 1495 // The user profile should exists if and only if this is lock screen. |
| 1496 DCHECK_NE(!profile, !ScreenLocker::default_screen_locker()); |
| 1497 |
| 1498 if (!profile) |
| 1499 profile = profile_helper->GetSigninProfile(); |
| 1500 |
| 1501 return EasyUnlockService::Get(profile); |
| 1502 } |
| 1503 |
1495 OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const { | 1504 OobeUI::Screen SigninScreenHandler::GetCurrentScreen() const { |
1496 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; | 1505 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; |
1497 OobeUI* oobe_ui = GetOobeUI(); | 1506 OobeUI* oobe_ui = GetOobeUI(); |
1498 if (oobe_ui) | 1507 if (oobe_ui) |
1499 screen = oobe_ui->current_screen(); | 1508 screen = oobe_ui->current_screen(); |
1500 return screen; | 1509 return screen; |
1501 } | 1510 } |
1502 | 1511 |
1503 bool SigninScreenHandler::IsGaiaVisible() const { | 1512 bool SigninScreenHandler::IsGaiaVisible() const { |
1504 return IsSigninScreen(GetCurrentScreen()) && | 1513 return IsSigninScreen(GetCurrentScreen()) && |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 return gaia_screen_handler_->frame_error(); | 1587 return gaia_screen_handler_->frame_error(); |
1579 } | 1588 } |
1580 | 1589 |
1581 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1590 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
1582 caps_lock_enabled_ = enabled; | 1591 caps_lock_enabled_ = enabled; |
1583 if (page_is_ready()) | 1592 if (page_is_ready()) |
1584 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1593 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
1585 } | 1594 } |
1586 | 1595 |
1587 } // namespace chromeos | 1596 } // namespace chromeos |
OLD | NEW |