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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 chrome::NOTIFICATION_AUTH_SUPPLIED, | 293 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 291 content::NotificationService::AllSources()); | 294 content::NotificationService::AllSources()); |
| 292 registrar_.Add(this, | 295 registrar_.Add(this, |
| 293 chrome::NOTIFICATION_AUTH_CANCELLED, | 296 chrome::NOTIFICATION_AUTH_CANCELLED, |
| 294 content::NotificationService::AllSources()); | 297 content::NotificationService::AllSources()); |
| 295 | 298 |
| 296 chromeos::input_method::ImeKeyboard* keyboard = | 299 chromeos::input_method::ImeKeyboard* keyboard = |
| 297 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 300 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 298 if (keyboard) | 301 if (keyboard) |
| 299 keyboard->AddObserver(this); | 302 keyboard->AddObserver(this); |
| 303 | |
| 304 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 305 PrefService* prefs = g_browser_process->local_state(); | |
| 306 is_enrolling_consumer_management_ = | |
| 307 command_line->HasSwitch(chromeos::switches::kEnableConsumerManagement) && | |
| 308 prefs->GetBoolean(prefs::kConsumerManagementEnrollmentRequested); | |
| 309 | |
| 310 CrosSettings::Get()->GetString(kDeviceOwner, &owner_email_); | |
|
Nikita (slow)
2014/07/31 10:03:43
CrosSettings need to be verified first like here:
davidyu
2014/08/01 07:07:23
I updated the code so that the untrusted value is
| |
| 300 } | 311 } |
| 301 | 312 |
| 302 SigninScreenHandler::~SigninScreenHandler() { | 313 SigninScreenHandler::~SigninScreenHandler() { |
| 303 chromeos::input_method::ImeKeyboard* keyboard = | 314 chromeos::input_method::ImeKeyboard* keyboard = |
| 304 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 315 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 305 if (keyboard) | 316 if (keyboard) |
| 306 keyboard->RemoveObserver(this); | 317 keyboard->RemoveObserver(this); |
| 307 weak_factory_.InvalidateWeakPtrs(); | 318 weak_factory_.InvalidateWeakPtrs(); |
| 308 if (delegate_) | 319 if (delegate_) |
| 309 delegate_->SetWebUIHandler(NULL); | 320 delegate_->SetWebUIHandler(NULL); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 | 424 |
| 414 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) | 425 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) |
| 415 builder->Add("demoLoginMessage", IDS_KIOSK_MODE_LOGIN_MESSAGE); | 426 builder->Add("demoLoginMessage", IDS_KIOSK_MODE_LOGIN_MESSAGE); |
| 416 } | 427 } |
| 417 | 428 |
| 418 void SigninScreenHandler::Show(const LoginScreenContext& context) { | 429 void SigninScreenHandler::Show(const LoginScreenContext& context) { |
| 419 CHECK(delegate_); | 430 CHECK(delegate_); |
| 420 | 431 |
| 421 // Just initialize internal fields from context and call ShowImpl(). | 432 // Just initialize internal fields from context and call ShowImpl(). |
| 422 oobe_ui_ = context.oobe_ui(); | 433 oobe_ui_ = context.oobe_ui(); |
| 423 gaia_screen_handler_->PopulateEmail(context.email()); | 434 gaia_screen_handler_->PopulateEmail( |
| 435 is_enrolling_consumer_management_ ? owner_email_ : context.email()); | |
| 424 ShowImpl(); | 436 ShowImpl(); |
| 425 } | 437 } |
| 426 | 438 |
| 427 void SigninScreenHandler::ShowRetailModeLoginSpinner() { | 439 void SigninScreenHandler::ShowRetailModeLoginSpinner() { |
| 428 CallJS("showLoginSpinner"); | 440 CallJS("showLoginSpinner"); |
| 429 } | 441 } |
| 430 | 442 |
| 431 void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { | 443 void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { |
| 432 delegate_ = delegate; | 444 delegate_ = delegate; |
| 433 if (delegate_) | 445 if (delegate_) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 452 } | 464 } |
| 453 | 465 |
| 454 // SigninScreenHandler, private: ----------------------------------------------- | 466 // SigninScreenHandler, private: ----------------------------------------------- |
| 455 | 467 |
| 456 void SigninScreenHandler::ShowImpl() { | 468 void SigninScreenHandler::ShowImpl() { |
| 457 if (!page_is_ready()) { | 469 if (!page_is_ready()) { |
| 458 show_on_init_ = true; | 470 show_on_init_ = true; |
| 459 return; | 471 return; |
| 460 } | 472 } |
| 461 | 473 |
| 462 if (oobe_ui_) { | 474 if (oobe_ui_ || is_enrolling_consumer_management_) { |
| 463 // Shows new user sign-in for OOBE. | 475 // Shows new user sign-in for OOBE. |
| 464 OnShowAddUser(); | 476 OnShowAddUser(); |
| 465 } else { | 477 } else { |
| 466 // Populates account picker. Animation is turned off for now until we | 478 // Populates account picker. Animation is turned off for now until we |
| 467 // figure out how to make it fast enough. | 479 // figure out how to make it fast enough. |
| 468 delegate_->HandleGetUsers(); | 480 delegate_->HandleGetUsers(); |
| 469 | 481 |
| 470 // Reset Caps Lock state when login screen is shown. | 482 // Reset Caps Lock state when login screen is shown. |
| 471 input_method::InputMethodManager::Get() | 483 input_method::InputMethodManager::Get() |
| 472 ->GetImeKeyboard() | 484 ->GetImeKeyboard() |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 &SigninScreenHandler::HandleUnlockOnLoginSuccess); | 756 &SigninScreenHandler::HandleUnlockOnLoginSuccess); |
| 745 AddCallback("showLoadingTimeoutError", | 757 AddCallback("showLoadingTimeoutError", |
| 746 &SigninScreenHandler::HandleShowLoadingTimeoutError); | 758 &SigninScreenHandler::HandleShowLoadingTimeoutError); |
| 747 AddCallback("updateOfflineLogin", | 759 AddCallback("updateOfflineLogin", |
| 748 &SigninScreenHandler::HandleUpdateOfflineLogin); | 760 &SigninScreenHandler::HandleUpdateOfflineLogin); |
| 749 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); | 761 AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod); |
| 750 AddCallback("retrieveAuthenticatedUserEmail", | 762 AddCallback("retrieveAuthenticatedUserEmail", |
| 751 &SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); | 763 &SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail); |
| 752 AddCallback("getPublicSessionKeyboardLayouts", | 764 AddCallback("getPublicSessionKeyboardLayouts", |
| 753 &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); | 765 &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); |
| 766 AddCallback("cancelConsumerManagementEnrollment", | |
| 767 &SigninScreenHandler::HandleCancelConsumerManagementEnrollment); | |
| 754 | 768 |
| 755 | 769 |
| 756 // This message is sent by the kiosk app menu, but is handled here | 770 // This message is sent by the kiosk app menu, but is handled here |
| 757 // so we can tell the delegate to launch the app. | 771 // so we can tell the delegate to launch the app. |
| 758 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); | 772 AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp); |
| 759 } | 773 } |
| 760 | 774 |
| 761 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { | 775 void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
| 762 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); | 776 registry->RegisterDictionaryPref(prefs::kUsersLRUInputMethod); |
| 763 } | 777 } |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1301 | 1315 |
| 1302 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, | 1316 void SigninScreenHandler::HandleLaunchKioskApp(const std::string& app_id, |
| 1303 bool diagnostic_mode) { | 1317 bool diagnostic_mode) { |
| 1304 UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_id); | 1318 UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_id); |
| 1305 SigninSpecifics specifics; | 1319 SigninSpecifics specifics; |
| 1306 specifics.kiosk_diagnostic_mode = diagnostic_mode; | 1320 specifics.kiosk_diagnostic_mode = diagnostic_mode; |
| 1307 if (delegate_) | 1321 if (delegate_) |
| 1308 delegate_->Login(context, specifics); | 1322 delegate_->Login(context, specifics); |
| 1309 } | 1323 } |
| 1310 | 1324 |
| 1325 void SigninScreenHandler::HandleCancelConsumerManagementEnrollment() { | |
| 1326 PrefService* prefs = g_browser_process->local_state(); | |
| 1327 prefs->SetBoolean(prefs::kConsumerManagementEnrollmentRequested, false); | |
| 1328 is_enrolling_consumer_management_ = false; | |
| 1329 ShowImpl(); | |
| 1330 } | |
| 1331 | |
| 1311 bool SigninScreenHandler::AllWhitelistedUsersPresent() { | 1332 bool SigninScreenHandler::AllWhitelistedUsersPresent() { |
| 1312 CrosSettings* cros_settings = CrosSettings::Get(); | 1333 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1313 bool allow_new_user = false; | 1334 bool allow_new_user = false; |
| 1314 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1335 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1315 if (allow_new_user) | 1336 if (allow_new_user) |
| 1316 return false; | 1337 return false; |
| 1317 UserManager* user_manager = UserManager::Get(); | 1338 UserManager* user_manager = UserManager::Get(); |
| 1318 const user_manager::UserList& users = user_manager->GetUsers(); | 1339 const user_manager::UserList& users = user_manager->GetUsers(); |
| 1319 if (!delegate_ || users.size() > kMaxUsers) { | 1340 if (!delegate_ || users.size() > kMaxUsers) { |
| 1320 return false; | 1341 return false; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1406 if (delegate_) | 1427 if (delegate_) |
| 1407 delegate_->ShowKioskEnableScreen(); | 1428 delegate_->ShowKioskEnableScreen(); |
| 1408 break; | 1429 break; |
| 1409 } | 1430 } |
| 1410 auto_enrollment_progress_subscription_.reset(); | 1431 auto_enrollment_progress_subscription_.reset(); |
| 1411 } | 1432 } |
| 1412 | 1433 |
| 1413 void SigninScreenHandler::OnShowAddUser() { | 1434 void SigninScreenHandler::OnShowAddUser() { |
| 1414 is_account_picker_showing_first_time_ = false; | 1435 is_account_picker_showing_first_time_ = false; |
| 1415 DCHECK(gaia_screen_handler_); | 1436 DCHECK(gaia_screen_handler_); |
| 1416 gaia_screen_handler_->ShowGaia(); | 1437 gaia_screen_handler_->ShowGaia(is_enrolling_consumer_management_); |
| 1417 } | 1438 } |
| 1418 | 1439 |
| 1419 GaiaScreenHandler::FrameState SigninScreenHandler::FrameState() const { | 1440 GaiaScreenHandler::FrameState SigninScreenHandler::FrameState() const { |
| 1420 DCHECK(gaia_screen_handler_); | 1441 DCHECK(gaia_screen_handler_); |
| 1421 return gaia_screen_handler_->frame_state(); | 1442 return gaia_screen_handler_->frame_state(); |
| 1422 } | 1443 } |
| 1423 | 1444 |
| 1424 net::Error SigninScreenHandler::FrameError() const { | 1445 net::Error SigninScreenHandler::FrameError() const { |
| 1425 DCHECK(gaia_screen_handler_); | 1446 DCHECK(gaia_screen_handler_); |
| 1426 return gaia_screen_handler_->frame_error(); | 1447 return gaia_screen_handler_->frame_error(); |
| 1427 } | 1448 } |
| 1428 | 1449 |
| 1429 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { | 1450 void SigninScreenHandler::OnCapsLockChanged(bool enabled) { |
| 1430 caps_lock_enabled_ = enabled; | 1451 caps_lock_enabled_ = enabled; |
| 1431 if (page_is_ready()) | 1452 if (page_is_ready()) |
| 1432 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); | 1453 CallJS("login.AccountPickerScreen.setCapsLockState", caps_lock_enabled_); |
| 1433 } | 1454 } |
| 1434 | 1455 |
| 1435 } // namespace chromeos | 1456 } // namespace chromeos |
| OLD | NEW |