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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | |
| 11 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
| 16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 17 #include "base/prefs/scoped_user_pref_update.h" | 18 #include "base/prefs/scoped_user_pref_update.h" |
| 18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 25 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 25 #include "chrome/browser/browser_shutdown.h" | 26 #include "chrome/browser/browser_shutdown.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 28 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 28 #include "chrome/browser/chromeos/boot_times_loader.h" | 29 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 29 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 30 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 30 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 31 #include "chrome/browser/chromeos/login/hwid_checker.h" | 32 #include "chrome/browser/chromeos/login/hwid_checker.h" |
| 32 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 33 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 33 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 34 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
| 34 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 35 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 35 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 36 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 36 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 37 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 37 #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/user_manager.h" | |
| 38 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 40 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 39 #include "chrome/browser/chromeos/login/wizard_controller.h" | 41 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 42 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 41 #include "chrome/browser/chromeos/policy/device_local_account.h" | 43 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 42 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 44 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 43 #include "chrome/browser/chromeos/settings/cros_settings.h" | 45 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 44 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h" | 46 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h" |
| 45 #include "chrome/browser/io_thread.h" | 47 #include "chrome/browser/io_thread.h" |
| 46 #include "chrome/browser/profiles/profile.h" | 48 #include "chrome/browser/profiles/profile.h" |
| 47 #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" |
| 48 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" | 50 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" |
| 49 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 51 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 50 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" | 52 #include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" |
| 51 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 53 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 52 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 54 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 53 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
| 54 #include "chrome/common/url_constants.h" | 56 #include "chrome/common/url_constants.h" |
| 57 #include "chromeos/chromeos_switches.h" | |
| 55 #include "chromeos/dbus/dbus_thread_manager.h" | 58 #include "chromeos/dbus/dbus_thread_manager.h" |
| 56 #include "chromeos/dbus/power_manager_client.h" | 59 #include "chromeos/dbus/power_manager_client.h" |
| 57 #include "chromeos/ime/ime_keyboard.h" | 60 #include "chromeos/ime/ime_keyboard.h" |
| 58 #include "chromeos/ime/input_method_descriptor.h" | 61 #include "chromeos/ime/input_method_descriptor.h" |
| 59 #include "chromeos/ime/input_method_manager.h" | 62 #include "chromeos/ime/input_method_manager.h" |
| 60 #include "chromeos/login/auth/key.h" | 63 #include "chromeos/login/auth/key.h" |
| 61 #include "chromeos/login/auth/user_context.h" | 64 #include "chromeos/login/auth/user_context.h" |
| 62 #include "chromeos/network/network_state.h" | 65 #include "chromeos/network/network_state.h" |
| 63 #include "chromeos/network/network_state_handler.h" | 66 #include "chromeos/network/network_state_handler.h" |
| 64 #include "chromeos/network/portal_detector/network_portal_detector.h" | 67 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 chrome::NOTIFICATION_AUTH_SUPPLIED, | 291 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 289 content::NotificationService::AllSources()); | 292 content::NotificationService::AllSources()); |
| 290 registrar_.Add(this, | 293 registrar_.Add(this, |
| 291 chrome::NOTIFICATION_AUTH_CANCELLED, | 294 chrome::NOTIFICATION_AUTH_CANCELLED, |
| 292 content::NotificationService::AllSources()); | 295 content::NotificationService::AllSources()); |
| 293 | 296 |
| 294 chromeos::input_method::ImeKeyboard* keyboard = | 297 chromeos::input_method::ImeKeyboard* keyboard = |
| 295 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 298 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 296 if (keyboard) | 299 if (keyboard) |
| 297 keyboard->AddObserver(this); | 300 keyboard->AddObserver(this); |
| 301 | |
| 302 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
|
bartfab (slow)
2014/08/04 17:40:52
Nit: const.
davidyu
2014/08/05 07:24:06
Done.
| |
| 303 PrefService* prefs = g_browser_process->local_state(); | |
|
bartfab (slow)
2014/08/04 17:40:52
Nit: const.
davidyu
2014/08/05 07:24:06
This line is removed.
| |
| 304 is_enrolling_consumer_management_ = | |
| 305 command_line->HasSwitch(chromeos::switches::kEnableConsumerManagement) && | |
| 306 prefs->GetBoolean(prefs::kConsumerManagementEnrollmentRequested); | |
| 307 | |
| 298 } | 308 } |
| 299 | 309 |
| 300 SigninScreenHandler::~SigninScreenHandler() { | 310 SigninScreenHandler::~SigninScreenHandler() { |
| 301 chromeos::input_method::ImeKeyboard* keyboard = | 311 chromeos::input_method::ImeKeyboard* keyboard = |
| 302 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 312 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 303 if (keyboard) | 313 if (keyboard) |
| 304 keyboard->RemoveObserver(this); | 314 keyboard->RemoveObserver(this); |
| 305 weak_factory_.InvalidateWeakPtrs(); | 315 weak_factory_.InvalidateWeakPtrs(); |
| 306 if (delegate_) | 316 if (delegate_) |
| 307 delegate_->SetWebUIHandler(NULL); | 317 delegate_->SetWebUIHandler(NULL); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 | 421 |
| 412 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) | 422 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) |
| 413 builder->Add("demoLoginMessage", IDS_KIOSK_MODE_LOGIN_MESSAGE); | 423 builder->Add("demoLoginMessage", IDS_KIOSK_MODE_LOGIN_MESSAGE); |
| 414 } | 424 } |
| 415 | 425 |
| 416 void SigninScreenHandler::Show(const LoginScreenContext& context) { | 426 void SigninScreenHandler::Show(const LoginScreenContext& context) { |
| 417 CHECK(delegate_); | 427 CHECK(delegate_); |
| 418 | 428 |
| 419 // Just initialize internal fields from context and call ShowImpl(). | 429 // Just initialize internal fields from context and call ShowImpl(). |
| 420 oobe_ui_ = context.oobe_ui(); | 430 oobe_ui_ = context.oobe_ui(); |
| 421 gaia_screen_handler_->PopulateEmail(context.email()); | 431 |
| 432 std::string email; | |
| 433 if (is_enrolling_consumer_management_) { | |
| 434 // We don't check if the value of the owner email is trusted because it is | |
|
bartfab (slow)
2014/08/04 17:40:52
Nit: s/email/e-mail/
davidyu
2014/08/05 07:24:06
Done.
| |
| 435 // only used to pre-fill the email field in Gaia sign-in page and a cached | |
|
bartfab (slow)
2014/08/04 17:40:52
Nit: s/email/e-mail/
davidyu
2014/08/05 07:24:05
Done.
| |
| 436 // value is sufficient. | |
| 437 CrosSettings::Get()->GetString(kDeviceOwner, &email); | |
| 438 } else { | |
| 439 email = context.email(); | |
| 440 } | |
| 441 gaia_screen_handler_->PopulateEmail(email); | |
| 422 ShowImpl(); | 442 ShowImpl(); |
| 423 } | 443 } |
| 424 | 444 |
| 425 void SigninScreenHandler::ShowRetailModeLoginSpinner() { | 445 void SigninScreenHandler::ShowRetailModeLoginSpinner() { |
| 426 CallJS("showLoginSpinner"); | 446 CallJS("showLoginSpinner"); |
| 427 } | 447 } |
| 428 | 448 |
| 429 void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { | 449 void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { |
| 430 delegate_ = delegate; | 450 delegate_ = delegate; |
| 431 if (delegate_) | 451 if (delegate_) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 450 } | 470 } |
| 451 | 471 |
| 452 // SigninScreenHandler, private: ----------------------------------------------- | 472 // SigninScreenHandler, private: ----------------------------------------------- |
| 453 | 473 |
| 454 void SigninScreenHandler::ShowImpl() { | 474 void SigninScreenHandler::ShowImpl() { |
| 455 if (!page_is_ready()) { | 475 if (!page_is_ready()) { |
| 456 show_on_init_ = true; | 476 show_on_init_ = true; |
| 457 return; | 477 return; |
| 458 } | 478 } |
| 459 | 479 |
| 460 if (oobe_ui_) { | 480 if (oobe_ui_ || is_enrolling_consumer_management_) { |
| 461 // Shows new user sign-in for OOBE. | 481 // Shows new user sign-in for OOBE. |
| 462 OnShowAddUser(); | 482 OnShowAddUser(); |
| 463 } else { | 483 } else { |
| 464 // Populates account picker. Animation is turned off for now until we | 484 // Populates account picker. Animation is turned off for now until we |
| 465 // figure out how to make it fast enough. | 485 // figure out how to make it fast enough. |
| 466 delegate_->HandleGetUsers(); | 486 delegate_->HandleGetUsers(); |
| 467 | 487 |
| 468 // Reset Caps Lock state when login screen is shown. | 488 // Reset Caps Lock state when login screen is shown. |
| 469 input_method::InputMethodManager::Get() | 489 input_method::InputMethodManager::Get() |
| 470 ->GetImeKeyboard() | 490 ->GetImeKeyboard() |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 &SigninScreenHandler::HandleUnlockOnLoginSuccess); | 762 &SigninScreenHandler::HandleUnlockOnLoginSuccess); |
| 743 AddCallback("showLoadingTimeoutError", | 763 AddCallback("showLoadingTimeoutError", |
| 744 &SigninScreenHandler::HandleShowLoadingTimeoutError); | 764 &SigninScreenHandler::HandleShowLoadingTimeoutError); |
| 745 AddCallback("updateOfflineLogin", | 765 AddCallback("updateOfflineLogin", |
| 746 &SigninScreenHandler::HandleUpdateOfflineLogin); | 766 &SigninScreenHandler::HandleUpdateOfflineLogin); |
| 747 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); | 767 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); |
| 748 AddCallback("retrieveAuthenticatedUserEmail", | 768 AddCallback("retrieveAuthenticatedUserEmail", |
| 749 &SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); | 769 &SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); |
| 750 AddCallback("getPublicSessionKeyboardLayouts", | 770 AddCallback("getPublicSessionKeyboardLayouts", |
| 751 &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); | 771 &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); |
| 772 AddCallback("cancelConsumerManagementEnrollment", | |
| 773 &SigninScreenHandler::HandleCancelConsumerManagementEnrollment); | |
| 752 | 774 |
| 753 | 775 |
| 754 // This message is sent by the kiosk app menu, but is handled here | 776 // This message is sent by the kiosk app menu, but is handled here |
| 755 // so we can tell the delegate to launch the app. | 777 // so we can tell the delegate to launch the app. |
| 756 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); | 778 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); |
| 757 } | 779 } |
| 758 | 780 |
| 759 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 781 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
| 760 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); | 782 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); |
| 761 } | 783 } |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1315 | 1337 |
| 1316 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, | 1338 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, |
| 1317 bool diagnostic_mode) { | 1339 bool diagnostic_mode) { |
| 1318 UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_id); | 1340 UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_id); |
| 1319 SigninSpecifics specifics; | 1341 SigninSpecifics specifics; |
| 1320 specifics.kiosk_diagnostic_mode = diagnostic_mode; | 1342 specifics.kiosk_diagnostic_mode = diagnostic_mode; |
| 1321 if (delegate_) | 1343 if (delegate_) |
| 1322 delegate_->Login(context, specifics); | 1344 delegate_->Login(context, specifics); |
| 1323 } | 1345 } |
| 1324 | 1346 |
| 1347 void SigninScreenHandler::HandleCancelConsumerManagementEnrollment() { | |
| 1348 PrefService* prefs = g_browser_process->local_state(); | |
|
bartfab (slow)
2014/08/04 17:40:52
Nit: const.
davidyu
2014/08/05 07:24:06
This line is removed.
| |
| 1349 prefs->SetBoolean(prefs::kConsumerManagementEnrollmentRequested, false); | |
| 1350 is_enrolling_consumer_management_ = false; | |
| 1351 ShowImpl(); | |
| 1352 } | |
| 1353 | |
| 1325 bool SigninScreenHandler::AllWhitelistedUsersPresent() { | 1354 bool SigninScreenHandler::AllWhitelistedUsersPresent() { |
| 1326 CrosSettings* cros_settings = CrosSettings::Get(); | 1355 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1327 bool allow_new_user = false; | 1356 bool allow_new_user = false; |
| 1328 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1357 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1329 if (allow_new_user) | 1358 if (allow_new_user) |
| 1330 return false; | 1359 return false; |
| 1331 UserManager* user_manager = UserManager::Get(); | 1360 UserManager* user_manager = UserManager::Get(); |
| 1332 const user_manager::UserList& users = user_manager->GetUsers(); | 1361 const user_manager::UserList& users = user_manager->GetUsers(); |
| 1333 if (!delegate_ || users.size() > kMaxUsers) { | 1362 if (!delegate_ || users.size() > kMaxUsers) { |
| 1334 return false; | 1363 return false; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1420 if (delegate_) | 1449 if (delegate_) |
| 1421 delegate_->ShowKioskEnableScreen(); | 1450 delegate_->ShowKioskEnableScreen(); |
| 1422 break; | 1451 break; |
| 1423 } | 1452 } |
| 1424 auto_enrollment_progress_subscription_.reset(); | 1453 auto_enrollment_progress_subscription_.reset(); |
| 1425 } | 1454 } |
| 1426 | 1455 |
| 1427 void SigninScreenHandler::OnShowAddUser() { | 1456 void SigninScreenHandler::OnShowAddUser() { |
| 1428 is_account_picker_showing_first_time_ = false; | 1457 is_account_picker_showing_first_time_ = false; |
| 1429 DCHECK(gaia_screen_handler_); | 1458 DCHECK(gaia_screen_handler_); |
| 1430 gaia_screen_handler_->ShowGaia(); | 1459 gaia_screen_handler_->ShowGaia(is_enrolling_consumer_management_); |
| 1431 } | 1460 } |
| 1432 | 1461 |
| 1433 GaiaScreenHandler::FrameState SigninScreenHandler::FrameState() const { | 1462 GaiaScreenHandler::FrameState SigninScreenHandler::FrameState() const { |
| 1434 DCHECK(gaia_screen_handler_); | 1463 DCHECK(gaia_screen_handler_); |
| 1435 return gaia_screen_handler_->frame_state(); | 1464 return gaia_screen_handler_->frame_state(); |
| 1436 } | 1465 } |
| 1437 | 1466 |
| 1438 net::Error SigninScreenHandler::FrameError() const { | 1467 net::Error SigninScreenHandler::FrameError() const { |
| 1439 DCHECK(gaia_screen_handler_); | 1468 DCHECK(gaia_screen_handler_); |
| 1440 return gaia_screen_handler_->frame_error(); | 1469 return gaia_screen_handler_->frame_error(); |
| 1441 } | 1470 } |
| 1442 | 1471 |
| 1443 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1472 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
| 1444 caps_lock_enabled_ = enabled; | 1473 caps_lock_enabled_ = enabled; |
| 1445 if (page_is_ready()) | 1474 if (page_is_ready()) |
| 1446 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1475 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
| 1447 } | 1476 } |
| 1448 | 1477 |
| 1449 } // namespace chromeos | 1478 } // namespace chromeos |
| OLD | NEW |