Commit d64e7597 authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

CrOS OOBE: Move Gaia IME set state into LDHCommon

Instead of triggerring Gaia IME on the Gaia async load - which might
happen even if the dialog is hidden.

Also fixed ExistingUserControllerAuthFailureTest.CryptohomeMissing test
which had a wrong expectations. Should show Gaia reauth page for the
missing cryptohome user.

Bug: 1140239
Fixed: 1150142
Change-Id: Idc722bfbd4f5b6418f6f2751b32e4bd9cc8ebf60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536872Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828648}
parent 1fe0160a
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "chrome/browser/chromeos/login/screens/user_selection_screen.h" #include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h" #include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h"
#include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
#include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/js_checker.h"
#include "chrome/browser/chromeos/login/test/login_manager_mixin.h" #include "chrome/browser/chromeos/login/test/login_manager_mixin.h"
#include "chrome/browser/chromeos/login/test/oobe_base_test.h" #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
...@@ -1161,8 +1162,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerSavePasswordHashTest, ...@@ -1161,8 +1162,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerSavePasswordHashTest,
} }
// Tests different auth failures for an existing user login attempts. // Tests different auth failures for an existing user login attempts.
class ExistingUserControllerAuthFailureTest class ExistingUserControllerAuthFailureTest : public OobeBaseTest {
: public MixinBasedInProcessBrowserTest {
public: public:
ExistingUserControllerAuthFailureTest() = default; ExistingUserControllerAuthFailureTest() = default;
~ExistingUserControllerAuthFailureTest() override = default; ~ExistingUserControllerAuthFailureTest() override = default;
...@@ -1208,6 +1208,7 @@ class ExistingUserControllerAuthFailureTest ...@@ -1208,6 +1208,7 @@ class ExistingUserControllerAuthFailureTest
} }
protected: protected:
FakeGaiaMixin fake_gaia_{&mixin_host_, embedded_test_server()};
const LoginManagerMixin::TestUserInfo test_user_{ const LoginManagerMixin::TestUserInfo test_user_{
AccountId::FromUserEmailGaiaId("user@gmail.com", "user")}; AccountId::FromUserEmailGaiaId("user@gmail.com", "user")};
LoginManagerMixin login_manager_{&mixin_host_, {test_user_}}; LoginManagerMixin login_manager_{&mixin_host_, {test_user_}};
...@@ -1217,7 +1218,11 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerAuthFailureTest, ...@@ -1217,7 +1218,11 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerAuthFailureTest,
CryptohomeMissing) { CryptohomeMissing) {
SetUpStubAuthenticatorAndAttemptLogin(AuthFailure::MISSING_CRYPTOHOME); SetUpStubAuthenticatorAndAttemptLogin(AuthFailure::MISSING_CRYPTOHOME);
OobeScreenWaiter(OobeBaseTest::GetFirstSigninScreen()).Wait(); WaitForGaiaPageLoad();
EXPECT_TRUE(ash::LoginScreenTestApi::IsOobeDialogVisible());
EXPECT_EQ(fake_gaia_.fake_gaia()->prefilled_email(),
test_user_.account_id.GetUserEmail());
const user_manager::User* user = const user_manager::User* user =
user_manager::UserManager::Get()->FindUser(test_user_.account_id); user_manager::UserManager::Get()->FindUser(test_user_.account_id);
ASSERT_TRUE(user); ASSERT_TRUE(user);
......
...@@ -10,9 +10,11 @@ ...@@ -10,9 +10,11 @@
#include "chrome/browser/browser_process_platform_part.h" #include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_types.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_types.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/login/app_mode/kiosk_launch_controller.h" #include "chrome/browser/chromeos/login/app_mode/kiosk_launch_controller.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h" #include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/lock_screen_utils.h"
#include "chrome/browser/chromeos/login/screens/gaia_screen.h" #include "chrome/browser/chromeos/login/screens/gaia_screen.h"
#include "chrome/browser/chromeos/login/startup_utils.h" #include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/ui/webui_accelerator_mapping.h" #include "chrome/browser/chromeos/login/ui/webui_accelerator_mapping.h"
...@@ -30,6 +32,8 @@ ...@@ -30,6 +32,8 @@
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "extensions/common/features/feature_session_type.h" #include "extensions/common/features/feature_session_type.h"
#include "extensions/common/mojom/feature_session_type.mojom.h" #include "extensions/common/mojom/feature_session_type.mojom.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/chromeos/input_method_util.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
namespace chromeos { namespace chromeos {
...@@ -50,6 +54,56 @@ void ScheduleCompletionCallbacks(std::vector<base::OnceClosure>&& callbacks) { ...@@ -50,6 +54,56 @@ void ScheduleCompletionCallbacks(std::vector<base::OnceClosure>&& callbacks) {
} }
} }
void PushFrontImIfNotExists(const std::string& input_method,
std::vector<std::string>* input_methods) {
if (input_method.empty())
return;
if (!base::Contains(*input_methods, input_method))
input_methods->insert(input_methods->begin(), input_method);
}
void SetGaiaInputMethods(const AccountId& account_id) {
input_method::InputMethodManager* imm =
input_method::InputMethodManager::Get();
scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state =
imm->GetActiveIMEState()->Clone();
imm->SetState(gaia_ime_state);
gaia_ime_state->SetUIStyle(input_method::InputMethodManager::UIStyle::kLogin);
// Set Least Recently Used input method for the user.
if (account_id.is_valid()) {
lock_screen_utils::SetUserInputMethod(account_id, gaia_ime_state.get(),
true /*honor_device_policy*/);
} else {
lock_screen_utils::EnforceDevicePolicyInputMethods(std::string());
std::vector<std::string> input_methods;
if (gaia_ime_state->GetAllowedInputMethods().empty()) {
input_methods =
imm->GetInputMethodUtil()->GetHardwareLoginInputMethodIds();
} else {
input_methods = gaia_ime_state->GetAllowedInputMethods();
}
const std::string owner_im = lock_screen_utils::GetUserLastInputMethod(
user_manager::UserManager::Get()->GetOwnerAccountId());
const std::string system_im = g_browser_process->local_state()->GetString(
language_prefs::kPreferredKeyboardLayout);
PushFrontImIfNotExists(owner_im, &input_methods);
PushFrontImIfNotExists(system_im, &input_methods);
gaia_ime_state->EnableLoginLayouts(
g_browser_process->GetApplicationLocale(), input_methods);
if (!system_im.empty()) {
gaia_ime_state->ChangeInputMethod(system_im, false /* show_message */);
} else if (!owner_im.empty()) {
gaia_ime_state->ChangeInputMethod(owner_im, false /* show_message */);
}
}
}
} // namespace } // namespace
LoginDisplayHostCommon::LoginDisplayHostCommon() LoginDisplayHostCommon::LoginDisplayHostCommon()
...@@ -328,6 +382,8 @@ void LoginDisplayHostCommon::ShowGaiaDialogCommon( ...@@ -328,6 +382,8 @@ void LoginDisplayHostCommon::ShowGaiaDialogCommon(
GaiaScreen* gaia_screen = GetWizardController()->GetScreen<GaiaScreen>(); GaiaScreen* gaia_screen = GetWizardController()->GetScreen<GaiaScreen>();
gaia_screen->LoadOnline(prefilled_account); gaia_screen->LoadOnline(prefilled_account);
SetGaiaInputMethods(prefilled_account);
if (chromeos::features::IsChildSpecificSigninEnabled() && if (chromeos::features::IsChildSpecificSigninEnabled() &&
!prefilled_account.is_valid()) { !prefilled_account.is_valid()) {
StartWizard(UserCreationView::kScreenId); StartWizard(UserCreationView::kScreenId);
......
...@@ -1002,9 +1002,6 @@ void LoginDisplayHostWebUI::DisableRestrictiveProxyCheckForTest() { ...@@ -1002,9 +1002,6 @@ void LoginDisplayHostWebUI::DisableRestrictiveProxyCheckForTest() {
} }
void LoginDisplayHostWebUI::ShowGaiaDialog(const AccountId& prefilled_account) { void LoginDisplayHostWebUI::ShowGaiaDialog(const AccountId& prefilled_account) {
// This is a special case, when WebUI sign-in screen shown with Views-based
// launch bar. Then "Add user" button will be Views-based, and user click
// will result in this call.
ShowGaiaDialogCommon(prefilled_account); ShowGaiaDialogCommon(prefilled_account);
} }
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
#include "chrome/browser/chromeos/certificate_provider/certificate_provider_service.h" #include "chrome/browser/chromeos/certificate_provider/certificate_provider_service.h"
#include "chrome/browser/chromeos/certificate_provider/certificate_provider_service_factory.h" #include "chrome/browser/chromeos/certificate_provider/certificate_provider_service_factory.h"
#include "chrome/browser/chromeos/certificate_provider/pin_dialog_manager.h" #include "chrome/browser/chromeos/certificate_provider/pin_dialog_manager.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/login/lock_screen_utils.h"
#include "chrome/browser/chromeos/login/reauth_stats.h" #include "chrome/browser/chromeos/login/reauth_stats.h"
#include "chrome/browser/chromeos/login/saml/public_saml_url_fetcher.h" #include "chrome/browser/chromeos/login/saml/public_saml_url_fetcher.h"
#include "chrome/browser/chromeos/login/saml/saml_metric_utils.h" #include "chrome/browser/chromeos/login/saml/saml_metric_utils.h"
...@@ -94,8 +92,6 @@ ...@@ -94,8 +92,6 @@
#include "net/cert/x509_certificate.h" #include "net/cert/x509_certificate.h"
#include "services/network/nss_temp_certs_cache_chromeos.h" #include "services/network/nss_temp_certs_cache_chromeos.h"
#include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/network_context.mojom.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/chromeos/input_method_util.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/chromeos/devicetype_utils.h" #include "ui/chromeos/devicetype_utils.h"
...@@ -224,15 +220,6 @@ void RecordSAMLScrapingVerificationResultInHistogram(bool success) { ...@@ -224,15 +220,6 @@ void RecordSAMLScrapingVerificationResultInHistogram(bool success) {
UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success); UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success);
} }
void PushFrontIMIfNotExists(const std::string& input_method,
std::vector<std::string>* input_methods) {
if (input_method.empty())
return;
if (!base::Contains(*input_methods, input_method))
input_methods->insert(input_methods->begin(), input_method);
}
bool IsOnline(NetworkPortalDetector::CaptivePortalStatus status) { bool IsOnline(NetworkPortalDetector::CaptivePortalStatus status) {
return status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; return status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
} }
...@@ -958,12 +945,7 @@ void GaiaScreenHandler::HandleOnFatalError( ...@@ -958,12 +945,7 @@ void GaiaScreenHandler::HandleOnFatalError(
} }
void GaiaScreenHandler::OnShowAddUser() { void GaiaScreenHandler::OnShowAddUser() {
lock_screen_utils::EnforceDevicePolicyInputMethods(std::string()); LoginDisplayHost::default_host()->ShowGaiaDialog(populated_account_id_);
LoadGaiaAsync(EmptyAccountId());
LoginDisplayHost::default_host()->StartWizard(
chromeos::features::IsChildSpecificSigninEnabled()
? UserCreationView::kScreenId
: GaiaView::kScreenId);
} }
void GaiaScreenHandler::DoCompleteLogin( void GaiaScreenHandler::DoCompleteLogin(
...@@ -1114,8 +1096,7 @@ void GaiaScreenHandler::SetGaiaPath(GaiaScreenHandler::GaiaPath gaia_path) { ...@@ -1114,8 +1096,7 @@ void GaiaScreenHandler::SetGaiaPath(GaiaScreenHandler::GaiaPath gaia_path) {
} }
void GaiaScreenHandler::LoadGaiaAsync(const AccountId& account_id) { void GaiaScreenHandler::LoadGaiaAsync(const AccountId& account_id) {
if (account_id.is_valid()) populated_account_id_ = account_id;
populated_account_id_ = account_id;
if (gaia_silent_load_ && !populated_account_id_.is_valid()) { if (gaia_silent_load_ && !populated_account_id_.is_valid()) {
dns_cleared_ = true; dns_cleared_ = true;
cookies_cleared_ = true; cookies_cleared_ = true;
...@@ -1232,45 +1213,6 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() { ...@@ -1232,45 +1213,6 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
gaia_silent_load_ = false; gaia_silent_load_ = false;
} }
input_method::InputMethodManager* imm =
input_method::InputMethodManager::Get();
scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state =
imm->GetActiveIMEState()->Clone();
imm->SetState(gaia_ime_state);
gaia_ime_state->SetUIStyle(input_method::InputMethodManager::UIStyle::kLogin);
// Set Least Recently Used input method for the user.
if (populated_account_id_.is_valid()) {
lock_screen_utils::SetUserInputMethod(populated_account_id_,
gaia_ime_state.get(),
true /*honor_device_policy*/);
} else {
std::vector<std::string> input_methods;
if (gaia_ime_state->GetAllowedInputMethods().empty()) {
input_methods =
imm->GetInputMethodUtil()->GetHardwareLoginInputMethodIds();
} else {
input_methods = gaia_ime_state->GetAllowedInputMethods();
}
const std::string owner_im = lock_screen_utils::GetUserLastInputMethod(
user_manager::UserManager::Get()->GetOwnerAccountId());
const std::string system_im = g_browser_process->local_state()->GetString(
language_prefs::kPreferredKeyboardLayout);
PushFrontIMIfNotExists(owner_im, &input_methods);
PushFrontIMIfNotExists(system_im, &input_methods);
gaia_ime_state->EnableLoginLayouts(
g_browser_process->GetApplicationLocale(), input_methods);
if (!system_im.empty()) {
gaia_ime_state->ChangeInputMethod(system_im, false /* show_message */);
} else if (!owner_im.empty()) {
gaia_ime_state->ChangeInputMethod(owner_im, false /* show_message */);
}
}
if (!untrusted_authority_certs_cache_) { if (!untrusted_authority_certs_cache_) {
// Make additional untrusted authority certificates available for client // Make additional untrusted authority certificates available for client
// certificate discovery in case a SAML flow is used which requires a client // certificate discovery in case a SAML flow is used which requires a client
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment