| 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 if (WallpaperManager::HasInstance()) |
| 291 WallpaperManager::Get()->AddObserver(this); |
| 284 } | 292 } |
| 285 | 293 |
| 286 SigninScreenHandler::~SigninScreenHandler() { | 294 SigninScreenHandler::~SigninScreenHandler() { |
| 287 OobeUI* oobe_ui = GetOobeUI(); | 295 OobeUI* oobe_ui = GetOobeUI(); |
| 288 if (oobe_ui && oobe_ui_observer_added_) | 296 if (oobe_ui && oobe_ui_observer_added_) |
| 289 oobe_ui->RemoveObserver(this); | 297 oobe_ui->RemoveObserver(this); |
| 290 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 298 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 291 this); | 299 this); |
| 292 chromeos::input_method::ImeKeyboard* keyboard = | 300 chromeos::input_method::ImeKeyboard* keyboard = |
| 293 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 301 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 294 if (keyboard) | 302 if (keyboard) |
| 295 keyboard->RemoveObserver(this); | 303 keyboard->RemoveObserver(this); |
| 296 lock_screen_utils::StopEnforcingPolicyInputMethods(); | 304 lock_screen_utils::StopEnforcingPolicyInputMethods(); |
| 297 weak_factory_.InvalidateWeakPtrs(); | 305 weak_factory_.InvalidateWeakPtrs(); |
| 298 if (delegate_) | 306 if (delegate_) |
| 299 delegate_->SetWebUIHandler(nullptr); | 307 delegate_->SetWebUIHandler(nullptr); |
| 300 network_state_informer_->RemoveObserver(this); | 308 network_state_informer_->RemoveObserver(this); |
| 301 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); | 309 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 302 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); | 310 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); |
| 311 if (WallpaperManager::HasInstance()) |
| 312 WallpaperManager::Get()->RemoveObserver(this); |
| 303 } | 313 } |
| 304 | 314 |
| 305 void SigninScreenHandler::DeclareLocalizedValues( | 315 void SigninScreenHandler::DeclareLocalizedValues( |
| 306 ::login::LocalizedValuesBuilder* builder) { | 316 ::login::LocalizedValuesBuilder* builder) { |
| 307 // Format numbers to be used on the pin keyboard. | 317 // Format numbers to be used on the pin keyboard. |
| 308 for (int j = 0; j <= 9; j++) { | 318 for (int j = 0; j <= 9; j++) { |
| 309 builder->Add("pinKeyboard" + base::IntToString(j), | 319 builder->Add("pinKeyboard" + base::IntToString(j), |
| 310 base::FormatNumber(int64_t{j})); | 320 base::FormatNumber(int64_t{j})); |
| 311 } | 321 } |
| 312 | 322 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 859 |
| 850 // Forces a reload for Gaia screen on hiding error message. | 860 // Forces a reload for Gaia screen on hiding error message. |
| 851 if (IsGaiaVisible() || IsGaiaHiddenByError()) | 861 if (IsGaiaVisible() || IsGaiaHiddenByError()) |
| 852 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); | 862 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
| 853 } | 863 } |
| 854 | 864 |
| 855 void SigninScreenHandler::ReloadGaia(bool force_reload) { | 865 void SigninScreenHandler::ReloadGaia(bool force_reload) { |
| 856 gaia_screen_handler_->ReloadGaia(force_reload); | 866 gaia_screen_handler_->ReloadGaia(force_reload); |
| 857 } | 867 } |
| 858 | 868 |
| 869 void SigninScreenHandler::SetSigninScreenColors(SkColor dark_muted_color) { |
| 870 // The dark muted color should have 100% opacity. |
| 871 dark_muted_color = SkColorSetA(dark_muted_color, 0xFF); |
| 872 SkColor base_color = color_utils::GetResultingPaintColor( |
| 873 SkColorSetA(ash::kShelfDefaultBaseColor, |
| 874 ash::kShelfTranslucentColorDarkenAlpha), |
| 875 dark_muted_color); |
| 876 SkColor background_color = |
| 877 SkColorSetA(base_color, ash::kShelfTranslucentAlpha); |
| 878 SkColor scroll_color = SkColorSetA(base_color, kLoginTranslucentAlpha); |
| 879 CallJS("login.AccountPickerScreen.setOverlayColors", |
| 880 color_utils::SkColorToRgbaString(dark_muted_color), |
| 881 color_utils::SkColorToRgbaString(scroll_color), |
| 882 color_utils::SkColorToRgbaString(background_color)); |
| 883 } |
| 884 |
| 859 void SigninScreenHandler::Initialize() { | 885 void SigninScreenHandler::Initialize() { |
| 860 // Preload PIN keyboard if any of the users can authenticate via PIN. | 886 // Preload PIN keyboard if any of the users can authenticate via PIN. |
| 861 if (user_manager::UserManager::IsInitialized()) { | 887 if (user_manager::UserManager::IsInitialized()) { |
| 862 for (user_manager::User* user : | 888 for (user_manager::User* user : |
| 863 user_manager::UserManager::Get()->GetUnlockUsers()) { | 889 user_manager::UserManager::Get()->GetUnlockUsers()) { |
| 864 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 890 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
| 865 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); | 891 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); |
| 866 if (quick_unlock_storage && | 892 if (quick_unlock_storage && |
| 867 quick_unlock_storage->IsPinAuthenticationAvailable()) { | 893 quick_unlock_storage->IsPinAuthenticationAvailable()) { |
| 868 CallJS("cr.ui.Oobe.preloadPinKeyboard"); | 894 CallJS("cr.ui.Oobe.preloadPinKeyboard"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 889 } | 915 } |
| 890 | 916 |
| 891 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, | 917 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, |
| 892 OobeScreen new_screen) { | 918 OobeScreen new_screen) { |
| 893 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { | 919 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { |
| 894 // Restore active IME state if returning to user pod row screen. | 920 // Restore active IME state if returning to user pod row screen. |
| 895 input_method::InputMethodManager::Get()->SetState(ime_state_); | 921 input_method::InputMethodManager::Get()->SetState(ime_state_); |
| 896 } | 922 } |
| 897 } | 923 } |
| 898 | 924 |
| 925 void SigninScreenHandler::OnWallpaperColorsChanged() { |
| 926 base::Optional<SkColor> color = WallpaperManager::Get()->prominent_color(); |
| 927 // If color extraction fails, use transparent as default. |
| 928 if (!color.has_value()) |
| 929 color = SK_ColorTRANSPARENT; |
| 930 SetSigninScreenColors(color.value()); |
| 931 } |
| 932 |
| 933 void SigninScreenHandler::OnWallpaperAnimationFinished( |
| 934 const AccountId& account_id) {} |
| 935 |
| 899 void SigninScreenHandler::ClearAndEnablePassword() { | 936 void SigninScreenHandler::ClearAndEnablePassword() { |
| 900 core_oobe_view_->ResetSignInUI(false); | 937 core_oobe_view_->ResetSignInUI(false); |
| 901 } | 938 } |
| 902 | 939 |
| 903 void SigninScreenHandler::ClearUserPodPassword() { | 940 void SigninScreenHandler::ClearUserPodPassword() { |
| 904 core_oobe_view_->ClearUserPodPassword(); | 941 core_oobe_view_->ClearUserPodPassword(); |
| 905 } | 942 } |
| 906 | 943 |
| 907 void SigninScreenHandler::RefocusCurrentPod() { | 944 void SigninScreenHandler::RefocusCurrentPod() { |
| 908 core_oobe_view_->RefocusCurrentPod(); | 945 core_oobe_view_->RefocusCurrentPod(); |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 if (focused_pod_account_id_) { | 1596 if (focused_pod_account_id_) { |
| 1560 std::string user_input_method = lock_screen_utils::GetUserLastInputMethod( | 1597 std::string user_input_method = lock_screen_utils::GetUserLastInputMethod( |
| 1561 focused_pod_account_id_->GetUserEmail()); | 1598 focused_pod_account_id_->GetUserEmail()); |
| 1562 lock_screen_utils::EnforcePolicyInputMethods(user_input_method); | 1599 lock_screen_utils::EnforcePolicyInputMethods(user_input_method); |
| 1563 } else { | 1600 } else { |
| 1564 lock_screen_utils::EnforcePolicyInputMethods(std::string()); | 1601 lock_screen_utils::EnforcePolicyInputMethods(std::string()); |
| 1565 } | 1602 } |
| 1566 } | 1603 } |
| 1567 | 1604 |
| 1568 } // namespace chromeos | 1605 } // namespace chromeos |
| OLD | NEW |