| 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 20 matching lines...) Expand all Loading... |
| 44 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" | 45 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
| 45 #include "chrome/browser/chromeos/login/reauth_stats.h" | 46 #include "chrome/browser/chromeos/login/reauth_stats.h" |
| 46 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" | 47 #include "chrome/browser/chromeos/login/screens/core_oobe_view.h" |
| 47 #include "chrome/browser/chromeos/login/screens/network_error.h" | 48 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 48 #include "chrome/browser/chromeos/login/startup_utils.h" | 49 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 49 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 50 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 50 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 51 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 51 #include "chrome/browser/chromeos/login/ui/login_feedback.h" | 52 #include "chrome/browser/chromeos/login/ui/login_feedback.h" |
| 52 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 53 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 53 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 54 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 54 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | |
| 55 #include "chrome/browser/chromeos/login/wizard_controller.h" | 55 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 56 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 56 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 57 #include "chrome/browser/chromeos/policy/device_local_account.h" | 57 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 58 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 58 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 59 #include "chrome/browser/chromeos/settings/cros_settings.h" | 59 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 60 #include "chrome/browser/chromeos/system/system_clock.h" | 60 #include "chrome/browser/chromeos/system/system_clock.h" |
| 61 #include "chrome/browser/io_thread.h" | 61 #include "chrome/browser/io_thread.h" |
| 62 #include "chrome/browser/profiles/profile.h" | 62 #include "chrome/browser/profiles/profile.h" |
| 63 #include "chrome/browser/profiles/profile_metrics.h" | 63 #include "chrome/browser/profiles/profile_metrics.h" |
| 64 #include "chrome/browser/signin/easy_unlock_service.h" | 64 #include "chrome/browser/signin/easy_unlock_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 #include "content/public/browser/web_contents.h" | 94 #include "content/public/browser/web_contents.h" |
| 95 #include "content/public/common/service_manager_connection.h" | 95 #include "content/public/common/service_manager_connection.h" |
| 96 #include "google_apis/gaia/gaia_auth_util.h" | 96 #include "google_apis/gaia/gaia_auth_util.h" |
| 97 #include "services/service_manager/public/cpp/connector.h" | 97 #include "services/service_manager/public/cpp/connector.h" |
| 98 #include "third_party/cros_system_api/dbus/service_constants.h" | 98 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 99 #include "ui/base/ime/chromeos/ime_keyboard.h" | 99 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 100 #include "ui/base/ime/chromeos/input_method_descriptor.h" | 100 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
| 101 #include "ui/base/ime/chromeos/input_method_manager.h" | 101 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 102 #include "ui/base/ime/chromeos/input_method_util.h" | 102 #include "ui/base/ime/chromeos/input_method_util.h" |
| 103 #include "ui/base/webui/web_ui_util.h" | 103 #include "ui/base/webui/web_ui_util.h" |
| 104 #include "ui/gfx/color_utils.h" |
| 104 | 105 |
| 105 namespace { | 106 namespace { |
| 106 | 107 |
| 107 // Max number of users to show. | 108 // Max number of users to show. |
| 108 const size_t kMaxUsers = 18; | 109 const size_t kMaxUsers = 18; |
| 109 | 110 |
| 110 // Timeout to delay first notification about offline state for a | 111 // Timeout to delay first notification about offline state for a |
| 111 // current network. | 112 // current network. |
| 112 const int kOfflineTimeoutSec = 5; | 113 const int kOfflineTimeoutSec = 5; |
| 113 | 114 |
| 114 // Timeout used to prevent infinite connecting to a flaky network. | 115 // Timeout used to prevent infinite connecting to a flaky network. |
| 115 const int kConnectingTimeoutSec = 60; | 116 const int kConnectingTimeoutSec = 60; |
| 116 | 117 |
| 117 // Max number of Gaia Reload to Show Proxy Auth Dialog. | 118 // Max number of Gaia Reload to Show Proxy Auth Dialog. |
| 118 const int kMaxGaiaReloadForProxyAuthDialog = 3; | 119 const int kMaxGaiaReloadForProxyAuthDialog = 3; |
| 119 | 120 |
| 120 // Type of the login screen UI that is currently presented to user. | 121 // Type of the login screen UI that is currently presented to user. |
| 121 const char kSourceGaiaSignin[] = "gaia-signin"; | 122 const char kSourceGaiaSignin[] = "gaia-signin"; |
| 122 const char kSourceAccountPicker[] = "account-picker"; | 123 const char kSourceAccountPicker[] = "account-picker"; |
| 123 | 124 |
| 124 // Constants for lock screen apps activity state values: | 125 // Constants for lock screen apps activity state values: |
| 125 const char kNoLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.NONE"; | 126 const char kNoLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.NONE"; |
| 126 const char kBackgroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.BACKGROUND"; | 127 const char kBackgroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.BACKGROUND"; |
| 127 const char kForegroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.FOREGROUND"; | 128 const char kForegroundLockScreenApps[] = "LOCK_SCREEN_APPS_STATE.FOREGROUND"; |
| 128 | 129 |
| 130 // The alpha value for the signin screen background. |
| 131 // TODO(crbug.com/732566): Move all constants related to views-based signin |
| 132 // screen to a separate file. |
| 133 constexpr int kLoginTranslucentAlpha = 76; |
| 134 |
| 129 static bool Contains(const std::vector<std::string>& container, | 135 static bool Contains(const std::vector<std::string>& container, |
| 130 const std::string& value) { | 136 const std::string& value) { |
| 131 return std::find(container.begin(), container.end(), value) != | 137 return std::find(container.begin(), container.end(), value) != |
| 132 container.end(); | 138 container.end(); |
| 133 } | 139 } |
| 134 | 140 |
| 135 class CallOnReturn { | 141 class CallOnReturn { |
| 136 public: | 142 public: |
| 137 explicit CallOnReturn(const base::Closure& callback) | 143 explicit CallOnReturn(const base::Closure& callback) |
| 138 : callback_(callback), call_scheduled_(false) {} | 144 : callback_(callback), call_scheduled_(false) {} |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 content::ServiceManagerConnection::GetForProcess() | 351 content::ServiceManagerConnection::GetForProcess() |
| 346 ->GetConnector() | 352 ->GetConnector() |
| 347 ->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_); | 353 ->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_); |
| 348 ash::mojom::TouchViewObserverPtr observer; | 354 ash::mojom::TouchViewObserverPtr observer; |
| 349 touch_view_binding_.Bind(mojo::MakeRequest(&observer)); | 355 touch_view_binding_.Bind(mojo::MakeRequest(&observer)); |
| 350 touch_view_manager_ptr_->AddObserver(std::move(observer)); | 356 touch_view_manager_ptr_->AddObserver(std::move(observer)); |
| 351 if (ScreenLocker::default_screen_locker() && | 357 if (ScreenLocker::default_screen_locker() && |
| 352 lock_screen_apps::StateController::IsEnabled()) { | 358 lock_screen_apps::StateController::IsEnabled()) { |
| 353 lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get()); | 359 lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get()); |
| 354 } | 360 } |
| 361 WallpaperManager::Get()->AddObserver(this); |
| 355 } | 362 } |
| 356 | 363 |
| 357 SigninScreenHandler::~SigninScreenHandler() { | 364 SigninScreenHandler::~SigninScreenHandler() { |
| 358 OobeUI* oobe_ui = GetOobeUI(); | 365 OobeUI* oobe_ui = GetOobeUI(); |
| 359 if (oobe_ui && oobe_ui_observer_added_) | 366 if (oobe_ui && oobe_ui_observer_added_) |
| 360 oobe_ui->RemoveObserver(this); | 367 oobe_ui->RemoveObserver(this); |
| 361 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 368 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 362 this); | 369 this); |
| 363 chromeos::input_method::ImeKeyboard* keyboard = | 370 chromeos::input_method::ImeKeyboard* keyboard = |
| 364 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 371 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 365 if (keyboard) | 372 if (keyboard) |
| 366 keyboard->RemoveObserver(this); | 373 keyboard->RemoveObserver(this); |
| 367 StopEnforcingPolicyInputMethods(); | 374 StopEnforcingPolicyInputMethods(); |
| 368 weak_factory_.InvalidateWeakPtrs(); | 375 weak_factory_.InvalidateWeakPtrs(); |
| 369 if (delegate_) | 376 if (delegate_) |
| 370 delegate_->SetWebUIHandler(nullptr); | 377 delegate_->SetWebUIHandler(nullptr); |
| 371 network_state_informer_->RemoveObserver(this); | 378 network_state_informer_->RemoveObserver(this); |
| 372 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); | 379 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 373 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); | 380 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); |
| 381 WallpaperManager::Get()->RemoveObserver(this); |
| 374 } | 382 } |
| 375 | 383 |
| 376 // static | 384 // static |
| 377 std::string SigninScreenHandler::GetUserLastInputMethod( | 385 std::string SigninScreenHandler::GetUserLastInputMethod( |
| 378 const std::string& username) { | 386 const std::string& username) { |
| 379 PrefService* const local_state = g_browser_process->local_state(); | 387 PrefService* const local_state = g_browser_process->local_state(); |
| 380 const base::DictionaryValue* users_last_input_methods = | 388 const base::DictionaryValue* users_last_input_methods = |
| 381 local_state->GetDictionary(prefs::kUsersLastInputMethod); | 389 local_state->GetDictionary(prefs::kUsersLastInputMethod); |
| 382 | 390 |
| 383 if (!users_last_input_methods) { | 391 if (!users_last_input_methods) { |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 | 978 |
| 971 // Forces a reload for Gaia screen on hiding error message. | 979 // Forces a reload for Gaia screen on hiding error message. |
| 972 if (IsGaiaVisible() || IsGaiaHiddenByError()) | 980 if (IsGaiaVisible() || IsGaiaHiddenByError()) |
| 973 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); | 981 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
| 974 } | 982 } |
| 975 | 983 |
| 976 void SigninScreenHandler::ReloadGaia(bool force_reload) { | 984 void SigninScreenHandler::ReloadGaia(bool force_reload) { |
| 977 gaia_screen_handler_->ReloadGaia(force_reload); | 985 gaia_screen_handler_->ReloadGaia(force_reload); |
| 978 } | 986 } |
| 979 | 987 |
| 988 void SigninScreenHandler::SetSigninScreenColors(SkColor dark_muted_color) { |
| 989 // The dark muted color should have 100% opacity. |
| 990 dark_muted_color = SkColorSetA(dark_muted_color, 0xFF); |
| 991 SkColor base_color = color_utils::GetResultingPaintColor( |
| 992 SkColorSetA(ash::kShelfDefaultBaseColor, |
| 993 ash::kShelfTranslucentColorDarkenAlpha), |
| 994 dark_muted_color); |
| 995 SkColor background_color = |
| 996 SkColorSetA(base_color, ash::kShelfTranslucentAlpha); |
| 997 SkColor scroll_color = SkColorSetA(base_color, kLoginTranslucentAlpha); |
| 998 CallJS("login.AccountPickerScreen.setOverlayColors", |
| 999 color_utils::SkColorToRgbaString(dark_muted_color), |
| 1000 color_utils::SkColorToRgbaString(scroll_color), |
| 1001 color_utils::SkColorToRgbaString(background_color)); |
| 1002 } |
| 1003 |
| 980 void SigninScreenHandler::Initialize() { | 1004 void SigninScreenHandler::Initialize() { |
| 981 // Preload PIN keyboard if any of the users can authenticate via PIN. | 1005 // Preload PIN keyboard if any of the users can authenticate via PIN. |
| 982 if (user_manager::UserManager::IsInitialized()) { | 1006 if (user_manager::UserManager::IsInitialized()) { |
| 983 for (user_manager::User* user : | 1007 for (user_manager::User* user : |
| 984 user_manager::UserManager::Get()->GetUnlockUsers()) { | 1008 user_manager::UserManager::Get()->GetUnlockUsers()) { |
| 985 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 1009 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
| 986 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); | 1010 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); |
| 987 if (quick_unlock_storage && | 1011 if (quick_unlock_storage && |
| 988 quick_unlock_storage->IsPinAuthenticationAvailable()) { | 1012 quick_unlock_storage->IsPinAuthenticationAvailable()) { |
| 989 CallJS("cr.ui.Oobe.preloadPinKeyboard"); | 1013 CallJS("cr.ui.Oobe.preloadPinKeyboard"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1010 } | 1034 } |
| 1011 | 1035 |
| 1012 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, | 1036 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, |
| 1013 OobeScreen new_screen) { | 1037 OobeScreen new_screen) { |
| 1014 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { | 1038 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { |
| 1015 // Restore active IME state if returning to user pod row screen. | 1039 // Restore active IME state if returning to user pod row screen. |
| 1016 input_method::InputMethodManager::Get()->SetState(ime_state_); | 1040 input_method::InputMethodManager::Get()->SetState(ime_state_); |
| 1017 } | 1041 } |
| 1018 } | 1042 } |
| 1019 | 1043 |
| 1044 void SigninScreenHandler::OnWallpaperColorsChanged() { |
| 1045 base::Optional<SkColor> color = WallpaperManager::Get()->prominent_color(); |
| 1046 // If color extraction fails, use transparent as default. |
| 1047 if (!color.has_value()) |
| 1048 color = SK_ColorTRANSPARENT; |
| 1049 SetSigninScreenColors(color.value()); |
| 1050 } |
| 1051 |
| 1052 void SigninScreenHandler::OnWallpaperAnimationFinished( |
| 1053 const AccountId& account_id) {} |
| 1054 |
| 1020 void SigninScreenHandler::ClearAndEnablePassword() { | 1055 void SigninScreenHandler::ClearAndEnablePassword() { |
| 1021 core_oobe_view_->ResetSignInUI(false); | 1056 core_oobe_view_->ResetSignInUI(false); |
| 1022 } | 1057 } |
| 1023 | 1058 |
| 1024 void SigninScreenHandler::ClearUserPodPassword() { | 1059 void SigninScreenHandler::ClearUserPodPassword() { |
| 1025 core_oobe_view_->ClearUserPodPassword(); | 1060 core_oobe_view_->ClearUserPodPassword(); |
| 1026 } | 1061 } |
| 1027 | 1062 |
| 1028 void SigninScreenHandler::RefocusCurrentPod() { | 1063 void SigninScreenHandler::RefocusCurrentPod() { |
| 1029 core_oobe_view_->RefocusCurrentPod(); | 1064 core_oobe_view_->RefocusCurrentPod(); |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 rate.initial_delay_in_ms = auto_repeat_delay; | 1742 rate.initial_delay_in_ms = auto_repeat_delay; |
| 1708 rate.repeat_interval_in_ms = auto_repeat_interval; | 1743 rate.repeat_interval_in_ms = auto_repeat_interval; |
| 1709 input_method::InputMethodManager::Get() | 1744 input_method::InputMethodManager::Get() |
| 1710 ->GetImeKeyboard() | 1745 ->GetImeKeyboard() |
| 1711 ->SetAutoRepeatEnabled(true); | 1746 ->SetAutoRepeatEnabled(true); |
| 1712 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( | 1747 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( |
| 1713 rate); | 1748 rate); |
| 1714 } | 1749 } |
| 1715 | 1750 |
| 1716 } // namespace chromeos | 1751 } // namespace chromeos |
| OLD | NEW |