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