| 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> |
| 11 | 11 |
| 12 #include "ash/public/interfaces/constants.mojom.h" | 12 #include "ash/public/interfaces/constants.mojom.h" |
| 13 #include "ash/public/interfaces/tray_action.mojom.h" | 13 #include "ash/public/interfaces/tray_action.mojom.h" |
| 14 #include "ash/shelf/shelf_constants.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/system/devicetype_utils.h" | 16 #include "ash/system/devicetype_utils.h" |
| 16 #include "ash/wm/lock_state_controller.h" | 17 #include "ash/wm/lock_state_controller.h" |
| 17 #include "base/bind.h" | 18 #include "base/bind.h" |
| 18 #include "base/i18n/number_formatting.h" | 19 #include "base/i18n/number_formatting.h" |
| 19 #include "base/location.h" | 20 #include "base/location.h" |
| 20 #include "base/logging.h" | 21 #include "base/logging.h" |
| 21 #include "base/macros.h" | 22 #include "base/macros.h" |
| 22 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
| 23 #include "base/single_thread_task_runner.h" | 24 #include "base/single_thread_task_runner.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" | 46 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
| 46 #include "chrome/browser/chromeos/login/reauth_stats.h" | 47 #include "chrome/browser/chromeos/login/reauth_stats.h" |
| 47 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" | 48 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" |
| 48 #include "chrome/browser/chromeos/login/screens/network_error.h" | 49 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 49 #include "chrome/browser/chromeos/login/startup_utils.h" | 50 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 50 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 51 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 51 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 52 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 52 #include "chrome/browser/chromeos/login/ui/login_feedback.h" | 53 #include "chrome/browser/chromeos/login/ui/login_feedback.h" |
| 53 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 54 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 54 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 55 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 55 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | |
| 56 #include "chrome/browser/chromeos/login/wizard_controller.h" | 56 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 57 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 57 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 58 #include "chrome/browser/chromeos/policy/device_local_account.h" | 58 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 59 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 59 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 60 #include "chrome/browser/chromeos/settings/cros_settings.h" | 60 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 61 #include "chrome/browser/chromeos/system/system_clock.h" | 61 #include "chrome/browser/chromeos/system/system_clock.h" |
| 62 #include "chrome/browser/io_thread.h" | 62 #include "chrome/browser/io_thread.h" |
| 63 #include "chrome/browser/profiles/profile.h" | 63 #include "chrome/browser/profiles/profile.h" |
| 64 #include "chrome/browser/profiles/profile_metrics.h" | 64 #include "chrome/browser/profiles/profile_metrics.h" |
| 65 #include "chrome/browser/signin/easy_unlock_service.h" | 65 #include "chrome/browser/signin/easy_unlock_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 95 #include "content/public/browser/web_contents.h" | 95 #include "content/public/browser/web_contents.h" |
| 96 #include "content/public/common/service_manager_connection.h" | 96 #include "content/public/common/service_manager_connection.h" |
| 97 #include "google_apis/gaia/gaia_auth_util.h" | 97 #include "google_apis/gaia/gaia_auth_util.h" |
| 98 #include "services/service_manager/public/cpp/connector.h" | 98 #include "services/service_manager/public/cpp/connector.h" |
| 99 #include "third_party/cros_system_api/dbus/service_constants.h" | 99 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 100 #include "ui/base/ime/chromeos/ime_keyboard.h" | 100 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 101 #include "ui/base/ime/chromeos/input_method_descriptor.h" | 101 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
| 102 #include "ui/base/ime/chromeos/input_method_manager.h" | 102 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 103 #include "ui/base/ime/chromeos/input_method_util.h" | 103 #include "ui/base/ime/chromeos/input_method_util.h" |
| 104 #include "ui/base/webui/web_ui_util.h" | 104 #include "ui/base/webui/web_ui_util.h" |
| 105 #include "ui/gfx/color_utils.h" |
| 105 | 106 |
| 106 namespace { | 107 namespace { |
| 107 | 108 |
| 108 // Max number of users to show. | 109 // Max number of users to show. |
| 109 const size_t kMaxUsers = 18; | 110 const size_t kMaxUsers = 18; |
| 110 | 111 |
| 111 // Timeout to delay first notification about offline state for a | 112 // Timeout to delay first notification about offline state for a |
| 112 // current network. | 113 // current network. |
| 113 const int kOfflineTimeoutSec = 5; | 114 const int kOfflineTimeoutSec = 5; |
| 114 | 115 |
| 115 // Timeout used to prevent infinite connecting to a flaky network. | 116 // Timeout used to prevent infinite connecting to a flaky network. |
| 116 const int kConnectingTimeoutSec = 60; | 117 const int kConnectingTimeoutSec = 60; |
| 117 | 118 |
| 118 // Max number of Gaia Reload to Show Proxy Auth Dialog. | 119 // Max number of Gaia Reload to Show Proxy Auth Dialog. |
| 119 const int kMaxGaiaReloadForProxyAuthDialog = 3; | 120 const int kMaxGaiaReloadForProxyAuthDialog = 3; |
| 120 | 121 |
| 121 // Type of the login screen UI that is currently presented to user. | 122 // Type of the login screen UI that is currently presented to user. |
| 122 const char kSourceGaiaSignin[] = "gaia-signin"; | 123 const char kSourceGaiaSignin[] = "gaia-signin"; |
| 123 const char kSourceAccountPicker[] = "account-picker"; | 124 const char kSourceAccountPicker[] = "account-picker"; |
| 124 | 125 |
| 125 // Constants for lock screen apps activity state values: | 126 // Constants for lock screen apps activity state values: |
| 126 const char kNoLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.NONE"; | 127 const char kNoLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.NONE"; |
| 127 const char kBackgroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.BACKGROUND"; | 128 const char kBackgroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.BACKGROUND"; |
| 128 const char kForegroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.FOREGROUND"; | 129 const char kForegroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.FOREGROUND"; |
| 129 | 130 |
| 131 // The alpha value for the signin screen background. |
| 132 // TODO(crbug.com/732566): Move all constants related to views-based signin |
| 133 // screen to a separate file. |
| 134 constexpr int kLoginTranslucentAlpha = 76; |
| 135 |
| 130 class CallOnReturn { | 136 class CallOnReturn { |
| 131 public: | 137 public: |
| 132 explicit CallOnReturn(const base::Closure& callback) | 138 explicit CallOnReturn(const base::Closure& callback) |
| 133 : callback_(callback), call_scheduled_(false) {} | 139 : callback_(callback), call_scheduled_(false) {} |
| 134 | 140 |
| 135 ~CallOnReturn() { | 141 ~CallOnReturn() { |
| 136 if (call_scheduled_ && !callback_.is_null()) | 142 if (call_scheduled_ && !callback_.is_null()) |
| 137 callback_.Run(); | 143 callback_.Run(); |
| 138 } | 144 } |
| 139 | 145 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 content::ServiceManagerConnection::GetForProcess() | 280 content::ServiceManagerConnection::GetForProcess() |
| 275 ->GetConnector() | 281 ->GetConnector() |
| 276 ->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_); | 282 ->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_); |
| 277 ash::mojom::TouchViewObserverPtr observer; | 283 ash::mojom::TouchViewObserverPtr observer; |
| 278 touch_view_binding_.Bind(mojo::MakeRequest(&observer)); | 284 touch_view_binding_.Bind(mojo::MakeRequest(&observer)); |
| 279 touch_view_manager_ptr_->AddObserver(std::move(observer)); | 285 touch_view_manager_ptr_->AddObserver(std::move(observer)); |
| 280 if (ScreenLocker::default_screen_locker() && | 286 if (ScreenLocker::default_screen_locker() && |
| 281 lock_screen_apps::StateController::IsEnabled()) { | 287 lock_screen_apps::StateController::IsEnabled()) { |
| 282 lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get()); | 288 lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get()); |
| 283 } | 289 } |
| 290 WallpaperManager::Get()->AddObserver(this); |
| 284 } | 291 } |
| 285 | 292 |
| 286 SigninScreenHandler::~SigninScreenHandler() { | 293 SigninScreenHandler::~SigninScreenHandler() { |
| 287 OobeUI* oobe_ui = GetOobeUI(); | 294 OobeUI* oobe_ui = GetOobeUI(); |
| 288 if (oobe_ui && oobe_ui_observer_added_) | 295 if (oobe_ui && oobe_ui_observer_added_) |
| 289 oobe_ui->RemoveObserver(this); | 296 oobe_ui->RemoveObserver(this); |
| 290 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 297 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 291 this); | 298 this); |
| 292 chromeos::input_method::ImeKeyboard* keyboard = | 299 chromeos::input_method::ImeKeyboard* keyboard = |
| 293 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 300 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 294 if (keyboard) | 301 if (keyboard) |
| 295 keyboard->RemoveObserver(this); | 302 keyboard->RemoveObserver(this); |
| 296 lock_screen_utils::StopEnforcingPolicyInputMethods(); | 303 lock_screen_utils::StopEnforcingPolicyInputMethods(); |
| 297 weak_factory_.InvalidateWeakPtrs(); | 304 weak_factory_.InvalidateWeakPtrs(); |
| 298 if (delegate_) | 305 if (delegate_) |
| 299 delegate_->SetWebUIHandler(nullptr); | 306 delegate_->SetWebUIHandler(nullptr); |
| 300 network_state_informer_->RemoveObserver(this); | 307 network_state_informer_->RemoveObserver(this); |
| 301 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); | 308 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 302 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); | 309 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); |
| 310 WallpaperManager::Get()->RemoveObserver(this); |
| 303 } | 311 } |
| 304 | 312 |
| 305 void SigninScreenHandler::DeclareLocalizedValues( | 313 void SigninScreenHandler::DeclareLocalizedValues( |
| 306 ::login::LocalizedValuesBuilder* builder) { | 314 ::login::LocalizedValuesBuilder* builder) { |
| 307 // Format numbers to be used on the pin keyboard. | 315 // Format numbers to be used on the pin keyboard. |
| 308 for (int j = 0; j <= 9; j++) { | 316 for (int j = 0; j <= 9; j++) { |
| 309 builder->Add("pinKeyboard" + base::IntToString(j), | 317 builder->Add("pinKeyboard" + base::IntToString(j), |
| 310 base::FormatNumber(int64_t{j})); | 318 base::FormatNumber(int64_t{j})); |
| 311 } | 319 } |
| 312 | 320 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 857 |
| 850 // Forces a reload for Gaia screen on hiding error message. | 858 // Forces a reload for Gaia screen on hiding error message. |
| 851 if (IsGaiaVisible() || IsGaiaHiddenByError()) | 859 if (IsGaiaVisible() || IsGaiaHiddenByError()) |
| 852 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); | 860 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
| 853 } | 861 } |
| 854 | 862 |
| 855 void SigninScreenHandler::ReloadGaia(bool force_reload) { | 863 void SigninScreenHandler::ReloadGaia(bool force_reload) { |
| 856 gaia_screen_handler_->ReloadGaia(force_reload); | 864 gaia_screen_handler_->ReloadGaia(force_reload); |
| 857 } | 865 } |
| 858 | 866 |
| 867 void SigninScreenHandler::SetSigninScreenColors(SkColor dark_muted_color) { |
| 868 // The dark muted color should have 100% opacity. |
| 869 dark_muted_color = SkColorSetA(dark_muted_color, 0xFF); |
| 870 SkColor base_color = color_utils::GetResultingPaintColor( |
| 871 SkColorSetA(ash::kShelfDefaultBaseColor, |
| 872 ash::kShelfTranslucentColorDarkenAlpha), |
| 873 dark_muted_color); |
| 874 SkColor background_color = |
| 875 SkColorSetA(base_color, ash::kShelfTranslucentAlpha); |
| 876 SkColor scroll_color = SkColorSetA(base_color, kLoginTranslucentAlpha); |
| 877 CallJS("login.AccountPickerScreen.setOverlayColors", |
| 878 color_utils::SkColorToRgbaString(dark_muted_color), |
| 879 color_utils::SkColorToRgbaString(scroll_color), |
| 880 color_utils::SkColorToRgbaString(background_color)); |
| 881 } |
| 882 |
| 859 void SigninScreenHandler::Initialize() { | 883 void SigninScreenHandler::Initialize() { |
| 860 // Preload PIN keyboard if any of the users can authenticate via PIN. | 884 // Preload PIN keyboard if any of the users can authenticate via PIN. |
| 861 if (user_manager::UserManager::IsInitialized()) { | 885 if (user_manager::UserManager::IsInitialized()) { |
| 862 for (user_manager::User* user : | 886 for (user_manager::User* user : |
| 863 user_manager::UserManager::Get()->GetUnlockUsers()) { | 887 user_manager::UserManager::Get()->GetUnlockUsers()) { |
| 864 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 888 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
| 865 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); | 889 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); |
| 866 if (quick_unlock_storage && | 890 if (quick_unlock_storage && |
| 867 quick_unlock_storage->IsPinAuthenticationAvailable()) { | 891 quick_unlock_storage->IsPinAuthenticationAvailable()) { |
| 868 CallJS("cr.ui.Oobe.preloadPinKeyboard"); | 892 CallJS("cr.ui.Oobe.preloadPinKeyboard"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 889 } | 913 } |
| 890 | 914 |
| 891 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, | 915 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, |
| 892 OobeScreen new_screen) { | 916 OobeScreen new_screen) { |
| 893 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { | 917 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { |
| 894 // Restore active IME state if returning to user pod row screen. | 918 // Restore active IME state if returning to user pod row screen. |
| 895 input_method::InputMethodManager::Get()->SetState(ime_state_); | 919 input_method::InputMethodManager::Get()->SetState(ime_state_); |
| 896 } | 920 } |
| 897 } | 921 } |
| 898 | 922 |
| 923 void SigninScreenHandler::OnWallpaperColorsChanged() { |
| 924 base::Optional<SkColor> color = WallpaperManager::Get()->prominent_color(); |
| 925 // If color extraction fails, use transparent as default. |
| 926 if (!color.has_value()) |
| 927 color = SK_ColorTRANSPARENT; |
| 928 SetSigninScreenColors(color.value()); |
| 929 } |
| 930 |
| 931 void SigninScreenHandler::OnWallpaperAnimationFinished( |
| 932 const AccountId& account_id) {} |
| 933 |
| 899 void SigninScreenHandler::ClearAndEnablePassword() { | 934 void SigninScreenHandler::ClearAndEnablePassword() { |
| 900 core_oobe_view_->ResetSignInUI(false); | 935 core_oobe_view_->ResetSignInUI(false); |
| 901 } | 936 } |
| 902 | 937 |
| 903 void SigninScreenHandler::ClearUserPodPassword() { | 938 void SigninScreenHandler::ClearUserPodPassword() { |
| 904 core_oobe_view_->ClearUserPodPassword(); | 939 core_oobe_view_->ClearUserPodPassword(); |
| 905 } | 940 } |
| 906 | 941 |
| 907 void SigninScreenHandler::RefocusCurrentPod() { | 942 void SigninScreenHandler::RefocusCurrentPod() { |
| 908 core_oobe_view_->RefocusCurrentPod(); | 943 core_oobe_view_->RefocusCurrentPod(); |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 if (focused_pod_account_id_) { | 1594 if (focused_pod_account_id_) { |
| 1560 std::string user_input_method = lock_screen_utils::GetUserLastInputMethod( | 1595 std::string user_input_method = lock_screen_utils::GetUserLastInputMethod( |
| 1561 focused_pod_account_id_->GetUserEmail()); | 1596 focused_pod_account_id_->GetUserEmail()); |
| 1562 lock_screen_utils::EnforcePolicyInputMethods(user_input_method); | 1597 lock_screen_utils::EnforcePolicyInputMethods(user_input_method); |
| 1563 } else { | 1598 } else { |
| 1564 lock_screen_utils::EnforcePolicyInputMethods(std::string()); | 1599 lock_screen_utils::EnforcePolicyInputMethods(std::string()); |
| 1565 } | 1600 } |
| 1566 } | 1601 } |
| 1567 | 1602 |
| 1568 } // namespace chromeos | 1603 } // namespace chromeos |
| OLD | NEW |