Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 36 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 37 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 37 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 38 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 38 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 39 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 39 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 40 #include "chrome/browser/chromeos/login/wizard_controller.h" | 40 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 41 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 41 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 42 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 42 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 43 #include "chrome/browser/chromeos/policy/device_local_account.h" | 43 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 44 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 44 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 45 #include "chrome/browser/chromeos/settings/cros_settings.h" | 45 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 46 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h" | |
| 47 #include "chrome/browser/io_thread.h" | 46 #include "chrome/browser/io_thread.h" |
| 48 #include "chrome/browser/profiles/profile.h" | 47 #include "chrome/browser/profiles/profile.h" |
| 48 #include "chrome/browser/signin/easy_unlock_service.h" | |
| 49 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie ver.h" | 49 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie ver.h" |
| 50 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" | 50 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" |
| 51 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 51 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 52 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" | 52 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" |
| 53 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 53 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 54 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 54 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 55 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
| 56 #include "chrome/common/url_constants.h" | 56 #include "chrome/common/url_constants.h" |
| 57 #include "chrome/grit/chromium_strings.h" | 57 #include "chrome/grit/chromium_strings.h" |
| 58 #include "chrome/grit/generated_resources.h" | 58 #include "chrome/grit/generated_resources.h" |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 ScreenlockBridge::LockHandler::AuthType SigninScreenHandler::GetAuthType( | 976 ScreenlockBridge::LockHandler::AuthType SigninScreenHandler::GetAuthType( |
| 977 const std::string& username) const { | 977 const std::string& username) const { |
| 978 return delegate_->GetAuthType(username); | 978 return delegate_->GetAuthType(username); |
| 979 } | 979 } |
| 980 | 980 |
| 981 void SigninScreenHandler::Unlock(const std::string& user_email) { | 981 void SigninScreenHandler::Unlock(const std::string& user_email) { |
| 982 DCHECK(ScreenLocker::default_screen_locker()); | 982 DCHECK(ScreenLocker::default_screen_locker()); |
| 983 ScreenLocker::Hide(); | 983 ScreenLocker::Hide(); |
| 984 } | 984 } |
| 985 | 985 |
| 986 void SigninScreenHandler::AttemptUserClickLogin(const std::string& user_email, | |
| 987 const std::string& secret, | |
| 988 const std::string& key_label) { | |
| 989 DCHECK(!ScreenLocker::default_screen_locker()); | |
| 990 if (!delegate_) | |
| 991 return; | |
| 992 | |
| 993 UserContext user_context(user_email); | |
| 994 user_context.SetAuthFlow(UserContext::AUTH_FLOW_EASY_UNLOCK); | |
| 995 user_context.SetKey(Key(secret)); | |
| 996 user_context.GetKey()->SetLabel(key_label); | |
| 997 | |
| 998 // TODO(tbarzic): Handle empty secret. The delegate will end up ignoring login | |
| 999 // attempt if the key is not set, and the UI will remain disabled. | |
| 1000 DCHECK(!secret.empty()); | |
| 1001 | |
| 1002 delegate_->Login(user_context, SigninSpecifics()); | |
|
Tim Song
2014/09/23 19:37:59
Is the delegate hooked up yet for logging in with
xiyuan
2014/09/23 19:56:58
The delegate should be set when sign-in screen is
tbarzic
2014/09/23 19:58:35
Yeah, it should work fine.
| |
| 1003 } | |
| 1004 | |
| 986 void SigninScreenHandler::OnMaximizeModeStarted() { | 1005 void SigninScreenHandler::OnMaximizeModeStarted() { |
| 987 CallJS("login.AccountPickerScreen.setTouchViewState", true); | 1006 CallJS("login.AccountPickerScreen.setTouchViewState", true); |
| 988 } | 1007 } |
| 989 | 1008 |
| 990 void SigninScreenHandler::OnMaximizeModeEnded() { | 1009 void SigninScreenHandler::OnMaximizeModeEnded() { |
| 991 CallJS("login.AccountPickerScreen.setTouchViewState", false); | 1010 CallJS("login.AccountPickerScreen.setTouchViewState", false); |
| 992 } | 1011 } |
| 993 | 1012 |
| 994 bool SigninScreenHandler::ShouldLoadGaia() const { | 1013 bool SigninScreenHandler::ShouldLoadGaia() const { |
| 995 // Fetching of the extension is not started before account picker page is | 1014 // Fetching of the extension is not started before account picker page is |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, | 1063 void SigninScreenHandler::HandleAuthenticateUser(const std::string& username, |
| 1045 const std::string& password) { | 1064 const std::string& password) { |
| 1046 if (!delegate_) | 1065 if (!delegate_) |
| 1047 return; | 1066 return; |
| 1048 UserContext user_context(username); | 1067 UserContext user_context(username); |
| 1049 user_context.SetKey(Key(password)); | 1068 user_context.SetKey(Key(password)); |
| 1050 delegate_->Login(user_context, SigninSpecifics()); | 1069 delegate_->Login(user_context, SigninSpecifics()); |
| 1051 } | 1070 } |
| 1052 | 1071 |
| 1053 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { | 1072 void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) { |
| 1054 DCHECK(ScreenLocker::default_screen_locker()); | 1073 if (!ScreenLocker::default_screen_locker()) { |
| 1074 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); | |
| 1075 if (oobe_ui->display_type() != OobeUI::kLoginDisplay) | |
| 1076 return; | |
| 1077 } | |
| 1055 | 1078 |
| 1056 const user_manager::User* unlock_user = NULL; | 1079 const user_manager::User* unlock_user = NULL; |
| 1057 const user_manager::UserList& users = delegate_->GetUsers(); | 1080 const user_manager::UserList& users = delegate_->GetUsers(); |
| 1058 for (user_manager::UserList::const_iterator it = users.begin(); | 1081 for (user_manager::UserList::const_iterator it = users.begin(); |
| 1059 it != users.end(); | 1082 it != users.end(); |
| 1060 ++it) { | 1083 ++it) { |
| 1061 if ((*it)->email() == username) { | 1084 if ((*it)->email() == username) { |
| 1062 unlock_user = *it; | 1085 unlock_user = *it; |
| 1063 break; | 1086 break; |
| 1064 } | 1087 } |
| 1065 } | 1088 } |
| 1066 if (!unlock_user) | 1089 if (!unlock_user) |
| 1067 return; | 1090 return; |
| 1068 | 1091 |
| 1069 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(unlock_user); | 1092 ProfileHelper* profile_helper = ProfileHelper::Get(); |
| 1070 extensions::ScreenlockPrivateEventRouter* router = | 1093 Profile* profile = profile_helper->GetProfileByUser(unlock_user); |
|
xiyuan
2014/09/23 01:24:29
This call probably has side effect. I suspect that
tbarzic
2014/09/23 01:50:21
According to the method comment, it returns NULL i
xiyuan
2014/09/23 02:49:24
I see. In this case, I am okay leaving as is.
| |
| 1071 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get( | 1094 |
| 1072 profile); | 1095 // The user profile should exists if and only if this is lock screen. |
| 1073 router->OnAuthAttempted(GetAuthType(username), ""); | 1096 DCHECK_NE(!profile, !ScreenLocker::default_screen_locker()); |
| 1097 | |
| 1098 if (!profile) | |
| 1099 profile = profile_helper->GetSigninProfile(); | |
| 1100 | |
| 1101 EasyUnlockService::Get(profile)->AttemptAuth(username); | |
| 1074 } | 1102 } |
| 1075 | 1103 |
| 1076 void SigninScreenHandler::HandleLaunchDemoUser() { | 1104 void SigninScreenHandler::HandleLaunchDemoUser() { |
| 1077 UserContext context(user_manager::USER_TYPE_RETAIL_MODE, std::string()); | 1105 UserContext context(user_manager::USER_TYPE_RETAIL_MODE, std::string()); |
| 1078 if (delegate_) | 1106 if (delegate_) |
| 1079 delegate_->Login(context, SigninSpecifics()); | 1107 delegate_->Login(context, SigninSpecifics()); |
| 1080 } | 1108 } |
| 1081 | 1109 |
| 1082 void SigninScreenHandler::HandleLaunchIncognito() { | 1110 void SigninScreenHandler::HandleLaunchIncognito() { |
| 1083 UserContext context(user_manager::USER_TYPE_GUEST, std::string()); | 1111 UserContext context(user_manager::USER_TYPE_GUEST, std::string()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1209 core_oobe_actor_->ShowDeviceResetScreen(); | 1237 core_oobe_actor_->ShowDeviceResetScreen(); |
| 1210 return; | 1238 return; |
| 1211 } | 1239 } |
| 1212 } | 1240 } |
| 1213 | 1241 |
| 1214 is_account_picker_showing_first_time_ = true; | 1242 is_account_picker_showing_first_time_ = true; |
| 1215 gaia_screen_handler_->MaybePreloadAuthExtension(); | 1243 gaia_screen_handler_->MaybePreloadAuthExtension(); |
| 1216 | 1244 |
| 1217 if (ScreenLocker::default_screen_locker()) { | 1245 if (ScreenLocker::default_screen_locker()) { |
| 1218 ScreenLocker::default_screen_locker()->delegate()->OnLockWebUIReady(); | 1246 ScreenLocker::default_screen_locker()->delegate()->OnLockWebUIReady(); |
| 1219 ScreenlockBridge::Get()->SetLockHandler(this); | |
| 1220 } | 1247 } |
| 1248 ScreenlockBridge::Get()->SetLockHandler(this); | |
| 1221 | 1249 |
| 1222 if (delegate_) | 1250 if (delegate_) |
| 1223 delegate_->OnSigninScreenReady(); | 1251 delegate_->OnSigninScreenReady(); |
| 1224 } | 1252 } |
| 1225 | 1253 |
| 1226 void SigninScreenHandler::HandleWallpaperReady() { | 1254 void SigninScreenHandler::HandleWallpaperReady() { |
| 1227 if (ScreenLocker::default_screen_locker()) { | 1255 if (ScreenLocker::default_screen_locker()) { |
| 1228 ScreenLocker::default_screen_locker()->delegate()-> | 1256 ScreenLocker::default_screen_locker()->delegate()-> |
| 1229 OnLockBackgroundDisplayed(); | 1257 OnLockBackgroundDisplayed(); |
| 1230 } | 1258 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1514 return gaia_screen_handler_->frame_error(); | 1542 return gaia_screen_handler_->frame_error(); |
| 1515 } | 1543 } |
| 1516 | 1544 |
| 1517 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1545 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
| 1518 caps_lock_enabled_ = enabled; | 1546 caps_lock_enabled_ = enabled; |
| 1519 if (page_is_ready()) | 1547 if (page_is_ready()) |
| 1520 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1548 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
| 1521 } | 1549 } |
| 1522 | 1550 |
| 1523 } // namespace chromeos | 1551 } // namespace chromeos |
| OLD | NEW |