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 <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 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 content::ServiceManagerConnection::GetForProcess() | 346 content::ServiceManagerConnection::GetForProcess() |
| 346 ->GetConnector() | 347 ->GetConnector() |
| 347 ->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_); | 348 ->BindInterface(ash::mojom::kServiceName, &touch_view_manager_ptr_); |
| 348 ash::mojom::TouchViewObserverPtr observer; | 349 ash::mojom::TouchViewObserverPtr observer; |
| 349 touch_view_binding_.Bind(mojo::MakeRequest(&observer)); | 350 touch_view_binding_.Bind(mojo::MakeRequest(&observer)); |
| 350 touch_view_manager_ptr_->AddObserver(std::move(observer)); | 351 touch_view_manager_ptr_->AddObserver(std::move(observer)); |
| 351 if (ScreenLocker::default_screen_locker() && | 352 if (ScreenLocker::default_screen_locker() && |
| 352 lock_screen_apps::StateController::IsEnabled()) { | 353 lock_screen_apps::StateController::IsEnabled()) { |
| 353 lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get()); | 354 lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get()); |
| 354 } | 355 } |
| 356 WallpaperManager::Get()->AddObserver(this); | |
| 355 } | 357 } |
| 356 | 358 |
| 357 SigninScreenHandler::~SigninScreenHandler() { | 359 SigninScreenHandler::~SigninScreenHandler() { |
| 358 OobeUI* oobe_ui = GetOobeUI(); | 360 OobeUI* oobe_ui = GetOobeUI(); |
| 359 if (oobe_ui && oobe_ui_observer_added_) | 361 if (oobe_ui && oobe_ui_observer_added_) |
| 360 oobe_ui->RemoveObserver(this); | 362 oobe_ui->RemoveObserver(this); |
| 361 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | 363 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 362 this); | 364 this); |
| 363 chromeos::input_method::ImeKeyboard* keyboard = | 365 chromeos::input_method::ImeKeyboard* keyboard = |
| 364 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); | 366 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); |
| 365 if (keyboard) | 367 if (keyboard) |
| 366 keyboard->RemoveObserver(this); | 368 keyboard->RemoveObserver(this); |
| 367 StopEnforcingPolicyInputMethods(); | 369 StopEnforcingPolicyInputMethods(); |
| 368 weak_factory_.InvalidateWeakPtrs(); | 370 weak_factory_.InvalidateWeakPtrs(); |
| 369 if (delegate_) | 371 if (delegate_) |
| 370 delegate_->SetWebUIHandler(nullptr); | 372 delegate_->SetWebUIHandler(nullptr); |
| 371 network_state_informer_->RemoveObserver(this); | 373 network_state_informer_->RemoveObserver(this); |
| 372 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); | 374 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr); |
| 373 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); | 375 proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId()); |
| 376 WallpaperManager::Get()->RemoveObserver(this); | |
| 374 } | 377 } |
| 375 | 378 |
| 376 // static | 379 // static |
| 377 std::string SigninScreenHandler::GetUserLastInputMethod( | 380 std::string SigninScreenHandler::GetUserLastInputMethod( |
| 378 const std::string& username) { | 381 const std::string& username) { |
| 379 PrefService* const local_state = g_browser_process->local_state(); | 382 PrefService* const local_state = g_browser_process->local_state(); |
| 380 const base::DictionaryValue* users_last_input_methods = | 383 const base::DictionaryValue* users_last_input_methods = |
| 381 local_state->GetDictionary(prefs::kUsersLastInputMethod); | 384 local_state->GetDictionary(prefs::kUsersLastInputMethod); |
| 382 | 385 |
| 383 if (!users_last_input_methods) { | 386 if (!users_last_input_methods) { |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 | 973 |
| 971 // Forces a reload for Gaia screen on hiding error message. | 974 // Forces a reload for Gaia screen on hiding error message. |
| 972 if (IsGaiaVisible() || IsGaiaHiddenByError()) | 975 if (IsGaiaVisible() || IsGaiaHiddenByError()) |
| 973 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); | 976 ReloadGaia(reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED); |
| 974 } | 977 } |
| 975 | 978 |
| 976 void SigninScreenHandler::ReloadGaia(bool force_reload) { | 979 void SigninScreenHandler::ReloadGaia(bool force_reload) { |
| 977 gaia_screen_handler_->ReloadGaia(force_reload); | 980 gaia_screen_handler_->ReloadGaia(force_reload); |
| 978 } | 981 } |
| 979 | 982 |
| 983 void SigninScreenHandler::SetSigninScreenColors(const SkColor& dm_color) { | |
|
jdufault
2017/06/12 21:37:28
Just pass a SkColor dm_color parameter and mutate
Wenzhao (Colin) Zang
2017/06/12 23:40:35
Done. Originally I wanted to prevent mistakenly ch
| |
| 984 // The dark muted color should have 100% opacity. | |
| 985 SkColor dm_sk_color = dm_color; | |
|
jdufault
2017/06/12 21:37:29
avoid non-obvious acronyms (dm). It makes the code
Wenzhao (Colin) Zang
2017/06/12 23:40:34
Done.
| |
| 986 dm_sk_color = SkColorSetA(dm_sk_color, 0xFF); | |
|
jdufault
2017/06/12 21:37:29
FYI: naming here is confusing; what is the differe
Wenzhao (Colin) Zang
2017/06/12 23:40:35
Done.
| |
| 987 SkColor base_sk_color = color_utils::GetResultingPaintColor( | |
| 988 SkColorSetA(ash::kShelfDefaultBaseColor, | |
| 989 ash::kShelfTranslucentColorDarkenAlpha), | |
| 990 dm_sk_color); | |
| 991 SkColor background_sk_color = | |
|
jdufault
2017/06/12 21:37:29
background_sk_color -> background_color
Wenzhao (Colin) Zang
2017/06/12 23:40:34
Done.
| |
| 992 SkColorSetA(base_sk_color, ash::kShelfTranslucentAlpha); | |
| 993 // The alpha value for the signin screen background. This constant will be | |
| 994 // moved to a separate file when views-based signin screen is being | |
|
jdufault
2017/06/12 21:37:29
Add TODO and file a bug.
Wenzhao (Colin) Zang
2017/06/12 23:40:34
Done.
| |
| 995 // developed. | |
| 996 constexpr int kLoginTranslucentAlpha = 76; | |
|
jdufault
2017/06/12 21:37:29
move to anonymous namespace
Wenzhao (Colin) Zang
2017/06/12 23:40:34
Done.
| |
| 997 SkColor scroll_sk_color = SkColorSetA(base_sk_color, kLoginTranslucentAlpha); | |
|
jdufault
2017/06/12 21:37:29
scroll_sk_color -> scroll_color
Wenzhao (Colin) Zang
2017/06/12 23:40:35
Done.
| |
| 998 // Transform SkColor values to rgba strings. | |
|
jdufault
2017/06/12 21:37:28
Remove comment, it is immediately obvious.
Wenzhao (Colin) Zang
2017/06/12 23:40:34
Done.
| |
| 999 CallJS("login.AccountPickerScreen.setOverlayColors", | |
| 1000 color_utils::SkColorToRgbaString(dm_sk_color), | |
| 1001 color_utils::SkColorToRgbaString(scroll_sk_color), | |
| 1002 color_utils::SkColorToRgbaString(background_sk_color)); | |
| 1003 } | |
| 1004 | |
| 980 void SigninScreenHandler::Initialize() { | 1005 void SigninScreenHandler::Initialize() { |
| 981 // Preload PIN keyboard if any of the users can authenticate via PIN. | 1006 // Preload PIN keyboard if any of the users can authenticate via PIN. |
| 982 if (user_manager::UserManager::IsInitialized()) { | 1007 if (user_manager::UserManager::IsInitialized()) { |
| 983 for (user_manager::User* user : | 1008 for (user_manager::User* user : |
| 984 user_manager::UserManager::Get()->GetUnlockUsers()) { | 1009 user_manager::UserManager::Get()->GetUnlockUsers()) { |
| 985 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = | 1010 chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage = |
| 986 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); | 1011 chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user); |
| 987 if (quick_unlock_storage && | 1012 if (quick_unlock_storage && |
| 988 quick_unlock_storage->IsPinAuthenticationAvailable()) { | 1013 quick_unlock_storage->IsPinAuthenticationAvailable()) { |
| 989 CallJS("cr.ui.Oobe.preloadPinKeyboard"); | 1014 CallJS("cr.ui.Oobe.preloadPinKeyboard"); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1010 } | 1035 } |
| 1011 | 1036 |
| 1012 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, | 1037 void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen, |
| 1013 OobeScreen new_screen) { | 1038 OobeScreen new_screen) { |
| 1014 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { | 1039 if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) { |
| 1015 // Restore active IME state if returning to user pod row screen. | 1040 // Restore active IME state if returning to user pod row screen. |
| 1016 input_method::InputMethodManager::Get()->SetState(ime_state_); | 1041 input_method::InputMethodManager::Get()->SetState(ime_state_); |
| 1017 } | 1042 } |
| 1018 } | 1043 } |
| 1019 | 1044 |
| 1045 void SigninScreenHandler::OnColorCalculationComplete() { | |
| 1046 SkColor dm_color = WallpaperManager::Get()->prominent_color(); | |
| 1047 SetSigninScreenColors(dm_color); | |
| 1048 } | |
| 1049 | |
| 1050 void SigninScreenHandler::OnWallpaperAnimationFinished( | |
| 1051 const AccountId& account_id) {} | |
| 1052 | |
| 1020 void SigninScreenHandler::ClearAndEnablePassword() { | 1053 void SigninScreenHandler::ClearAndEnablePassword() { |
| 1021 core_oobe_view_->ResetSignInUI(false); | 1054 core_oobe_view_->ResetSignInUI(false); |
| 1022 } | 1055 } |
| 1023 | 1056 |
| 1024 void SigninScreenHandler::ClearUserPodPassword() { | 1057 void SigninScreenHandler::ClearUserPodPassword() { |
| 1025 core_oobe_view_->ClearUserPodPassword(); | 1058 core_oobe_view_->ClearUserPodPassword(); |
| 1026 } | 1059 } |
| 1027 | 1060 |
| 1028 void SigninScreenHandler::RefocusCurrentPod() { | 1061 void SigninScreenHandler::RefocusCurrentPod() { |
| 1029 core_oobe_view_->RefocusCurrentPod(); | 1062 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; | 1740 rate.initial_delay_in_ms = auto_repeat_delay; |
| 1708 rate.repeat_interval_in_ms = auto_repeat_interval; | 1741 rate.repeat_interval_in_ms = auto_repeat_interval; |
| 1709 input_method::InputMethodManager::Get() | 1742 input_method::InputMethodManager::Get() |
| 1710 ->GetImeKeyboard() | 1743 ->GetImeKeyboard() |
| 1711 ->SetAutoRepeatEnabled(true); | 1744 ->SetAutoRepeatEnabled(true); |
| 1712 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( | 1745 input_method::InputMethodManager::Get()->GetImeKeyboard()->SetAutoRepeatRate( |
| 1713 rate); | 1746 rate); |
| 1714 } | 1747 } |
| 1715 | 1748 |
| 1716 } // namespace chromeos | 1749 } // namespace chromeos |
| OLD | NEW |