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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username | 224 DLOG(ERROR) << "SigninScreenHandler::SetUserInputMethod('" << username |
| 225 << "'): user input method '" << user_input_method | 225 << "'): user input method '" << user_input_method |
| 226 << "' is not enabled and enabling failed (ignored!)."; | 226 << "' is not enabled and enabling failed (ignored!)."; |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 ime_state->ChangeInputMethod(user_input_method, false /* show_message */); | 229 ime_state->ChangeInputMethod(user_input_method, false /* show_message */); |
| 230 | 230 |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 void EnforcePolicyInputMethods(std::string user_input_method) { | |
| 235 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); | |
| 236 const base::ListValue* login_screen_input_methods = nullptr; | |
| 237 if (!cros_settings->GetList(chromeos::kDeviceLoginScreenInputMethods, | |
| 238 &login_screen_input_methods)) | |
| 239 return; | |
|
Shu Chen
2017/02/07 02:47:09
nit: wrap this by brackets {}.
pmarko
2017/02/07 10:44:09
Done.
| |
| 240 | |
| 241 std::vector<std::string> allowed_input_methods; | |
| 242 | |
| 243 // Add user's input method first so it is pre-selected. | |
| 244 if (!user_input_method.empty()) { | |
| 245 allowed_input_methods.push_back(user_input_method); | |
| 246 } | |
| 247 | |
| 248 std::string input_method; | |
| 249 for (const auto& input_method_entry : *login_screen_input_methods) { | |
| 250 if (input_method_entry->GetAsString(&input_method)) { | |
| 251 allowed_input_methods.push_back(input_method); | |
| 252 } | |
|
Shu Chen
2017/02/07 02:47:09
nit: no need these brackets.
pmarko
2017/02/07 10:44:09
Done.
| |
| 253 } | |
| 254 chromeos::input_method::InputMethodManager* imm = | |
| 255 chromeos::input_method::InputMethodManager::Get(); | |
| 256 imm->GetActiveIMEState()->SetAllowedInputMethods(allowed_input_methods); | |
| 257 } | |
| 258 | |
| 259 void StopEnforcingPolicyInputMethods() { | |
| 260 // Empty means all input methods are allowed | |
| 261 std::vector<std::string> allowed_input_methods; | |
| 262 chromeos::input_method::InputMethodManager* imm = | |
| 263 chromeos::input_method::InputMethodManager::Get(); | |
| 264 imm->GetActiveIMEState()->SetAllowedInputMethods(allowed_input_methods); | |
| 265 } | |
| 266 | |
| 234 } // namespace | 267 } // namespace |
| 235 | 268 |
| 236 // LoginScreenContext implementation ------------------------------------------ | 269 // LoginScreenContext implementation ------------------------------------------ |
| 237 | 270 |
| 238 LoginScreenContext::LoginScreenContext() { | 271 LoginScreenContext::LoginScreenContext() { |
| 239 Init(); | 272 Init(); |
| 240 } | 273 } |
| 241 | 274 |
| 242 LoginScreenContext::LoginScreenContext(const base::ListValue* args) { | 275 LoginScreenContext::LoginScreenContext(const base::ListValue* args) { |
| 243 Init(); | 276 Init(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 chrome::NOTIFICATION_AUTH_CANCELLED, | 320 chrome::NOTIFICATION_AUTH_CANCELLED, |
| 288 content::NotificationService::AllSources()); | 321 content::NotificationService::AllSources()); |
| 289 | 322 |
| 290 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( | 323 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( |
| 291 this); | 324 this); |
| 292 | 325 |
| 293 chromeos::input_method::ImeKeyboard* keyboard = | 326 chromeos::input_method::ImeKeyboard* keyboard = |
| 294 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 327 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 295 if (keyboard) | 328 if (keyboard) |
| 296 keyboard->AddObserver(this); | 329 keyboard->AddObserver(this); |
| 330 OnAllowedInputMethodsChanged(); | |
| 331 allowed_input_methods_subscription_ = | |
| 332 chromeos::CrosSettings::Get()->AddSettingsObserver( | |
| 333 chromeos::kDeviceLoginScreenInputMethods, | |
| 334 base::Bind(&SigninScreenHandler::OnAllowedInputMethodsChanged, | |
| 335 base::Unretained(this))); | |
| 297 | 336 |
| 298 content::ServiceManagerConnection::GetForProcess() | 337 content::ServiceManagerConnection::GetForProcess() |
| 299 ->GetConnector() | 338 ->GetConnector() |
| 300 ->BindInterface(ash_util::GetAshServiceName(), &touch_view_manager_ptr_); | 339 ->BindInterface(ash_util::GetAshServiceName(), &touch_view_manager_ptr_); |
| 301 touch_view_manager_ptr_->AddObserver( | 340 touch_view_manager_ptr_->AddObserver( |
| 302 touch_view_binding_.CreateInterfacePtrAndBind()); | 341 touch_view_binding_.CreateInterfacePtrAndBind()); |
| 303 } | 342 } |
| 304 | 343 |
| 305 SigninScreenHandler::~SigninScreenHandler() { | 344 SigninScreenHandler::~SigninScreenHandler() { |
| 306 OobeUI* oobe_ui = GetOobeUI(); | 345 OobeUI* oobe_ui = GetOobeUI(); |
| 307 if (oobe_ui && oobe_ui_observer_added_) | 346 if (oobe_ui && oobe_ui_observer_added_) |
| 308 oobe_ui->RemoveObserver(this); | 347 oobe_ui->RemoveObserver(this); |
| 309 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 348 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 310 this); | 349 this); |
| 311 chromeos::input_method::ImeKeyboard* keyboard = | 350 chromeos::input_method::ImeKeyboard* keyboard = |
| 312 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 351 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 313 if (keyboard) | 352 if (keyboard) |
| 314 keyboard->RemoveObserver(this); | 353 keyboard->RemoveObserver(this); |
| 354 StopEnforcingPolicyInputMethods(); | |
|
Shu Chen
2017/02/07 02:47:09
I'd like to understand about what will happen afte
pmarko
2017/02/07 10:44:09
After SetAllowedInputMethods(non_empty_vec), addit
| |
| 315 weak_factory_.InvalidateWeakPtrs(); | 355 weak_factory_.InvalidateWeakPtrs(); |
| 316 if (delegate_) | 356 if (delegate_) |
| 317 delegate_->SetWebUIHandler(nullptr); | 357 delegate_->SetWebUIHandler(nullptr); |
| 318 network_state_informer_->RemoveObserver(this); | 358 network_state_informer_->RemoveObserver(this); |
| 319 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); | 359 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 320 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); | 360 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); |
| 321 } | 361 } |
| 322 | 362 |
| 323 // static | 363 // static |
| 324 std::string SigninScreenHandler::GetUserLRUInputMethod( | 364 std::string SigninScreenHandler::GetUserLRUInputMethod( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 347 | 387 |
| 348 // static | 388 // static |
| 349 // Update keyboard layout to least recently used by the user. | 389 // Update keyboard layout to least recently used by the user. |
| 350 void SigninScreenHandler::SetUserInputMethod( | 390 void SigninScreenHandler::SetUserInputMethod( |
| 351 const std::string& username, | 391 const std::string& username, |
| 352 input_method::InputMethodManager::State* ime_state) { | 392 input_method::InputMethodManager::State* ime_state) { |
| 353 bool succeed = false; | 393 bool succeed = false; |
| 354 | 394 |
| 355 const std::string input_method = GetUserLRUInputMethod(username); | 395 const std::string input_method = GetUserLRUInputMethod(username); |
| 356 | 396 |
| 397 EnforcePolicyInputMethods(input_method); | |
| 398 | |
| 357 if (!input_method.empty()) | 399 if (!input_method.empty()) |
| 358 succeed = SetUserInputMethodImpl(username, input_method, ime_state); | 400 succeed = SetUserInputMethodImpl(username, input_method, ime_state); |
| 359 | 401 |
| 360 // This is also a case when LRU layout is set only for a few local users, | 402 // This is also a case when LRU layout is set only for a few local users, |
| 361 // thus others need to be switched to default locale. | 403 // thus others need to be switched to default locale. |
| 362 // Otherwise they will end up using another user's locale to log in. | 404 // Otherwise they will end up using another user's locale to log in. |
| 363 if (!succeed) { | 405 if (!succeed) { |
| 364 DVLOG(0) << "SetUserInputMethod('" << username | 406 DVLOG(0) << "SetUserInputMethod('" << username |
| 365 << "'): failed to set user layout. Switching to default."; | 407 << "'): failed to set user layout. Switching to default."; |
| 366 | 408 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 AddCallback("cancelUserAdding", &SigninScreenHandler::HandleCancelUserAdding); | 603 AddCallback("cancelUserAdding", &SigninScreenHandler::HandleCancelUserAdding); |
| 562 AddCallback("migrateUserData", &SigninScreenHandler::HandleMigrateUserData); | 604 AddCallback("migrateUserData", &SigninScreenHandler::HandleMigrateUserData); |
| 563 AddCallback("resyncUserData", &SigninScreenHandler::HandleResyncUserData); | 605 AddCallback("resyncUserData", &SigninScreenHandler::HandleResyncUserData); |
| 564 AddCallback("loginUIStateChanged", | 606 AddCallback("loginUIStateChanged", |
| 565 &SigninScreenHandler::HandleLoginUIStateChanged); | 607 &SigninScreenHandler::HandleLoginUIStateChanged); |
| 566 AddCallback("unlockOnLoginSuccess", | 608 AddCallback("unlockOnLoginSuccess", |
| 567 &SigninScreenHandler::HandleUnlockOnLoginSuccess); | 609 &SigninScreenHandler::HandleUnlockOnLoginSuccess); |
| 568 AddCallback("showLoadingTimeoutError", | 610 AddCallback("showLoadingTimeoutError", |
| 569 &SigninScreenHandler::HandleShowLoadingTimeoutError); | 611 &SigninScreenHandler::HandleShowLoadingTimeoutError); |
| 570 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); | 612 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); |
| 613 AddCallback("noPodFocused", &SigninScreenHandler::HandleNoPodFocused); | |
| 571 AddCallback("getPublicSessionKeyboardLayouts", | 614 AddCallback("getPublicSessionKeyboardLayouts", |
| 572 &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); | 615 &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); |
| 573 AddCallback("getTouchViewState", | 616 AddCallback("getTouchViewState", |
| 574 &SigninScreenHandler::HandleGetTouchViewState); | 617 &SigninScreenHandler::HandleGetTouchViewState); |
| 575 AddCallback("logRemoveUserWarningShown", | 618 AddCallback("logRemoveUserWarningShown", |
| 576 &SigninScreenHandler::HandleLogRemoveUserWarningShown); | 619 &SigninScreenHandler::HandleLogRemoveUserWarningShown); |
| 577 AddCallback("firstIncorrectPasswordAttempt", | 620 AddCallback("firstIncorrectPasswordAttempt", |
| 578 &SigninScreenHandler::HandleFirstIncorrectPasswordAttempt); | 621 &SigninScreenHandler::HandleFirstIncorrectPasswordAttempt); |
| 579 AddCallback("maxIncorrectPasswordAttempts", | 622 AddCallback("maxIncorrectPasswordAttempts", |
| 580 &SigninScreenHandler::HandleMaxIncorrectPasswordAttempts); | 623 &SigninScreenHandler::HandleMaxIncorrectPasswordAttempts); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1380 UpdateState(NetworkError::ERROR_REASON_LOADING_TIMEOUT); | 1423 UpdateState(NetworkError::ERROR_REASON_LOADING_TIMEOUT); |
| 1381 } | 1424 } |
| 1382 | 1425 |
| 1383 void SigninScreenHandler::HandleFocusPod(const AccountId& account_id) { | 1426 void SigninScreenHandler::HandleFocusPod(const AccountId& account_id) { |
| 1384 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(account_id); | 1427 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(account_id); |
| 1385 if (delegate_) | 1428 if (delegate_) |
| 1386 delegate_->CheckUserStatus(account_id); | 1429 delegate_->CheckUserStatus(account_id); |
| 1387 if (!test_focus_pod_callback_.is_null()) | 1430 if (!test_focus_pod_callback_.is_null()) |
| 1388 test_focus_pod_callback_.Run(); | 1431 test_focus_pod_callback_.Run(); |
| 1389 | 1432 |
| 1433 focused_pod_account_id_ = base::MakeUnique<AccountId>(account_id); | |
| 1434 | |
| 1390 const user_manager::User* user = | 1435 const user_manager::User* user = |
| 1391 user_manager::UserManager::Get()->FindUser(account_id); | 1436 user_manager::UserManager::Get()->FindUser(account_id); |
| 1392 // |user| may be nullptr in kiosk mode or unit tests. | 1437 // |user| may be nullptr in kiosk mode or unit tests. |
| 1393 if (user && user->is_logged_in() && !user->is_active()) { | 1438 if (user && user->is_logged_in() && !user->is_active()) { |
| 1394 ash::WmShell::Get()->GetSessionStateDelegate()->SwitchActiveUser( | 1439 ash::WmShell::Get()->GetSessionStateDelegate()->SwitchActiveUser( |
| 1395 account_id); | 1440 account_id); |
| 1396 } else { | 1441 } else { |
| 1397 SetUserInputMethod(account_id.GetUserEmail(), ime_state_.get()); | 1442 SetUserInputMethod(account_id.GetUserEmail(), ime_state_.get()); |
| 1398 WallpaperManager::Get()->SetUserWallpaperDelayed(account_id); | 1443 WallpaperManager::Get()->SetUserWallpaperDelayed(account_id); |
| 1399 | 1444 |
| 1400 bool use_24hour_clock = false; | 1445 bool use_24hour_clock = false; |
| 1401 if (user_manager::known_user::GetBooleanPref( | 1446 if (user_manager::known_user::GetBooleanPref( |
| 1402 account_id, prefs::kUse24HourClock, &use_24hour_clock)) { | 1447 account_id, prefs::kUse24HourClock, &use_24hour_clock)) { |
| 1403 g_browser_process->platform_part() | 1448 g_browser_process->platform_part() |
| 1404 ->GetSystemClock() | 1449 ->GetSystemClock() |
| 1405 ->SetLastFocusedPodHourClockType( | 1450 ->SetLastFocusedPodHourClockType( |
| 1406 use_24hour_clock ? base::k24HourClock : base::k12HourClock); | 1451 use_24hour_clock ? base::k24HourClock : base::k12HourClock); |
| 1407 } | 1452 } |
| 1408 } | 1453 } |
| 1409 } | 1454 } |
| 1410 | 1455 |
| 1456 void SigninScreenHandler::HandleNoPodFocused() { | |
| 1457 focused_pod_account_id_.reset(); | |
| 1458 EnforcePolicyInputMethods(std::string()); | |
| 1459 } | |
| 1460 | |
| 1411 void SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts( | 1461 void SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts( |
| 1412 const AccountId& account_id, | 1462 const AccountId& account_id, |
| 1413 const std::string& locale) { | 1463 const std::string& locale) { |
| 1414 GetKeyboardLayoutsForLocale( | 1464 GetKeyboardLayoutsForLocale( |
| 1415 base::Bind(&SigninScreenHandler::SendPublicSessionKeyboardLayouts, | 1465 base::Bind(&SigninScreenHandler::SendPublicSessionKeyboardLayouts, |
| 1416 weak_factory_.GetWeakPtr(), account_id, locale), | 1466 weak_factory_.GetWeakPtr(), account_id, locale), |
| 1417 locale); | 1467 locale); |
| 1418 } | 1468 } |
| 1419 | 1469 |
| 1420 void SigninScreenHandler::SendPublicSessionKeyboardLayouts( | 1470 void SigninScreenHandler::SendPublicSessionKeyboardLayouts( |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1548 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1598 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
| 1549 } | 1599 } |
| 1550 | 1600 |
| 1551 void SigninScreenHandler::OnFeedbackFinished() { | 1601 void SigninScreenHandler::OnFeedbackFinished() { |
| 1552 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); | 1602 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); |
| 1553 | 1603 |
| 1554 // Recreate user's cryptohome after the feedback is attempted. | 1604 // Recreate user's cryptohome after the feedback is attempted. |
| 1555 HandleResyncUserData(); | 1605 HandleResyncUserData(); |
| 1556 } | 1606 } |
| 1557 | 1607 |
| 1608 void SigninScreenHandler::OnAllowedInputMethodsChanged() { | |
| 1609 if (focused_pod_account_id_) { | |
| 1610 std::string user_input_method = | |
| 1611 GetUserLRUInputMethod(focused_pod_account_id_->GetUserEmail()); | |
| 1612 EnforcePolicyInputMethods(user_input_method); | |
| 1613 } else { | |
| 1614 EnforcePolicyInputMethods(std::string()); | |
| 1615 } | |
| 1616 } | |
| 1617 | |
| 1558 } // namespace chromeos | 1618 } // namespace chromeos |
| OLD | NEW |