| Index: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
|
| diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
|
| index 5b21d4fbb74a18ca33a86a7999b0227725d228ef..0dae2faddd8c64732f10efab17ce12dba90c7499 100644
|
| --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
|
| +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
|
| @@ -29,9 +29,11 @@
|
| #include "chrome/browser/chromeos/boot_times_loader.h"
|
| #include "chrome/browser/chromeos/input_method/input_method_util.h"
|
| #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
|
| +#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
|
| #include "chrome/browser/chromeos/login/hwid_checker.h"
|
| #include "chrome/browser/chromeos/login/lock/screen_locker.h"
|
| #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
|
| +#include "chrome/browser/chromeos/login/session/user_session_manager.h"
|
| #include "chrome/browser/chromeos/login/ui/login_display_host.h"
|
| #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
|
| #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
|
| @@ -74,6 +76,7 @@
|
| #include "google_apis/gaia/gaia_auth_util.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| #include "third_party/cros_system_api/dbus/service_constants.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/webui/web_ui_util.h"
|
|
|
| #if defined(USE_AURA)
|
| @@ -1050,26 +1053,45 @@ void SigninScreenHandler::HandleAuthenticateUser(const std::string& username,
|
| }
|
|
|
| void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) {
|
| - DCHECK(ScreenLocker::default_screen_locker());
|
| -
|
| - const user_manager::User* unlock_user = NULL;
|
| - const user_manager::UserList& users = delegate_->GetUsers();
|
| - for (user_manager::UserList::const_iterator it = users.begin();
|
| - it != users.end();
|
| - ++it) {
|
| - if ((*it)->email() == username) {
|
| - unlock_user = *it;
|
| - break;
|
| + if (ScreenLocker::default_screen_locker()) {
|
| + // Lock screen
|
| + const user_manager::User* unlock_user = NULL;
|
| + const user_manager::UserList& users = delegate_->GetUsers();
|
| + for (user_manager::UserList::const_iterator it = users.begin();
|
| + it != users.end();
|
| + ++it) {
|
| + if ((*it)->email() == username) {
|
| + unlock_user = *it;
|
| + break;
|
| + }
|
| }
|
| + if (!unlock_user)
|
| + return;
|
| +
|
| + Profile* profile =
|
| + ProfileHelper::Get()->GetProfileByUserUnsafe(unlock_user);
|
| + extensions::ScreenlockPrivateEventRouter* router =
|
| + extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
|
| + profile);
|
| + router->OnAuthAttempted(GetAuthType(username), "");
|
| + return;
|
| }
|
| - if (!unlock_user)
|
| +
|
| + OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
|
| + if (oobe_ui->display_type() != OobeUI::kLoginDisplay)
|
| + return;
|
| +
|
| + EasyUnlockKeyManager* key_manager =
|
| + UserSessionManager::GetInstance()->GetEasyUnlockKeyManager();
|
| + if (!key_manager)
|
| return;
|
|
|
| - Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(unlock_user);
|
| - extensions::ScreenlockPrivateEventRouter* router =
|
| - extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
|
| - profile);
|
| - router->OnAuthAttempted(GetAuthType(username), "");
|
| + // TODO(xiyuan,tengs): Trigger decrypt message.
|
| + key_manager->GetDeviceDataList(
|
| + UserContext(username),
|
| + base::Bind(&SigninScreenHandler::OnEasyUnlockDeviceListFetchedForSignIn,
|
| + weak_factory_.GetWeakPtr(),
|
| + username));
|
| }
|
|
|
| void SigninScreenHandler::HandleLaunchDemoUser() {
|
| @@ -1190,6 +1212,10 @@ void SigninScreenHandler::LoadUsers(const base::ListValue& users_list,
|
| CallJS("login.AccountPickerScreen.loadUsers",
|
| users_list,
|
| delegate_->IsShowGuest());
|
| +
|
| + OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
|
| + if (oobe_ui->display_type() == OobeUI::kLoginDisplay)
|
| + FetchEasyUnlockKeysForUserList(users_list);
|
| }
|
|
|
| void SigninScreenHandler::HandleAccountPickerReady() {
|
| @@ -1518,4 +1544,67 @@ void SigninScreenHandler::OnCapsLockChanged(bool enabled) {
|
| CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_);
|
| }
|
|
|
| +void SigninScreenHandler::FetchEasyUnlockKeysForUserList(
|
| + const base::ListValue& users_list) {
|
| + EasyUnlockKeyManager* key_manager =
|
| + UserSessionManager::GetInstance()->GetEasyUnlockKeyManager();
|
| + if (!key_manager)
|
| + return;
|
| +
|
| + for (size_t i = 0; i < users_list.GetSize(); ++i) {
|
| + const base::DictionaryValue* user_dict;
|
| + if (!users_list.GetDictionary(i, &user_dict))
|
| + continue;
|
| +
|
| + std::string user_id;
|
| + if (!user_dict->GetStringWithoutPathExpansion("username", &user_id))
|
| + continue;
|
| +
|
| + key_manager->GetDeviceDataList(
|
| + UserContext(user_id),
|
| + base::Bind(&SigninScreenHandler::OnEasyUnlockDeviceListFetched,
|
| + weak_factory_.GetWeakPtr(),
|
| + user_id));
|
| + }
|
| +}
|
| +
|
| +void SigninScreenHandler::OnEasyUnlockDeviceListFetched(
|
| + const std::string& user_id,
|
| + bool success,
|
| + const EasyUnlockDeviceKeyDataList& devices) {
|
| + if (!success || devices.empty())
|
| + return;
|
| +
|
| + SetAuthType(user_id,
|
| + ScreenlockBridge::LockHandler::USER_CLICK,
|
| + l10n_util::GetStringUTF16(
|
| + IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE));
|
| +}
|
| +
|
| +void SigninScreenHandler::OnEasyUnlockDeviceListFetchedForSignIn(
|
| + const std::string& user_id,
|
| + bool success,
|
| + const EasyUnlockDeviceKeyDataList& devices) {
|
| + if (!delegate_)
|
| + return;
|
| +
|
| + if (!success || devices.empty()) {
|
| + LOG(ERROR) << "Easy unlock failed to get device to sign in.";
|
| + // Trigger a login failure.
|
| + delegate_->Login(UserContext(user_id), SigninSpecifics());
|
| + return;
|
| + }
|
| +
|
| + UserContext user_context(user_id);
|
| + user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK);
|
| +
|
| + // Assumes the first phone.
|
| + const size_t device_index = 0;
|
| + user_context.SetKey(Key(devices[device_index].wrapped_secret));
|
| + user_context.GetKey()->SetLabel(
|
| + EasyUnlockKeyManager::GetKeyLabel(device_index));
|
| +
|
| + delegate_->Login(user_context, SigninSpecifics());
|
| +}
|
| +
|
| } // namespace chromeos
|
|
|