[go: nahoru, domu]

blob: d0493bc17514823037889b8291c84155afb41e08 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2014 The Chromium Authors
nkostylev@chromium.org770e03b2011-03-18 11:27:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Henrique Ferreiro11bf85192021-03-04 11:19:095#include "chrome/browser/ash/login/ui/login_display_host_webui.h"
nkostylev@chromium.org770e03b2011-03-18 11:27:056
Peter Boström6b701822021-04-15 03:53:087#include <memory>
dcheng4c82ad42015-12-31 16:07:158#include <utility>
xiyuan@chromium.org49a3bca2013-05-03 04:56:329#include <vector>
10
David Tsengb774097e2021-03-24 17:31:1011#include "ash/accessibility/ui/focus_ring_controller.h"
Danila Kuzmin27591c152023-05-12 09:45:3812#include "ash/booting/booting_animation_controller.h"
Roman Sorokin79e56b352022-05-27 13:11:3413#include "ash/constants/ash_features.h"
Henrique Ferreirof3fbcea22021-02-05 23:12:1914#include "ash/constants/ash_switches.h"
Maria Petrisora3c52dd2020-03-17 11:35:3615#include "ash/public/cpp/locale_update_controller.h"
Alexander Alekseevaf0c06f2021-08-24 17:14:2416#include "ash/public/cpp/login_accelerators.h"
Denis Kuznetsov9addcea2020-02-07 18:21:5117#include "ash/public/cpp/login_screen.h"
18#include "ash/public/cpp/login_screen_model.h"
jamescook8800b8232016-10-19 12:46:2719#include "ash/public/cpp/shell_window_ids.h"
pkotwicz3632b442015-01-17 00:44:1120#include "ash/shell.h"
Miriam Polzere8f4ac8f2023-09-19 11:19:0721#include "base/check_is_test.h"
sadrul@chromium.org301f9732011-06-03 18:36:3722#include "base/command_line.h"
Avi Drissman02e49e582023-01-07 01:23:1823#include "base/functional/bind.h"
fdoray283082bd2016-06-02 20:18:4624#include "base/location.h"
nkostylev@chromium.org770e03b2011-03-18 11:27:0525#include "base/logging.h"
Arthur Sonzogni39396932023-04-24 09:41:3326#include "base/memory/raw_ptr.h"
Roman Sorokin73e8d5082021-04-14 11:09:2527#include "base/metrics/histogram_functions.h"
shuchen@chromium.orgfdcd4412014-03-05 06:01:5828#include "base/strings/string_split.h"
avi@chromium.org135cb802013-06-09 16:44:2029#include "base/strings/utf_string_conversions.h"
avi@chromium.orgf248ebe02013-06-28 00:58:2830#include "base/time/time.h"
Roman Sorokin373dd992020-04-24 07:40:4631#include "base/timer/elapsed_timer.h"
primiano6221e572015-01-28 12:14:3432#include "base/trace_event/trace_event.h"
Henrique Ferreirof352a752021-01-16 00:37:1933#include "chrome/browser/ash/accessibility/accessibility_manager.h"
Henrique Ferreiro26ed25a2021-02-01 21:59:2934#include "chrome/browser/ash/app_mode/kiosk_app_types.h"
Yeunjoo Choi1fb4ba52021-03-31 01:43:1835#include "chrome/browser/ash/base/locale_util.h"
Henrique Ferreiroae846062021-10-04 14:44:3436#include "chrome/browser/ash/boot_times_recorder.h"
Yeunjoo Choi2761592c2021-07-21 07:33:2537#include "chrome/browser/ash/first_run/first_run.h"
Henrique Ferreiroae846062021-10-04 14:44:3438#include "chrome/browser/ash/language_preferences.h"
Henrique Ferreiroe7040602021-03-05 11:54:2439#include "chrome/browser/ash/login/existing_user_controller.h"
40#include "chrome/browser/ash/login/helper.h"
Osama Fathy1d73817a52023-09-26 18:36:1341#include "chrome/browser/ash/login/login_pref_names.h"
Henrique Ferreiroffdc85f2021-03-05 13:26:2142#include "chrome/browser/ash/login/login_wizard.h"
Roman Sorokinc0b7c182022-03-15 15:59:5243#include "chrome/browser/ash/login/oobe_screen.h"
Henrique Ferreiro995b1db2021-03-06 00:41:4144#include "chrome/browser/ash/login/startup_utils.h"
Henrique Ferreiro11bf85192021-03-04 11:19:0945#include "chrome/browser/ash/login/ui/input_events_blocker.h"
46#include "chrome/browser/ash/login/ui/login_display_host_mojo.h"
Henrique Ferreiro60f2e502021-03-04 15:05:3147#include "chrome/browser/ash/login/ui/webui_login_view.h"
Henrique Ferreiroff1cc24c2021-03-08 12:01:5748#include "chrome/browser/ash/login/wizard_controller.h"
Henrique Ferreirod57c4962021-09-29 07:26:5949#include "chrome/browser/ash/net/delay_network_call.h"
Yeunjoo Choi7227dba2021-08-04 06:35:4750#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
Yeunjoo Choia60b6212021-07-06 11:25:1251#include "chrome/browser/ash/policy/enrollment/enrollment_config.h"
Yeunjoo Choi5097e9c2021-02-25 08:46:5252#include "chrome/browser/ash/settings/cros_settings.h"
Igorec6fe1b2023-12-14 08:54:2853#include "chrome/browser/ash/settings/device_settings_service.h"
Yeunjoo Choia43d74a2021-02-10 23:23:1954#include "chrome/browser/ash/system/device_disabling_manager.h"
55#include "chrome/browser/ash/system/input_device_settings.h"
56#include "chrome/browser/ash/system/timezone_resolver_manager.h"
57#include "chrome/browser/ash/system/timezone_util.h"
nkostylev@chromium.org770e03b2011-03-18 11:27:0558#include "chrome/browser/browser_process.h"
Hans Wennborg63344452019-10-15 10:15:2159#include "chrome/browser/browser_process_platform_part.h"
Avi Drissmand30927342018-05-22 15:04:2760#include "chrome/browser/lifetime/browser_shutdown.h"
antrim@chromium.org2bb3ea82014-08-21 17:29:5661#include "chrome/browser/profiles/profile_manager.h"
Steven Bennetts7dd6dad2018-12-12 17:38:3262#include "chrome/browser/ui/ash/ash_util.h"
Steven Bennetts83149642018-12-06 01:47:2963#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
Henrique Ferreiro325a280d2021-05-04 22:13:5064#include "chrome/browser/ui/ash/system_tray_client_impl.h"
Henrique Ferreiroc78bdb22021-03-25 18:44:3865#include "chrome/browser/ui/ash/wallpaper_controller_client_impl.h"
Yeunjoo Choi3fc970b2022-10-28 02:55:4866#include "chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.h"
Youkichi Hosoieb8d92622023-01-24 19:55:0667#include "chrome/browser/ui/webui/ash/login/arc_vm_data_migration_screen_handler.h"
Yeunjoo Choi3fc970b2022-10-28 02:55:4868#include "chrome/browser/ui/webui/ash/login/core_oobe_handler.h"
69#include "chrome/browser/ui/webui/ash/login/device_disabled_screen_handler.h"
70#include "chrome/browser/ui/webui/ash/login/gaia_screen_handler.h"
Igor3f3ff102024-01-18 12:58:1471#include "chrome/browser/ui/webui/ash/login/install_attributes_error_screen_handler.h"
Yeunjoo Choi3fc970b2022-10-28 02:55:4872#include "chrome/browser/ui/webui/ash/login/lacros_data_backward_migration_screen_handler.h"
73#include "chrome/browser/ui/webui/ash/login/lacros_data_migration_screen_handler.h"
Yeunjoo Choi271633f2022-10-25 03:42:2074#include "chrome/browser/ui/webui/ash/login/oobe_ui.h"
Yeunjoo Choi8e9e2f92022-11-07 02:02:1775#include "chrome/browser/ui/webui/ash/login/os_install_screen_handler.h"
Yeunjoo Choib727c2d2022-11-01 03:09:3476#include "chrome/browser/ui/webui/ash/login/welcome_screen_handler.h"
xiyuan@chromium.org49a3bca2013-05-03 04:56:3277#include "chrome/common/chrome_constants.h"
dzhioev@chromium.orge384a9f2013-11-25 11:23:3778#include "chrome/common/chrome_switches.h"
sadrul@chromium.org301f9732011-06-03 18:36:3779#include "chrome/common/pref_names.h"
thestig@chromium.orgb58d2f82014-08-09 05:36:1480#include "chrome/grit/browser_resources.h"
Henrique Ferreiro94c5e502022-08-17 14:20:2281#include "chromeos/ash/components/audio/sounds.h"
Yeunjoo Choi4095986d2022-06-20 05:30:0382#include "chromeos/ash/components/dbus/session_manager/session_manager_client.h"
Yeunjoo Choi2dade3c2022-12-01 04:00:5383#include "chromeos/ash/components/login/login_state/login_state.h"
Henrique Ferreiro1eaedc42022-10-05 15:33:4784#include "chromeos/ash/components/settings/cros_settings_names.h"
85#include "chromeos/ash/components/settings/cros_settings_provider.h"
86#include "chromeos/ash/components/settings/timezone_settings.h"
Henrique Ferreiroacf002702022-10-06 21:54:5987#include "chromeos/ash/components/timezone/timezone_resolver.h"
Alexander Alekseev3f09a8f2018-05-03 02:52:1088#include "components/account_id/account_id.h"
Ran Ji73f3b432018-07-15 22:10:2789#include "components/language/core/browser/pref_names.h"
Claudio Magnie0a80bb2018-01-31 02:52:5890#include "components/language/core/common/locale_util.h"
brettwb1fc1b82016-02-02 00:19:0891#include "components/prefs/pref_service.h"
nkostylev@chromium.orgb88d2c62014-07-16 18:20:4492#include "components/session_manager/core/session_manager.h"
Danila Kuzminf60c66732023-05-22 19:50:2693#include "components/session_manager/session_manager_types.h"
antrim62ed2582015-03-24 19:08:3594#include "components/user_manager/user.h"
nkostylev@chromium.org4d390782014-08-15 09:22:5895#include "components/user_manager/user_manager.h"
nkostylev@chromium.org4ac57882013-04-22 05:22:4596#include "content/public/browser/web_contents.h"
nkostylev@chromium.org4ac57882013-04-22 05:22:4597#include "content/public/browser/web_ui.h"
Yu-Hsuan Hsu5caedd22019-03-11 12:38:0498#include "services/audio/public/cpp/sounds/sounds_manager.h"
nkostylev@chromium.org2e816352011-12-16 18:19:1699#include "ui/aura/window.h"
Henrique Ferreiro1220b392021-09-16 19:58:07100#include "ui/base/ime/ash/extension_ime_util.h"
101#include "ui/base/ime/ash/input_method_manager.h"
102#include "ui/base/ime/ash/input_method_util.h"
saintlou@chromium.orga2ddff0d2012-03-21 00:31:37103#include "ui/base/resource/resource_bundle.h"
tfarina@chromium.org116302f2012-05-05 21:45:41104#include "ui/compositor/layer.h"
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44105#include "ui/compositor/layer_animation_observer.h"
tfarina@chromium.org116302f2012-05-05 21:45:41106#include "ui/compositor/scoped_layer_animation_settings.h"
oshimad5c972e2016-04-28 23:17:14107#include "ui/display/display.h"
108#include "ui/display/screen.h"
Scott Violeta29ccc92019-06-13 17:04:00109#include "ui/events/devices/device_data_manager.h"
jdufault3cb9fa02017-02-28 00:42:35110#include "ui/events/event_handler.h"
kinaba@chromium.orgbbd08262013-10-30 09:04:27111#include "ui/events/event_utils.h"
tfarina3b0452d2014-12-31 15:20:09112#include "ui/gfx/geometry/rect.h"
tfarinaebe974f02015-01-03 04:25:32113#include "ui/gfx/geometry/size.h"
Xianzhu Wang65ef1ad32021-10-07 03:12:33114#include "ui/gfx/geometry/transform.h"
xiyuan@chromium.org49a3bca2013-05-03 04:56:32115#include "ui/views/focus/focus_manager.h"
nkostylev@chromium.org2e816352011-12-16 18:19:16116#include "ui/views/widget/widget.h"
tfarina@chromium.orga6483d22013-07-03 22:11:00117#include "url/gurl.h"
nkostylev@chromium.org2e816352011-12-16 18:19:16118
Henrique Ferreirofb734d82021-07-21 15:01:02119namespace ash {
nkostylev@chromium.org770e03b2011-03-18 11:27:05120namespace {
121
ygorshenin@chromium.org0bd2c492013-12-03 17:08:29122// Maximum delay for startup sound after 'loginPromptVisible' signal.
Alexander Alekseevec0ed3d2018-08-14 08:27:42123const int kStartupSoundMaxDelayMs = 4000;
ygorshenin@chromium.orgfe703f02013-11-02 22:11:20124
nkostylev@chromium.org4ac57882013-04-22 05:22:45125// URL which corresponds to the OOBE WebUI.
dzhioev@chromium.org50fe9f72013-08-14 20:03:14126const char kOobeURL[] = "chrome://oobe/oobe";
dzhioev@chromium.org04887162013-05-29 23:01:51127
tengs@chromium.org535d2b12013-08-20 12:14:47128// URL which corresponds to the app launch splash WebUI.
129const char kAppLaunchSplashURL[] = "chrome://oobe/app-launch-splash";
130
nkostylev@chromium.org4ac57882013-04-22 05:22:45131// Duration of sign-in transition animation.
132const int kLoginFadeoutTransitionDurationMs = 700;
133
134// Number of times we try to reload OOBE/login WebUI if it crashes.
135const int kCrashCountLimit = 5;
136
xdai957c25f02016-03-03 18:37:18137// The default fade out animation time in ms.
138const int kDefaultFadeTimeMs = 200;
139
Igorec6fe1b2023-12-14 08:54:28140const char kValidInstallAttributesHistogram[] =
141 "Enterprise.InstallAttributes.ValidOnEnrolledDevice";
142
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44143// A class to observe an implicit animation and invokes the callback after the
144// animation is completed.
145class AnimationObserver : public ui::ImplicitAnimationObserver {
146 public:
Reilly Grant3afb5452021-01-23 03:07:19147 explicit AnimationObserver(base::OnceClosure callback)
148 : callback_(std::move(callback)) {}
Peter Boström53c6c5952021-09-17 09:41:26149
150 AnimationObserver(const AnimationObserver&) = delete;
151 AnimationObserver& operator=(const AnimationObserver&) = delete;
152
Edman Anjosd6ea31b2023-10-11 16:51:46153 ~AnimationObserver() override = default;
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44154
155 private:
156 // ui::ImplicitAnimationObserver implementation:
dcheng77fc7b72015-01-16 00:48:45157 void OnImplicitAnimationsCompleted() override {
Reilly Grant3afb5452021-01-23 03:07:19158 std::move(callback_).Run();
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44159 delete this;
160 }
161
Reilly Grant3afb5452021-01-23 03:07:19162 base::OnceClosure callback_;
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44163};
164
Igorec6fe1b2023-12-14 08:54:28165// Returns whether the device settings are managed.
166bool HasManagedDeviceSettings() {
167 if (!DeviceSettingsService::IsInitialized()) {
168 CHECK_IS_TEST();
169 return false;
170 }
171 return DeviceSettingsService::Get()->IsDeviceManaged();
172}
173
Jacob Dufaultaad20ba2018-02-21 21:36:58174// Even if oobe is complete we may still want to show it, for example, if there
175// are no users registered then the user may want to enterprise enroll.
176bool IsOobeComplete() {
Yeunjoo Choi7227dba2021-08-04 06:35:47177 policy::BrowserPolicyConnectorAsh* connector =
178 g_browser_process->platform_part()->browser_policy_connector_ash();
Jacob Dufaultaad20ba2018-02-21 21:36:58179
180 // Oobe is completed and we have a user or we are enterprise enrolled.
Henrique Ferreirob403be32021-09-22 07:15:36181 return StartupUtils::IsOobeCompleted() &&
Igorec6fe1b2023-12-14 08:54:28182 ((!user_manager::UserManager::Get()->GetUsers().empty() &&
183 !HasManagedDeviceSettings()) ||
Roland Bock4ce23a922021-06-11 13:23:11184 connector->IsDeviceEnterpriseManaged());
Jacob Dufaultaad20ba2018-02-21 21:36:58185}
186
Jacob Dufault76d2b412018-03-21 20:38:12187// Returns true if signin (not oobe) should be displayed.
Henrique Ferreirob403be32021-09-22 07:15:36188bool ShouldShowSigninScreen(OobeScreenId first_screen) {
Roman Sorokinba7e9062022-04-13 16:45:52189 return (first_screen == ash::OOBE_SCREEN_UNKNOWN && IsOobeComplete());
pmarko8c3ffb52017-02-08 12:18:35190}
191
Roman Sorokinab28c342020-04-09 10:47:48192void MaybeShowDeviceDisabledScreen() {
Henrique Ferreiro27959862021-06-03 11:09:36193 DCHECK(LoginDisplayHost::default_host());
Roman Sorokinab28c342020-04-09 10:47:48194 if (!g_browser_process->platform_part()->device_disabling_manager()) {
195 // Device disabled check will be done in the DeviceDisablingManager.
196 return;
197 }
198
Edman Anjosd6ea31b2023-10-11 16:51:46199 if (!system::DeviceDisablingManager::
200 IsDeviceDisabledDuringNormalOperation()) {
Roman Sorokinab28c342020-04-09 10:47:48201 return;
Edman Anjosd6ea31b2023-10-11 16:51:46202 }
Roman Sorokinab28c342020-04-09 10:47:48203
Henrique Ferreiro27959862021-06-03 11:09:36204 LoginDisplayHost::default_host()->StartWizard(
Roman Sorokinab28c342020-04-09 10:47:48205 DeviceDisabledScreenView::kScreenId);
206}
207
Igorec6fe1b2023-12-14 08:54:28208void MaybeShowInstallAttributesCorruptedScreen() {
209 if (HasManagedDeviceSettings() &&
210 !InstallAttributes::Get()->IsDeviceLocked()) {
211 LOG(ERROR) << "Corrupted install attributes, showing the TPM error";
212 base::UmaHistogramBoolean(kValidInstallAttributesHistogram, false);
Igor3f3ff102024-01-18 12:58:14213 LoginDisplayHost::default_host()->StartWizard(
214 InstallAttributesErrorView::kScreenId);
Igorec6fe1b2023-12-14 08:54:28215 } else {
216 base::UmaHistogramBoolean(kValidInstallAttributesHistogram, true);
217 }
218}
219
Roman Sorokin373dd992020-04-24 07:40:46220void MaybeShutdownLoginDisplayHostWebUI() {
Edman Anjosd6ea31b2023-10-11 16:51:46221 if (!LoginDisplayHost::default_host()) {
Roman Sorokin373dd992020-04-24 07:40:46222 return;
Edman Anjosd6ea31b2023-10-11 16:51:46223 }
224 if (!LoginDisplayHost::default_host()->GetOobeUI()) {
Roman Sorokin373dd992020-04-24 07:40:46225 return;
Edman Anjosd6ea31b2023-10-11 16:51:46226 }
Roman Sorokin373dd992020-04-24 07:40:46227 if (LoginDisplayHost::default_host()->GetOobeUI()->display_type() !=
228 OobeUI::kOobeDisplay) {
229 return;
230 }
231 LoginDisplayHost::default_host()->FinalizeImmediately();
Miriam Polzere8f4ac8f2023-09-19 11:19:07232 if (LoginDisplayHost::default_host()) {
233 // Tests may be keeping a fake instance.
234 CHECK_IS_TEST();
235 }
Roman Sorokin373dd992020-04-24 07:40:46236}
237
alemate@chromium.orgfcb10a482013-11-13 20:08:43238// ShowLoginWizard is split into two parts. This function is sometimes called
pmarko8c3ffb52017-02-08 12:18:35239// from TriggerShowLoginWizardFinish() directly, and sometimes from
240// OnLanguageSwitchedCallback()
alemate@chromium.orgfcb10a482013-11-13 20:08:43241// (if locale was updated).
242void ShowLoginWizardFinish(
Henrique Ferreirob403be32021-09-22 07:15:36243 OobeScreenId first_screen,
Henrique Ferreirofb734d82021-07-21 15:01:02244 const StartupCustomizationDocument* startup_manifest) {
cmasone@chromium.org2d44d302014-02-11 14:16:07245 TRACE_EVENT0("chromeos", "ShowLoginWizard::ShowLoginWizardFinish");
246
Roman Sorokin373dd992020-04-24 07:40:46247 if (ShouldShowSigninScreen(first_screen)) {
248 // Shutdown WebUI host to replace with the Mojo one.
249 MaybeShutdownLoginDisplayHostWebUI();
250 }
251
Jacob Dufault2ab65572017-11-15 21:15:05252 // TODO(crbug.com/781402): Move LoginDisplayHost creation out of
253 // LoginDisplayHostWebUI, it is not specific to a particular implementation.
254
255 // Create the LoginDisplayHost. Use the views-based implementation only for
256 // the sign-in screen.
Henrique Ferreiro27959862021-06-03 11:09:36257 LoginDisplayHost* display_host = nullptr;
258 if (LoginDisplayHost::default_host()) {
Jacob Dufault5f237c5e2018-01-20 00:19:44259 // Tests may have already allocated an instance for us to use.
Henrique Ferreiro27959862021-06-03 11:09:36260 display_host = LoginDisplayHost::default_host();
Yuta Hijikata1fdf4922022-05-09 08:49:35261 } else if (ShouldShowSigninScreen(first_screen)) {
262 display_host = new LoginDisplayHostMojo(DisplayedScreen::SIGN_IN_SCREEN);
263 } else if (first_screen == LacrosDataMigrationScreenView::kScreenId) {
Yuta Hijikata27bf2f3a2021-07-08 08:03:56264 // TODO(crbug.com/1178702): Once lacros is officially released,
265 // `ShowLoginWizard()` will no longer be called with lacros screen id.
266 // Instead simply call `SigninUI::StartBrowserDataMigration()` as part of
267 // the login flow.
Henrique Ferreiro27959862021-06-03 11:09:36268 display_host = new LoginDisplayHostMojo(DisplayedScreen::SIGN_IN_SCREEN);
Yuta Hijikata1fdf4922022-05-09 08:49:35269 DCHECK(session_manager::SessionManager::Get());
270 session_manager::SessionManager::Get()->NotifyLoginOrLockScreenVisible();
Jana Grilldca1d122022-09-05 10:59:54271 } else if (first_screen == LacrosDataBackwardMigrationScreenView::kScreenId) {
272 display_host = new LoginDisplayHostMojo(DisplayedScreen::SIGN_IN_SCREEN);
273 DCHECK(session_manager::SessionManager::Get());
274 session_manager::SessionManager::Get()->NotifyLoginOrLockScreenVisible();
Youkichi Hosoieb8d92622023-01-24 19:55:06275 } else if (first_screen == ArcVmDataMigrationScreenView::kScreenId) {
276 display_host = new LoginDisplayHostMojo(DisplayedScreen::SIGN_IN_SCREEN);
277 DCHECK(session_manager::SessionManager::Get());
278 session_manager::SessionManager::Get()->NotifyLoginOrLockScreenVisible();
Jacob Dufault2ab65572017-11-15 21:15:05279 } else {
Henrique Ferreiro27959862021-06-03 11:09:36280 display_host = new LoginDisplayHostWebUI();
Jacob Dufault2ab65572017-11-15 21:15:05281 }
282
alemate2cb0d752017-08-11 05:22:16283 // Restore system timezone.
284 std::string timezone;
Henrique Ferreirofb734d82021-07-21 15:01:02285 if (system::PerUserTimezoneEnabled()) {
alemate2cb0d752017-08-11 05:22:16286 timezone = g_browser_process->local_state()->GetString(
Osama Fathy1d73817a52023-09-26 18:36:13287 ::prefs::kSigninScreenTimezone);
alemate2cb0d752017-08-11 05:22:16288 }
289
Denis Kuznetsov04e87082020-07-15 12:58:53290 // TODO(crbug.com/1105387): Part of initial screen logic.
pmarko8c3ffb52017-02-08 12:18:35291 if (ShouldShowSigninScreen(first_screen)) {
Roman Aleksandrova43d8882020-03-26 13:55:56292 display_host->StartSignInScreen();
pmarko8c3ffb52017-02-08 12:18:35293 } else {
294 display_host->StartWizard(first_screen);
alemate@chromium.orgfcb10a482013-11-13 20:08:43295
pmarko8c3ffb52017-02-08 12:18:35296 // Set initial timezone if specified by customization.
alemate2cb0d752017-08-11 05:22:16297 const std::string customization_timezone =
298 startup_manifest->initial_timezone();
299 VLOG(1) << "Initial time zone: " << customization_timezone;
pmarko8c3ffb52017-02-08 12:18:35300 // Apply locale customizations only once to preserve whatever locale
301 // user has changed to during OOBE.
Edman Anjosd6ea31b2023-10-11 16:51:46302 if (!customization_timezone.empty()) {
alemate2cb0d752017-08-11 05:22:16303 timezone = customization_timezone;
Edman Anjosd6ea31b2023-10-11 16:51:46304 }
alemate2cb0d752017-08-11 05:22:16305 }
Edman Anjosd6ea31b2023-10-11 16:51:46306 if (!timezone.empty()) {
Henrique Ferreirofb734d82021-07-21 15:01:02307 system::SetSystemAndSigninScreenTimezone(timezone);
Edman Anjosd6ea31b2023-10-11 16:51:46308 }
Xiyuan Xia1f475ee2019-07-19 13:43:56309
310 // This step requires the session manager to have been initialized and login
311 // display host to be created.
312 DCHECK(session_manager::SessionManager::Get());
Henrique Ferreiro27959862021-06-03 11:09:36313 DCHECK(LoginDisplayHost::default_host());
Danila Kuzminf60c66732023-05-22 19:50:26314 // Postpone loading wallpaper if the booting animation might be played.
Simon Ziegltrum503b22d2023-11-03 12:47:39315 if (!features::IsBootAnimationEnabled() ||
Danila Kuzminf60c66732023-05-22 19:50:26316 session_manager::SessionManager::Get()->session_state() !=
317 session_manager::SessionState::OOBE) {
318 WallpaperControllerClientImpl::Get()->SetInitialWallpaper();
319 }
320
Igorec6fe1b2023-12-14 08:54:28321 MaybeShowInstallAttributesCorruptedScreen();
322
Denis Kuznetsov04e87082020-07-15 12:58:53323 // TODO(crbug.com/1105387): Part of initial screen logic.
Roman Sorokinab28c342020-04-09 10:47:48324 MaybeShowDeviceDisabledScreen();
alemate@chromium.orgfcb10a482013-11-13 20:08:43325}
326
327struct ShowLoginWizardSwitchLanguageCallbackData {
328 explicit ShowLoginWizardSwitchLanguageCallbackData(
Henrique Ferreirob403be32021-09-22 07:15:36329 OobeScreenId first_screen,
Henrique Ferreirofb734d82021-07-21 15:01:02330 const StartupCustomizationDocument* startup_manifest)
Jacob Dufault2ab65572017-11-15 21:15:05331 : first_screen(first_screen), startup_manifest(startup_manifest) {}
alemate@chromium.orgfcb10a482013-11-13 20:08:43332
Henrique Ferreirob403be32021-09-22 07:15:36333 const OobeScreenId first_screen;
Bartek Nowierski8f579342024-01-08 06:45:15334 const raw_ptr<const StartupCustomizationDocument> startup_manifest;
alemate@chromium.orgfcb10a482013-11-13 20:08:43335
336 // lock UI while resource bundle is being reloaded.
Henrique Ferreirofb734d82021-07-21 15:01:02337 InputEventsBlocker events_blocker;
alemate@chromium.orgfcb10a482013-11-13 20:08:43338};
339
Henrique Ferreirofb734d82021-07-21 15:01:02340// Trigger OnLocaleChanged via LocaleUpdateController.
Maria Petrisora3c52dd2020-03-17 11:35:36341void NotifyLocaleChange() {
Henrique Ferreirofb734d82021-07-21 15:01:02342 LocaleUpdateController::Get()->OnLocaleChanged();
Maria Petrisora3c52dd2020-03-17 11:35:36343}
344
alemate@chromium.orgfcb10a482013-11-13 20:08:43345void OnLanguageSwitchedCallback(
dcheng24002d02016-04-08 02:42:40346 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> self,
Henrique Ferreirofb734d82021-07-21 15:01:02347 const locale_util::LanguageSwitchResult& result) {
Alexander Alekseevbfd0b0962023-08-15 22:37:44348 TRACE_EVENT0("login", "OnLanguageSwitchedCallback");
Edman Anjosd6ea31b2023-10-11 16:51:46349 if (!result.success) {
alemated7fb4172014-11-11 16:03:56350 LOG(WARNING) << "Locale could not be found for '" << result.requested_locale
351 << "'";
Edman Anjosd6ea31b2023-10-11 16:51:46352 }
alemate@chromium.orgfcb10a482013-11-13 20:08:43353
Maria Petrisora3c52dd2020-03-17 11:35:36354 // Notify the locale change.
355 NotifyLocaleChange();
Jacob Dufault2ab65572017-11-15 21:15:05356 ShowLoginWizardFinish(self->first_screen, self->startup_manifest);
alemate@chromium.orgfcb10a482013-11-13 20:08:43357}
358
pmarko8c3ffb52017-02-08 12:18:35359// Triggers ShowLoginWizardFinish directly if no locale switch is required
Denis Kuznetsovddc02312020-10-19 11:30:13360// (`switch_locale` is empty) or after a locale switch otherwise.
pmarko8c3ffb52017-02-08 12:18:35361void TriggerShowLoginWizardFinish(
362 std::string switch_locale,
363 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data) {
364 if (switch_locale.empty()) {
Jacob Dufault2ab65572017-11-15 21:15:05365 ShowLoginWizardFinish(data->first_screen, data->startup_manifest);
pmarko8c3ffb52017-02-08 12:18:35366 } else {
Henrique Ferreirofb734d82021-07-21 15:01:02367 locale_util::SwitchLanguageCallback callback(
Daniel Cheng0e084e32021-03-01 10:10:49368 base::BindOnce(&OnLanguageSwitchedCallback, std::move(data)));
pmarko8c3ffb52017-02-08 12:18:35369
370 // Load locale keyboards here. Hardware layout would be automatically
371 // enabled.
Henrique Ferreirofb734d82021-07-21 15:01:02372 locale_util::SwitchLanguage(
Jesse McKenna9d32e8902020-11-17 03:58:57373 switch_locale, true, true /* login_layouts_only */, std::move(callback),
pmarko8c3ffb52017-02-08 12:18:35374 ProfileManager::GetActiveUserProfile());
375 }
376}
377
378// Returns the login screen locale mandated by device policy, or an empty string
379// if no policy-specified locale is set.
380std::string GetManagedLoginScreenLocale() {
Henrique Ferreirofb734d82021-07-21 15:01:02381 auto* cros_settings = CrosSettings::Get();
Andrey Davydov5a8f7a0e2022-08-30 03:06:07382 const base::Value::List* login_screen_locales = nullptr;
Edman Anjosd6ea31b2023-10-11 16:51:46383 if (!cros_settings->GetList(kDeviceLoginScreenLocales,
384 &login_screen_locales)) {
pmarko8c3ffb52017-02-08 12:18:35385 return std::string();
Edman Anjosd6ea31b2023-10-11 16:51:46386 }
pmarko8c3ffb52017-02-08 12:18:35387
388 // Currently, only the first element is used. The setting is a list for future
389 // compatibility, if dynamically switching locales on the login screen will be
390 // implemented.
Andrey Davydov5a8f7a0e2022-08-30 03:06:07391 if (login_screen_locales->empty() ||
Edman Anjosd6ea31b2023-10-11 16:51:46392 !login_screen_locales->front().is_string()) {
pmarko8c3ffb52017-02-08 12:18:35393 return std::string();
Edman Anjosd6ea31b2023-10-11 16:51:46394 }
pmarko8c3ffb52017-02-08 12:18:35395
Andrey Davydov5a8f7a0e2022-08-30 03:06:07396 return login_screen_locales->front().GetString();
pmarko8c3ffb52017-02-08 12:18:35397}
398
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29399// Disables virtual keyboard overscroll. Login UI will scroll user pods
400// into view on JS side when virtual keyboard is shown.
401void DisableKeyboardOverscroll() {
Steven Bennetts5f63c6b02018-10-04 19:14:16402 auto* client = ChromeKeyboardControllerClient::Get();
Darren Shen8604a212019-06-07 00:41:38403 keyboard::KeyboardConfig config = client->GetKeyboardConfig();
404 config.overscroll_behavior = keyboard::KeyboardOverscrollBehavior::kDisabled;
Steven Bennetts5f63c6b02018-10-04 19:14:16405 client->SetKeyboardConfig(config);
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29406}
407
Steven Bennetts42a4d4a2018-10-05 19:05:10408void ResetKeyboardOverscrollBehavior() {
Steven Bennetts5f63c6b02018-10-04 19:14:16409 auto* client = ChromeKeyboardControllerClient::Get();
Darren Shen8604a212019-06-07 00:41:38410 keyboard::KeyboardConfig config = client->GetKeyboardConfig();
411 config.overscroll_behavior = keyboard::KeyboardOverscrollBehavior::kDefault;
Steven Bennetts5f63c6b02018-10-04 19:14:16412 client->SetKeyboardConfig(config);
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29413}
414
Alexander Alekseevc1710c92018-08-03 21:02:48415// Returns true if we have default audio device.
416bool CanPlayStartupSound() {
Henrique Ferreiro3d9d93d2021-02-19 22:17:39417 AudioDevice device;
Henrique Ferreirofb734d82021-07-21 15:01:02418 bool found = CrasAudioHandler::Get()->GetPrimaryActiveOutputDevice(&device);
Alexander Alekseevc1710c92018-08-03 21:02:48419 return found && device.stable_device_id_version &&
Henrique Ferreiro30d27742021-01-14 20:45:04420 device.type != AudioDeviceType::kOther;
Alexander Alekseevc1710c92018-08-03 21:02:48421}
422
Paul Dysonc98c28c2021-08-31 02:04:20423// Returns the preferences service.
424PrefService* GetLocalState() {
Edman Anjosd6ea31b2023-10-11 16:51:46425 if (g_browser_process && g_browser_process->local_state()) {
Paul Dysonc98c28c2021-08-31 02:04:20426 return g_browser_process->local_state();
Edman Anjosd6ea31b2023-10-11 16:51:46427 }
Paul Dysonc98c28c2021-08-31 02:04:20428 return nullptr;
429}
430
James Cook907ced32018-08-27 16:16:36431} // namespace
nkostylev@chromium.org770e03b2011-03-18 11:27:05432
433// static
Yunke Zhouea445712020-10-05 10:10:24434const char LoginDisplayHostWebUI::kShowLoginWebUIid[] = "ShowLoginWebUI";
435
jdufault3cb9fa02017-02-28 00:42:35436// A class to handle special menu key for keyboard driven OOBE.
Jacob Dufault1c71f8b2017-11-10 00:42:30437class LoginDisplayHostWebUI::KeyboardDrivenOobeKeyHandler
jdufault3cb9fa02017-02-28 00:42:35438 : public ui::EventHandler {
439 public:
Henrique Ferreirofb734d82021-07-21 15:01:02440 KeyboardDrivenOobeKeyHandler() { Shell::Get()->AddPreTargetHandler(this); }
Peter Boström53c6c5952021-09-17 09:41:26441
442 KeyboardDrivenOobeKeyHandler(const KeyboardDrivenOobeKeyHandler&) = delete;
443 KeyboardDrivenOobeKeyHandler& operator=(const KeyboardDrivenOobeKeyHandler&) =
444 delete;
445
jdufault3cb9fa02017-02-28 00:42:35446 ~KeyboardDrivenOobeKeyHandler() override {
Henrique Ferreirofb734d82021-07-21 15:01:02447 Shell::Get()->RemovePreTargetHandler(this);
jdufault3cb9fa02017-02-28 00:42:35448 }
449
450 private:
451 // ui::EventHandler
452 void OnKeyEvent(ui::KeyEvent* event) override {
453 if (event->key_code() == ui::VKEY_F6) {
Henrique Ferreiro325a280d2021-05-04 22:13:50454 SystemTrayClientImpl::Get()->SetPrimaryTrayVisible(false);
jdufault3cb9fa02017-02-28 00:42:35455 event->StopPropagation();
456 }
457 }
jdufault3cb9fa02017-02-28 00:42:35458};
459
nkostylev@chromium.org2e816352011-12-16 18:19:16460////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30461// LoginDisplayHostWebUI, public
nkostylev@chromium.org770e03b2011-03-18 11:27:05462
Jacob Dufaultd052b5c62018-02-08 23:56:00463LoginDisplayHostWebUI::LoginDisplayHostWebUI()
Jeremy Roman47d432e2019-08-20 14:24:00464 : oobe_startup_sound_played_(StartupUtils::IsOobeCompleted()) {
Steven Bennetts7c45cb92019-04-03 21:30:23465 SessionManagerClient::Get()->AddObserver(this);
ygorshenin@chromium.org0bd2c492013-12-03 17:08:29466 CrasAudioHandler::Get()->AddAudioObserver(this);
nkostylev@chromium.org40db36e2014-04-04 14:08:18467
Scott Violeta29ccc92019-06-13 17:04:00468 ui::DeviceDataManager::GetInstance()->AddObserver(this);
Felix Ekblomd706dfc2017-07-21 09:17:08469
Sammie Quon0ab09822021-08-24 18:16:10470 // When we wait for WebUI to be initialized we wait for the error screen to be
471 // shown or the login or lock screen to be shown.
Sammie Quon5ddda102021-08-18 17:32:07472 session_observation_.Observe(session_manager::SessionManager::Get());
ygorshenin@chromium.orgce89d9392013-12-11 21:05:20473
Yu-Hsuan Hsu5caedd22019-03-11 12:38:04474 audio::SoundsManager* manager = audio::SoundsManager::Get();
ygorshenin@chromium.orgce89d9392013-12-11 21:05:20475 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
Henrique Ferreirobd3e9972021-01-14 18:48:48476 manager->Initialize(static_cast<int>(Sound::kStartup),
Hongyu Long3074f59f2023-02-07 01:19:04477 bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV),
478 media::AudioCodec::kPCM);
nkostylev@chromium.org770e03b2011-03-18 11:27:05479}
480
Jacob Dufault1c71f8b2017-11-10 00:42:30481LoginDisplayHostWebUI::~LoginDisplayHostWebUI() {
Roman Sorokin8d1a4fe2023-05-12 14:01:30482 VLOG(4) << __func__;
Paul Dysonc98c28c2021-08-31 02:04:20483
Steven Bennetts7c45cb92019-04-03 21:30:23484 SessionManagerClient::Get()->RemoveObserver(this);
ygorshenin@chromium.org0bd2c492013-12-03 17:08:29485 CrasAudioHandler::Get()->RemoveAudioObserver(this);
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29486
Denis Kuznetsovc8619642018-09-21 19:30:44487 if (waiting_for_configuration_) {
488 OobeConfiguration::Get()->RemoveObserver(this);
489 waiting_for_configuration_ = false;
490 }
491
Scott Violeta29ccc92019-06-13 17:04:00492 ui::DeviceDataManager::GetInstance()->RemoveObserver(this);
Felix Ekblomd706dfc2017-07-21 09:17:08493
Edman Anjosd6ea31b2023-10-11 16:51:46494 if (login_view_ && login_window_) {
rsorokin@chromium.org69e6f0e2014-07-08 22:53:14495 login_window_->RemoveRemovalsObserver(this);
Edman Anjosd6ea31b2023-10-11 16:51:46496 }
rsorokin@chromium.org69e6f0e2014-07-08 22:53:14497
Steven Bennetts42a4d4a2018-10-05 19:05:10498 ResetKeyboardOverscrollBehavior();
ygorshenin@chromium.orgfe703f02013-11-02 22:11:20499
xiyuan@chromium.org49a3bca2013-05-03 04:56:32500 views::FocusManager::set_arrow_key_traversal_enabled(false);
nkostylev@chromium.org4ac57882013-04-22 05:22:45501 ResetLoginWindowAndView();
502
Richard Knoll8e1924332020-06-24 06:55:28503 CHECK(!views::WidgetObserver::IsInObserverList());
nkostylev@chromium.org770e03b2011-03-18 11:27:05504}
505
nkostylev@chromium.org2e816352011-12-16 18:19:16506////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30507// LoginDisplayHostWebUI, LoginDisplayHost:
nkostylev@chromium.org770e03b2011-03-18 11:27:05508
Jacob Dufault0ef3aab02018-07-17 15:54:50509ExistingUserController* LoginDisplayHostWebUI::GetExistingUserController() {
Edman Anjosd6ea31b2023-10-11 16:51:46510 if (!existing_user_controller_) {
Martin Bidlingmaier13539d32022-04-14 11:17:32511 CreateExistingUserController();
Edman Anjosd6ea31b2023-10-11 16:51:46512 }
Jacob Dufault0ef3aab02018-07-17 15:54:50513 return existing_user_controller_.get();
514}
515
Jacob Dufault1c71f8b2017-11-10 00:42:30516gfx::NativeWindow LoginDisplayHostWebUI::GetNativeWindow() const {
jdufaulte7952a22017-02-07 00:44:47517 return login_window_ ? login_window_->GetNativeWindow() : nullptr;
nkostylev@chromium.org4ac57882013-04-22 05:22:45518}
519
Danila Kuzmin1546b88e2022-02-07 12:12:35520views::Widget* LoginDisplayHostWebUI::GetLoginWindowWidget() const {
521 return login_window_;
522}
523
Jacob Dufault1c71f8b2017-11-10 00:42:30524WebUILoginView* LoginDisplayHostWebUI::GetWebUILoginView() const {
nkostylev@chromium.org4ac57882013-04-22 05:22:45525 return login_view_;
526}
527
Jacob Dufault0af1f452018-02-08 16:56:58528void LoginDisplayHostWebUI::OnFinalize() {
xiyuan654013972017-04-21 18:44:28529 DVLOG(1) << "Finalizing LoginDisplayHost. User session starting";
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44530
531 switch (finalize_animation_type_) {
532 case ANIMATION_NONE:
Xiyuan Xia1a92b112017-12-08 23:04:22533 ShutdownDisplayHost();
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44534 break;
535 case ANIMATION_WORKSPACE:
James Cook9e2d55202018-08-29 00:27:08536 ScheduleWorkspaceAnimation();
Xiyuan Xia1a92b112017-12-08 23:04:22537 ShutdownDisplayHost();
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44538 break;
539 case ANIMATION_FADE_OUT:
540 // Display host is deleted once animation is completed
541 // since sign in screen widget has to stay alive.
xdai957c25f02016-03-03 18:37:18542 ScheduleFadeOutAnimation(kDefaultFadeTimeMs);
543 break;
dzhioev@chromium.org04887162013-05-29 23:01:51544 }
nkostylev@chromium.org770e03b2011-03-18 11:27:05545}
546
Jacob Dufault1c71f8b2017-11-10 00:42:30547void LoginDisplayHostWebUI::SetStatusAreaVisible(bool visible) {
Roman Sorokin5973f802019-08-01 15:46:12548 status_area_saved_visibility_ = visible;
Edman Anjosd6ea31b2023-10-11 16:51:46549 if (login_view_) {
Roman Sorokin5973f802019-08-01 15:46:12550 login_view_->SetStatusAreaVisible(status_area_saved_visibility_);
Edman Anjosd6ea31b2023-10-11 16:51:46551 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45552}
553
Denis Kuznetsovc8619642018-09-21 19:30:44554void LoginDisplayHostWebUI::OnOobeConfigurationChanged() {
555 waiting_for_configuration_ = false;
556 OobeConfiguration::Get()->RemoveObserver(this);
557 StartWizard(first_screen_);
558}
559
Jacob Dufaultb7eb2342019-05-01 21:40:37560void LoginDisplayHostWebUI::StartWizard(OobeScreenId first_screen) {
Denis Kuznetsovc8619642018-09-21 19:30:44561 if (!StartupUtils::IsOobeCompleted()) {
Osama Fathy1d73817a52023-09-26 18:36:13562 // If `prefs::kOobeStartTime` is not yet stored, then this is the first
563 // time OOBE has started.
564 if (GetLocalState() &&
565 GetLocalState()->GetTime(prefs::kOobeStartTime).is_null()) {
566 GetLocalState()->SetTime(prefs::kOobeStartTime, base::Time::Now());
Osama Fathyb3c39d02023-10-19 00:01:13567 GetOobeMetricsHelper()->RecordPreLoginOobeFirstStart();
Osama Fathy1d73817a52023-09-26 18:36:13568 }
569
Denis Kuznetsovc8619642018-09-21 19:30:44570 CHECK(OobeConfiguration::Get());
Edman Anjosd6ea31b2023-10-11 16:51:46571 if (waiting_for_configuration_) {
Denis Kuznetsovc8619642018-09-21 19:30:44572 return;
Edman Anjosd6ea31b2023-10-11 16:51:46573 }
Denis Kuznetsovc8619642018-09-21 19:30:44574 if (!OobeConfiguration::Get()->CheckCompleted()) {
575 waiting_for_configuration_ = true;
576 first_screen_ = first_screen;
577 OobeConfiguration::Get()->AddAndFireObserver(this);
578 VLOG(1) << "Login WebUI >> wizard waiting for configuration check";
579 return;
580 }
581 }
582
bshe65e45e12015-05-05 15:04:52583 DisableKeyboardOverscroll();
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29584
Jacob Dufault73671d42018-01-03 22:06:36585 TryToPlayOobeStartupSound();
ygorshenin@chromium.orgfe703f02013-11-02 22:11:20586
jdufault9e47a74b2017-01-09 20:46:56587 first_screen_ = first_screen;
nkostylev@chromium.org4ac57882013-04-22 05:22:45588
stevenjb@chromium.orge6898662014-07-17 05:03:53589 VLOG(1) << "Login WebUI >> wizard";
nkostylev@chromium.org4ac57882013-04-22 05:22:45590
Roman Sorokin73e8d5082021-04-14 11:09:25591 if (!login_window_) {
592 oobe_load_timer_ = base::ElapsedTimer();
dzhioev99949d72015-06-19 21:56:14593 LoadURL(GURL(kOobeURL));
Roman Sorokin73e8d5082021-04-14 11:09:25594 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45595
Jacob Dufaultb7eb2342019-05-01 21:40:37596 DVLOG(1) << "Starting wizard, first_screen: " << first_screen;
Saurabh Nijhara21b6d992020-04-05 15:56:27597
598 // Create and show the wizard.
Saurabh Nijhara34bdce02020-09-23 16:44:08599 if (wizard_controller_) {
Saurabh Nijhara21b6d992020-04-05 15:56:27600 wizard_controller_->AdvanceToScreen(first_screen);
601 } else {
Elie Maamarife318812021-10-06 11:05:42602 wizard_controller_ = std::make_unique<WizardController>(GetWizardContext());
Alexander Alekseev93937102021-08-30 07:55:46603 NotifyWizardCreated();
Saurabh Nijhara21b6d992020-04-05 15:56:27604 wizard_controller_->Init(first_screen);
605 }
Danila Kuzmin27591c152023-05-12 09:45:38606
Simon Ziegltrum503b22d2023-11-03 12:47:39607 if (ash::features::IsBootAnimationEnabled()) {
Danila Kuzmin27591c152023-05-12 09:45:38608 auto* welcome_screen = GetWizardController()->GetScreen<WelcomeScreen>();
609 const bool should_show =
610 wizard_controller_->current_screen() == welcome_screen;
Danila Kuzmin918482d2023-06-01 10:40:55611 if (should_show) {
612 ash::Shell::Get()
613 ->booting_animation_controller()
614 ->ShowAnimationWithEndCallback(base::BindOnce(
615 &LoginDisplayHostWebUI::OnViewsBootingAnimationPlayed,
616 weak_factory_.GetWeakPtr()));
Danila Kuzmin27591c152023-05-12 09:45:38617 }
Danila Kuzmin918482d2023-06-01 10:40:55618 // Show the underlying OOBE WebUI and wallpaper so they are ready once
619 // animation has finished playing.
620 login_window_->Show();
Danila Kuzmin61b7a972023-05-23 23:03:32621 WallpaperControllerClientImpl::Get()->SetInitialWallpaper();
Danila Kuzmin27591c152023-05-12 09:45:38622 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45623}
624
Jacob Dufault1c71f8b2017-11-10 00:42:30625WizardController* LoginDisplayHostWebUI::GetWizardController() {
nkostylev@chromium.org4ac57882013-04-22 05:22:45626 return wizard_controller_.get();
nkostylev@chromium.org770e03b2011-03-18 11:27:05627}
628
Jacob Dufault0af1f452018-02-08 16:56:58629void LoginDisplayHostWebUI::OnStartUserAdding() {
Denis Kuznetsov610b8d02021-02-05 16:26:24630 NOTREACHED();
dzhioev@chromium.org04887162013-05-29 23:01:51631}
632
Jacob Dufault1c71f8b2017-11-10 00:42:30633void LoginDisplayHostWebUI::CancelUserAdding() {
Denis Kuznetsov610b8d02021-02-05 16:26:24634 NOTREACHED();
xdai7a1a51842016-04-23 01:15:41635}
636
Roman Aleksandrova43d8882020-03-26 13:55:56637void LoginDisplayHostWebUI::OnStartSignInScreen() {
bshe65e45e12015-05-05 15:04:52638 DisableKeyboardOverscroll();
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29639
James Cook9e2d55202018-08-29 00:27:08640 finalize_animation_type_ = ANIMATION_WORKSPACE;
nkostylev@chromium.org4ac57882013-04-22 05:22:45641
stevenjb@chromium.orge6898662014-07-17 05:03:53642 VLOG(1) << "Login WebUI >> sign in";
nkostylev@chromium.org4ac57882013-04-22 05:22:45643
nkostylev@chromium.org770e03b2011-03-18 11:27:05644 DVLOG(1) << "Starting sign in screen";
Jacob Dufaulte78efab992018-06-22 18:18:52645 CreateExistingUserController();
antrim5dd7bbe2014-11-27 22:16:24646
Jacob Dufault957e0922017-12-06 19:16:09647 existing_user_controller_->Init(user_manager::UserManager::Get()->GetUsers());
nkostylev@chromium.org770e03b2011-03-18 11:27:05648
Roman Sorokin7f43cfa2022-02-18 09:43:25649 ShowGaiaDialogCommon(EmptyAccountId());
Alexander Alekseevd09cdba2019-03-08 06:42:51650
651 OnStartSignInScreenCommon();
652
Yunke Zhouea445712020-10-05 10:10:24653 TRACE_EVENT_NESTABLE_ASYNC_INSTANT0(
654 "ui", "WaitForScreenStateInitialize",
655 TRACE_ID_WITH_SCOPE(kShowLoginWebUIid, TRACE_ID_GLOBAL(1)));
Jacob Dufault957e0922017-12-06 19:16:09656
657 // TODO(crbug.com/784495): Make sure this is ported to views.
tfarina0923ac52015-01-07 03:21:22658 BootTimesRecorder::Get()->RecordCurrentStats(
alemate@chromium.org3eed4702013-11-07 16:21:21659 "login-wait-for-signin-state-initialize");
antrim@chromium.org8c9ce572013-03-23 22:12:25660}
661
Jacob Dufaultdcc96e32017-12-20 17:48:27662void LoginDisplayHostWebUI::OnStartAppLaunch() {
James Cook9e2d55202018-08-29 00:27:08663 finalize_animation_type_ = ANIMATION_FADE_OUT;
Edman Anjosd6ea31b2023-10-11 16:51:46664 if (!login_window_) {
tengs@chromium.org535d2b12013-08-20 12:14:47665 LoadURL(GURL(kAppLaunchSplashURL));
Edman Anjosd6ea31b2023-10-11 16:51:46666 }
tengs@chromium.org535d2b12013-08-20 12:14:47667
668 login_view_->set_should_emit_login_prompt_visible(false);
tengs@chromium.org535d2b12013-08-20 12:14:47669}
670
nkostylev@chromium.org4ac57882013-04-22 05:22:45671////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30672// LoginDisplayHostWebUI, public
nkostylev@chromium.org4ac57882013-04-22 05:22:45673
Jacob Dufault1c71f8b2017-11-10 00:42:30674void LoginDisplayHostWebUI::OnBrowserCreated() {
Roman Sorokinfdba16d22021-02-02 09:45:37675 VLOG(4) << "OnBrowserCreated";
nkostylev@chromium.org4ac57882013-04-22 05:22:45676 // Close lock window now so that the launched browser can receive focus.
677 ResetLoginWindowAndView();
678}
679
Jacob Dufault1c71f8b2017-11-10 00:42:30680OobeUI* LoginDisplayHostWebUI::GetOobeUI() const {
Edman Anjosd6ea31b2023-10-11 16:51:46681 if (!login_view_) {
jdufault55c7b0b2016-10-20 23:25:32682 return nullptr;
Edman Anjosd6ea31b2023-10-11 16:51:46683 }
jdufault55c7b0b2016-10-20 23:25:32684 return login_view_->GetOobeUI();
joaodasilva@chromium.orgbad588b92011-12-27 14:49:41685}
686
Jacob Dufaultcb9aed042018-06-21 17:10:24687content::WebContents* LoginDisplayHostWebUI::GetOobeWebContents() const {
Edman Anjosd6ea31b2023-10-11 16:51:46688 if (!login_view_) {
Jacob Dufaultcb9aed042018-06-21 17:10:24689 return nullptr;
Edman Anjosd6ea31b2023-10-11 16:51:46690 }
Jacob Dufaultcb9aed042018-06-21 17:10:24691 return login_view_->GetWebContents();
692}
nkostylev@chromium.org770e03b2011-03-18 11:27:05693
nkostylev@chromium.org4ac57882013-04-22 05:22:45694////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30695// LoginDisplayHostWebUI, WebContentsObserver:
nkostylev@chromium.org4ac57882013-04-22 05:22:45696
Dave Tapuska7052b7c52021-10-18 17:30:53697void LoginDisplayHostWebUI::PrimaryMainFrameRenderProcessGone(
698 base::TerminationStatus status) {
nkostylev@chromium.org4ac57882013-04-22 05:22:45699 // Do not try to restore on shutdown
Edman Anjosd6ea31b2023-10-11 16:51:46700 if (browser_shutdown::HasShutdownStarted()) {
nkostylev@chromium.org4ac57882013-04-22 05:22:45701 return;
Edman Anjosd6ea31b2023-10-11 16:51:46702 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45703
704 crash_count_++;
Edman Anjosd6ea31b2023-10-11 16:51:46705 if (crash_count_ > kCrashCountLimit) {
nkostylev@chromium.org4ac57882013-04-22 05:22:45706 return;
Edman Anjosd6ea31b2023-10-11 16:51:46707 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45708
709 if (status != base::TERMINATION_STATUS_NORMAL_TERMINATION) {
710 // Render with login screen crashed. Let's crash browser process to let
711 // session manager restart it properly. It is hard to reload the page
712 // and get to controlled state that is fully functional.
713 // If you see check, search for renderer crash for the same client.
714 LOG(FATAL) << "Renderer crash on login window";
715 }
716}
717
718////////////////////////////////////////////////////////////////////////////////
Yeunjoo Choi5e3f6edd2022-06-23 02:43:36719// LoginDisplayHostWebUI, SessionManagerClient::Observer:
ygorshenin@chromium.orgfe703f02013-11-02 22:11:20720
Jacob Dufault1c71f8b2017-11-10 00:42:30721void LoginDisplayHostWebUI::EmitLoginPromptVisibleCalled() {
ygorshenin@chromium.orgfe703f02013-11-02 22:11:20722 OnLoginPromptVisible();
723}
724
nkostylev@chromium.org40db36e2014-04-04 14:08:18725////////////////////////////////////////////////////////////////////////////////
Henrique Ferreirofb734d82021-07-21 15:01:02726// LoginDisplayHostWebUI, CrasAudioHandler::AudioObserver:
nkostylev@chromium.org40db36e2014-04-04 14:08:18727
Jacob Dufault1c71f8b2017-11-10 00:42:30728void LoginDisplayHostWebUI::OnActiveOutputNodeChanged() {
Alexander Alekseevc1710c92018-08-03 21:02:48729 PlayStartupSoundIfPossible();
ygorshenin@chromium.org0bd2c492013-12-03 17:08:29730}
731
ygorshenin@chromium.orgfe703f02013-11-02 22:11:20732////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30733// LoginDisplayHostWebUI, display::DisplayObserver:
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29734
Jacob Dufault1c71f8b2017-11-10 00:42:30735void LoginDisplayHostWebUI::OnDisplayAdded(
736 const display::Display& new_display) {
Edman Anjosd6ea31b2023-10-11 16:51:46737 if (GetOobeUI()) {
felixebcbc0c42017-05-11 10:53:50738 GetOobeUI()->OnDisplayConfigurationChanged();
Edman Anjosd6ea31b2023-10-11 16:51:46739 }
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29740}
741
Jacob Dufault1c71f8b2017-11-10 00:42:30742void LoginDisplayHostWebUI::OnDisplayMetricsChanged(
oshimad5c972e2016-04-28 23:17:14743 const display::Display& display,
744 uint32_t changed_metrics) {
felixe491c6b22017-05-24 07:27:22745 const display::Display primary_display =
oshimad5c972e2016-04-28 23:17:14746 display::Screen::GetScreen()->GetPrimaryDisplay();
pkotwicz9eda0c62014-10-31 15:28:54747 if (display.id() != primary_display.id() ||
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29748 !(changed_metrics & DISPLAY_METRIC_BOUNDS)) {
749 return;
750 }
751
nkostylev@chromium.orgc9e094b2014-05-29 14:14:29752 if (GetOobeUI()) {
Renato Silva9d0017722023-05-19 16:25:56753 GetOobeUI()->GetCoreOobe()->UpdateClientAreaSize(primary_display.size());
Edman Anjosd6ea31b2023-10-11 16:51:46754 if (changed_metrics & DISPLAY_METRIC_PRIMARY) {
felixe491c6b22017-05-24 07:27:22755 GetOobeUI()->OnDisplayConfigurationChanged();
Edman Anjosd6ea31b2023-10-11 16:51:46756 }
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29757 }
758}
759
Roman Sorokin182fcf62021-11-22 17:11:38760void LoginDisplayHostWebUI::OnShowWebUITimeout() {
761 VLOG(1) << "Login WebUI >> Show WebUI because of timeout";
762 ShowWebUI();
763}
764
Danila Kuzmin742daa62023-05-15 09:39:23765void LoginDisplayHostWebUI::OnViewsBootingAnimationPlayed() {
766 booting_animation_finished_playing_ = true;
767 if (webui_ready_to_take_over_) {
768 // This function is called by the AnimationObserver which can't destroy the
769 // animation on its own so we need to post a task to do so.
770 content::GetUIThreadTaskRunner({})->PostTask(
771 FROM_HERE,
772 base::BindOnce(&LoginDisplayHostWebUI::FinishBootingAnimation,
773 weak_factory_.GetWeakPtr()));
774 }
775}
776
777void LoginDisplayHostWebUI::FinishBootingAnimation() {
Simon Ziegltrum503b22d2023-11-03 12:47:39778 CHECK(features::IsBootAnimationEnabled());
Danila Kuzmin742daa62023-05-15 09:39:23779 ash::Shell::Get()->booting_animation_controller()->Finish();
Renato Silva9d0017722023-05-19 16:25:56780 GetOobeUI()->GetCoreOobe()->TriggerDown();
Danila Kuzmin27591c152023-05-12 09:45:38781}
782
nkostylev@chromium.orgecdbcf52014-05-26 16:17:29783////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30784// LoginDisplayHostWebUI, ui::InputDeviceEventObserver
Mustaq Ahmede8be37f2018-12-18 21:33:53785void LoginDisplayHostWebUI::OnInputDeviceConfigurationChanged(
786 uint8_t input_device_types) {
787 if ((input_device_types & ui::InputDeviceEventObserver::kTouchscreen) &&
788 GetOobeUI()) {
Felix Ekblomd706dfc2017-07-21 09:17:08789 GetOobeUI()->OnDisplayConfigurationChanged();
Mustaq Ahmede8be37f2018-12-18 21:33:53790 }
Felix Ekblomd706dfc2017-07-21 09:17:08791}
792
793////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30794// LoginDisplayHostWebUI, views::WidgetRemovalsObserver:
795void LoginDisplayHostWebUI::OnWillRemoveView(views::Widget* widget,
796 views::View* view) {
Edman Anjosd6ea31b2023-10-11 16:51:46797 if (view != static_cast<views::View*>(login_view_)) {
rsorokin@chromium.org69e6f0e2014-07-08 22:53:14798 return;
Edman Anjosd6ea31b2023-10-11 16:51:46799 }
Roman Sorokin68ca8062020-12-01 15:49:16800 ResetLoginView();
rsorokin@chromium.org69e6f0e2014-07-08 22:53:14801 widget->RemoveRemovalsObserver(this);
802}
803
804////////////////////////////////////////////////////////////////////////////////
Xiyuan Xia056687f2018-12-19 23:14:06805// LoginDisplayHostWebUI, views::WidgetObserver:
806void LoginDisplayHostWebUI::OnWidgetDestroying(views::Widget* widget) {
807 DCHECK_EQ(login_window_, widget);
808 login_window_->RemoveRemovalsObserver(this);
809 login_window_->RemoveObserver(this);
810
811 login_window_ = nullptr;
Roman Sorokin68ca8062020-12-01 15:49:16812 ResetLoginView();
Xiyuan Xia056687f2018-12-19 23:14:06813}
814
yilkal164e3aa2020-11-06 18:39:59815void LoginDisplayHostWebUI::OnWidgetBoundsChanged(views::Widget* widget,
816 const gfx::Rect& new_bounds) {
Edman Anjosd6ea31b2023-10-11 16:51:46817 for (auto& observer : observers_) {
yilkal164e3aa2020-11-06 18:39:59818 observer.WebDialogViewBoundsChanged(new_bounds);
Edman Anjosd6ea31b2023-10-11 16:51:46819 }
yilkal164e3aa2020-11-06 18:39:59820}
821
Xiyuan Xia056687f2018-12-19 23:14:06822////////////////////////////////////////////////////////////////////////////////
Denis Kuznetsov5d9c9b252022-08-01 17:59:46823// LoginDisplayHostWebUI, OobeUI::Observer
xdai7a1a51842016-04-23 01:15:41824
Roman Sorokinc0b7c182022-03-15 15:59:52825void LoginDisplayHostWebUI::OnCurrentScreenChanged(OobeScreenId current_screen,
826 OobeScreenId new_screen) {
Roman Sorokinba7e9062022-04-13 16:45:52827 if (current_screen == ash::OOBE_SCREEN_UNKNOWN) {
Renato Silva2e22ff5b2022-04-07 14:55:20828 // TODO(crbug.com/1305245) - Remove once the issue is fixed.
829 LOG(WARNING) << "LoginDisplayHostWebUI::OnCurrentScreenChanged() "
830 "NotifyLoginOrLockScreenVisible";
831
Danila Kuzmine4717542023-05-24 19:29:42832 // Notify that the OOBE page is ready and the first screen is shown. It
833 // might happen that front-end part isn't fully initialized yet (when
834 // `OobeLazyLoading` is enabled), so wait for it to happen before notifying.
835 GetOobeUI()->IsJSReady(base::BindOnce(
836 &session_manager::SessionManager::NotifyLoginOrLockScreenVisible,
837 base::Unretained(session_manager::SessionManager::Get())));
Renato Silva2e22ff5b2022-04-07 14:55:20838 } else {
839 // TODO(crbug.com/1305245) - Remove once the issue is fixed.
840 LOG(WARNING) << "LoginDisplayHostWebUI::OnCurrentScreenChanged() Not "
841 "notifying LoginOrLockScreenVisible.";
Roman Sorokinc0b7c182022-03-15 15:59:52842 }
843}
844
Danila Kuzmin742daa62023-05-15 09:39:23845void LoginDisplayHostWebUI::OnBackdropLoaded() {
846 webui_ready_to_take_over_ = true;
847 if (booting_animation_finished_playing_) {
848 FinishBootingAnimation();
849 }
850}
851
Roman Sorokinc0b7c182022-03-15 15:59:52852void LoginDisplayHostWebUI::OnDestroyingOobeUI() {
853 GetOobeUI()->RemoveObserver(this);
854}
855
Roman Sorokinf5cbe392021-08-16 09:12:41856bool LoginDisplayHostWebUI::IsOobeUIDialogVisible() const {
857 return true;
858}
859
Danila Kuzmin5346f2f2023-02-08 16:00:21860bool LoginDisplayHostWebUI::HandleAccelerator(LoginAcceleratorAction action) {
861 if (action == LoginAcceleratorAction::kToggleSystemInfo) {
862 if (!GetOobeUI()) {
863 return false;
864 }
Renato Silva9d0017722023-05-19 16:25:56865 GetOobeUI()->GetCoreOobe()->ToggleSystemInfo();
Danila Kuzmin5346f2f2023-02-08 16:00:21866 return true;
867 }
868
869 return LoginDisplayHostCommon::HandleAccelerator(action);
870}
871
xdai7a1a51842016-04-23 01:15:41872////////////////////////////////////////////////////////////////////////////////
Jacob Dufault1c71f8b2017-11-10 00:42:30873// LoginDisplayHostWebUI, private
nkostylev@chromium.org4ac57882013-04-22 05:22:45874
Jacob Dufault1c71f8b2017-11-10 00:42:30875void LoginDisplayHostWebUI::ScheduleWorkspaceAnimation() {
avi3ef9ec9e2014-12-22 22:50:17876 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
xiyuane6a229f2017-05-25 15:04:59877 switches::kDisableLoginAnimations)) {
Henrique Ferreirofb734d82021-07-21 15:01:02878 Shell::Get()->DoInitialWorkspaceAnimation();
xiyuane6a229f2017-05-25 15:04:59879 }
nkostylev@chromium.org770e03b2011-03-18 11:27:05880}
881
Jacob Dufault1c71f8b2017-11-10 00:42:30882void LoginDisplayHostWebUI::ScheduleFadeOutAnimation(int animation_speed_ms) {
xdai605f8102016-04-15 20:02:55883 // login window might have been closed by OnBrowserCreated() at this moment.
884 // This may happen when adding another user into the session, and a browser
885 // is created before session start, which triggers the close of the login
886 // window. In this case, we should shut down the display host directly.
887 if (!login_window_) {
Xiyuan Xia1a92b112017-12-08 23:04:22888 ShutdownDisplayHost();
xdai605f8102016-04-15 20:02:55889 return;
890 }
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44891 ui::Layer* layer = login_window_->GetLayer();
892 ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
893 animation.AddObserver(new AnimationObserver(
Reilly Grant3afb5452021-01-23 03:07:19894 base::BindOnce(&LoginDisplayHostWebUI::ShutdownDisplayHost,
895 weak_factory_.GetWeakPtr())));
Peter Kastinge5a38ed2021-10-02 03:06:35896 animation.SetTransitionDuration(base::Milliseconds(animation_speed_ms));
xiyuan@chromium.orgbae09636f2013-10-29 22:18:44897 layer->SetOpacity(0);
898}
899
Jacob Dufault1c71f8b2017-11-10 00:42:30900void LoginDisplayHostWebUI::LoadURL(const GURL& url) {
nkostylev@chromium.org4ac57882013-04-22 05:22:45901 InitLoginWindowAndView();
902 // Subscribe to crash events.
903 content::WebContentsObserver::Observe(login_view_->GetWebContents());
904 login_view_->LoadURL(url);
Simon Ziegltrum503b22d2023-11-03 12:47:39905 if (!ash::features::IsBootAnimationEnabled()) {
Danila Kuzmin918482d2023-06-01 10:40:55906 login_window_->Show();
907 }
Roman Sorokinc0b7c182022-03-15 15:59:52908 CHECK(GetOobeUI());
909 GetOobeUI()->AddObserver(this);
nkostylev@chromium.org4ac57882013-04-22 05:22:45910}
911
Jacob Dufault1c71f8b2017-11-10 00:42:30912void LoginDisplayHostWebUI::ShowWebUI() {
Roman Sorokin182fcf62021-11-22 17:11:38913 session_observation_.Reset();
914 show_webui_guard_.AbandonAndStop();
915
Xiyuan Xiadf379182019-07-23 19:41:03916 DCHECK(login_window_);
917 DCHECK(login_view_);
918
stevenjb@chromium.orge6898662014-07-17 05:03:53919 VLOG(1) << "Login WebUI >> Show already initialized UI";
nkostylev@chromium.org4ac57882013-04-22 05:22:45920 login_window_->Show();
jam@chromium.orgfc2b46b2014-05-03 16:33:45921 login_view_->GetWebContents()->Focus();
nkostylev@chromium.org4ac57882013-04-22 05:22:45922 login_view_->SetStatusAreaVisible(status_area_saved_visibility_);
923 login_view_->OnPostponedShow();
Roman Sorokin73e8d5082021-04-14 11:09:25924
925 if (oobe_load_timer_.has_value()) {
926 base::UmaHistogramTimes("OOBE.WebUI.LoadTime.FirstRun",
927 oobe_load_timer_->Elapsed());
928 oobe_load_timer_.reset();
929 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45930}
931
Jacob Dufault1c71f8b2017-11-10 00:42:30932void LoginDisplayHostWebUI::InitLoginWindowAndView() {
Edman Anjosd6ea31b2023-10-11 16:51:46933 if (login_window_) {
nkostylev@chromium.org4ac57882013-04-22 05:22:45934 return;
Edman Anjosd6ea31b2023-10-11 16:51:46935 }
nkostylev@chromium.org4ac57882013-04-22 05:22:45936
Scott Violet7618db6a2019-06-20 01:22:07937 if (system::InputDeviceSettings::ForceKeyboardDrivenUINavigation()) {
xiyuan@chromium.org96a30552013-11-02 05:21:24938 views::FocusManager::set_arrow_key_traversal_enabled(true);
Henrique Ferreirofb734d82021-07-21 15:01:02939 focus_ring_controller_ = std::make_unique<FocusRingController>();
xiyuan@chromium.org96a30552013-11-02 05:21:24940 focus_ring_controller_->SetVisible(true);
941
Peter Boström6b701822021-04-15 03:53:08942 keyboard_driven_oobe_key_handler_ =
943 std::make_unique<KeyboardDrivenOobeKeyHandler>();
xiyuan@chromium.org96a30552013-11-02 05:21:24944 }
945
nkostylev@chromium.org4ac57882013-04-22 05:22:45946 views::Widget::InitParams params(
947 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
Jacob Dufaultd052b5c62018-02-08 23:56:00948 params.bounds = CalculateScreenBounds(gfx::Size());
Xiaohui Chenabeb0dc2019-01-10 02:18:38949 params.show_state = ui::SHOW_STATE_FULLSCREEN;
Hwanseung Lee787d0aa2019-11-22 00:31:08950 params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent;
Yue Li843ce812017-08-10 00:13:13951
Xiaohui Chenabeb0dc2019-01-10 02:18:38952 ash_util::SetupWidgetInitParamsForContainer(
Henrique Ferreirofb734d82021-07-21 15:01:02953 &params, kShellWindowId_LockScreenContainer);
nkostylev@chromium.org4ac57882013-04-22 05:22:45954 login_window_ = new views::Widget;
Ahmed Fakhry32f3c452019-08-01 16:36:34955 login_window_->Init(std::move(params));
nkostylev@chromium.org40db36e2014-04-04 14:08:18956
Denis Kuznetsovad5a97c2020-07-09 10:45:35957 login_view_ = new WebUILoginView(WebUILoginView::WebViewSettings(),
958 weak_factory_.GetWeakPtr());
dzhioev@chromium.org3ed40bb2013-08-22 17:32:26959 login_view_->Init();
nkostylev@chromium.org4ac57882013-04-22 05:22:45960
Xiaohui Chenabeb0dc2019-01-10 02:18:38961 login_window_->SetVisibilityAnimationDuration(
Peter Kastinge5a38ed2021-10-02 03:06:35962 base::Milliseconds(kLoginFadeoutTransitionDurationMs));
Xiaohui Chenabeb0dc2019-01-10 02:18:38963 login_window_->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE);
nkostylev@chromium.org4ac57882013-04-22 05:22:45964
Xiyuan Xia056687f2018-12-19 23:14:06965 login_window_->AddObserver(this);
rsorokin@chromium.org69e6f0e2014-07-08 22:53:14966 login_window_->AddRemovalsObserver(this);
nkostylev@chromium.org4ac57882013-04-22 05:22:45967 login_window_->SetContentsView(login_view_);
nkostylev@chromium.org4ac57882013-04-22 05:22:45968 login_window_->GetNativeView()->SetName("WebUILoginView");
Xiyuan Xiadf379182019-07-23 19:41:03969
970 // Delay showing the window until the login webui is ready.
971 VLOG(1) << "Login WebUI >> login window is hidden on create";
972 login_view_->set_is_hidden(true);
Roman Sorokin182fcf62021-11-22 17:11:38973
974 // A minute should be enough time for the UI to load.
975 show_webui_guard_.Start(FROM_HERE, base::Minutes(1), this,
976 &LoginDisplayHostWebUI::OnShowWebUITimeout);
nkostylev@chromium.org4ac57882013-04-22 05:22:45977}
978
Jacob Dufault1c71f8b2017-11-10 00:42:30979void LoginDisplayHostWebUI::ResetLoginWindowAndView() {
Roman Sorokin41b89f52022-01-25 18:46:54980 LOG(WARNING) << "ResetLoginWindowAndView";
Toni Barzicf3c784b2020-02-20 17:24:59981 // Notify any oobe dialog state observers (e.g. login shelf) that the UI is
982 // hidden (so they can reset any cached OOBE dialog state.)
Henrique Ferreirofb734d82021-07-21 15:01:02983 LoginScreen::Get()->GetModel()->NotifyOobeDialogState(
984 OobeDialogState::HIDDEN);
Toni Barzicf3c784b2020-02-20 17:24:59985
Denis Kuznetsovddc02312020-10-19 11:30:13986 // Make sure to reset the `login_view_` pointer first; it is owned by
987 // `login_window_`. Closing `login_window_` could immediately invalidate the
988 // `login_view_` pointer.
jdufaulte7952a22017-02-07 00:44:47989 if (login_view_) {
Danila Kuzminf31c97f2023-04-26 13:02:23990 login_view_->SetKeyboardEventsAndSystemTrayEnabled(true);
Roman Sorokin68ca8062020-12-01 15:49:16991 ResetLoginView();
jdufaulte7952a22017-02-07 00:44:47992 }
afakhry4c09e0c2014-10-29 23:28:20993
jdufaulte7952a22017-02-07 00:44:47994 if (login_window_) {
Roman Sorokin44b0d0ab2022-02-01 17:33:04995 login_window_->CloseWithReason(views::Widget::ClosedReason::kUnspecified);
Evan Rosky15b56c82017-09-25 19:40:03996 login_window_->RemoveRemovalsObserver(this);
Xiyuan Xia056687f2018-12-19 23:14:06997 login_window_->RemoveObserver(this);
jdufaulte7952a22017-02-07 00:44:47998 login_window_ = nullptr;
999 }
Xiyuan Xiaa6547382017-12-08 16:25:081000
1001 // Release wizard controller with the webui and hosting window so that it
1002 // does not find missing webui handlers in surprise.
1003 wizard_controller_.reset();
nkostylev@chromium.org4ac57882013-04-22 05:22:451004}
1005
Jacob Dufault73671d42018-01-03 22:06:361006void LoginDisplayHostWebUI::TryToPlayOobeStartupSound() {
Alexander Alekseevc1710c92018-08-03 21:02:481007 need_to_play_startup_sound_ = true;
1008 PlayStartupSoundIfPossible();
ygorshenin@chromium.orgfe703f02013-11-02 22:11:201009}
1010
Roman Sorokin68ca8062020-12-01 15:49:161011void LoginDisplayHostWebUI::ResetLoginView() {
Edman Anjosd6ea31b2023-10-11 16:51:461012 if (!login_view_) {
Roman Sorokin68ca8062020-12-01 15:49:161013 return;
Edman Anjosd6ea31b2023-10-11 16:51:461014 }
Roman Sorokin68ca8062020-12-01 15:49:161015
1016 OobeUI* oobe_ui = login_view_->GetOobeUI();
Roman Sorokinc0b7c182022-03-15 15:59:521017 if (oobe_ui) {
Roman Sorokinc0b7c182022-03-15 15:59:521018 oobe_ui->RemoveObserver(this);
1019 }
Roman Sorokin68ca8062020-12-01 15:49:161020
1021 login_view_ = nullptr;
1022}
1023
Jacob Dufault1c71f8b2017-11-10 00:42:301024void LoginDisplayHostWebUI::OnLoginPromptVisible() {
Edman Anjosd6ea31b2023-10-11 16:51:461025 if (!login_prompt_visible_time_.is_null()) {
ygorshenin@chromium.orgfe703f02013-11-02 22:11:201026 return;
Edman Anjosd6ea31b2023-10-11 16:51:461027 }
ygorshenin@chromium.orgfe703f02013-11-02 22:11:201028 login_prompt_visible_time_ = base::TimeTicks::Now();
Jacob Dufault73671d42018-01-03 22:06:361029 TryToPlayOobeStartupSound();
ygorshenin@chromium.orgfe703f02013-11-02 22:11:201030}
1031
Jacob Dufaulte78efab992018-06-22 18:18:521032void LoginDisplayHostWebUI::CreateExistingUserController() {
Jacob Dufault0ef3aab02018-07-17 15:54:501033 existing_user_controller_ = std::make_unique<ExistingUserController>();
Jacob Dufaulte78efab992018-06-22 18:18:521034}
1035
Roman Sorokin26d7e9662020-02-24 17:52:181036void LoginDisplayHostWebUI::ShowGaiaDialog(const AccountId& prefilled_account) {
Alexander Alekseevd09cdba2019-03-08 06:42:511037 ShowGaiaDialogCommon(prefilled_account);
Danila Kuzmin9d524572023-07-25 21:15:181038 UpdateWallpaper(prefilled_account);
Wenzhao Zang767a9f32018-05-02 21:20:551039}
Sarah Hu9fba0e752018-02-07 01:41:091040
Danila Kuzmin24986a82021-09-03 14:13:001041void LoginDisplayHostWebUI::ShowOsInstallScreen() {
1042 StartWizard(OsInstallScreenView::kScreenId);
1043}
1044
Ossama Mahmoud8fa195f2021-09-30 19:51:251045void LoginDisplayHostWebUI::ShowGuestTosScreen() {
1046 StartWizard(GuestTosScreenView::kScreenId);
1047}
1048
Ashutosh Singhal8ff34072023-11-09 14:26:591049void LoginDisplayHostWebUI::ShowRemoteActivityNotificationScreen() {
1050 StartWizard(RemoteActivityNotificationView::kScreenId);
1051}
1052
Danila Kuzmin157fb302022-06-21 10:44:551053void LoginDisplayHostWebUI::HideOobeDialog(bool saml_page_closed) {
Peter Boström36684f8d2024-02-13 19:32:551054 DUMP_WILL_BE_NOTREACHED_NORETURN();
Jacob Dufault4f4fa352018-06-27 17:31:071055}
1056
Yunke Zhou9319aab2020-12-01 07:34:421057void LoginDisplayHostWebUI::SetShelfButtonsEnabled(bool enabled) {
Henrique Ferreirofb734d82021-07-21 15:01:021058 LoginScreen::Get()->EnableShelfButtons(enabled);
Edman Anjosd6ea31b2023-10-11 16:51:461059 if (GetWebUILoginView()) {
Akihiro Otaef006f52020-12-16 15:45:041060 GetWebUILoginView()->set_shelf_enabled(enabled);
Edman Anjosd6ea31b2023-10-11 16:51:461061 }
Yunke Zhou9319aab2020-12-01 07:34:421062}
1063
Henrique Ferreirofb734d82021-07-21 15:01:021064void LoginDisplayHostWebUI::UpdateOobeDialogState(OobeDialogState state) {
1065 LoginScreen::Get()->GetModel()->NotifyOobeDialogState(state);
Sarah Hu51d19d32018-08-27 19:41:501066}
1067
Quan Nguyenaa5a44d42018-08-21 21:30:471068void LoginDisplayHostWebUI::HandleDisplayCaptivePortal() {
1069 GetOobeUI()->GetErrorScreen()->FixCaptivePortal();
1070}
Quan Nguyen7c534062018-07-17 21:43:011071
Jacob Dufault22a807b2018-07-06 21:01:241072void LoginDisplayHostWebUI::OnCancelPasswordChangedFlow() {}
1073
Denis Kuznetsove3c82782020-12-01 09:33:371074void LoginDisplayHostWebUI::ShowEnableConsumerKioskScreen() {
Edman Anjosd6ea31b2023-10-11 16:51:461075 if (GetExistingUserController()) {
Denis Kuznetsove3c82782020-12-01 09:33:371076 GetExistingUserController()->OnStartKioskEnableScreen();
Edman Anjosd6ea31b2023-10-11 16:51:461077 }
Denis Kuznetsove3c82782020-12-01 09:33:371078}
1079
Sarah Hu4976046e2018-07-19 23:47:471080void LoginDisplayHostWebUI::UpdateAddUserButtonStatus() {
1081 NOTREACHED();
1082}
1083
Victor Hsieh26eb8b02019-11-18 23:56:281084void LoginDisplayHostWebUI::RequestSystemInfoUpdate() {
1085 NOTREACHED();
1086}
1087
Yunke Zhouea445712020-10-05 10:10:241088bool LoginDisplayHostWebUI::HasUserPods() {
1089 return false;
1090}
1091
Denis Kuznetsov55c97be2023-11-09 18:29:381092void LoginDisplayHostWebUI::StartUserRecovery(const AccountId& account_id) {
1093 NOTREACHED();
1094}
1095
Denis Kuznetsovb9ff5492023-11-23 15:44:151096void LoginDisplayHostWebUI::UseAlternativeAuthentication(
1097 std::unique_ptr<UserContext> user_context,
1098 bool online_password_mismatch) {
Yunke Zhou0dc66fe2022-09-16 10:57:201099 NOTREACHED();
1100}
1101
Denis Kuznetsov81053982023-11-08 17:37:541102void LoginDisplayHostWebUI::RunLocalAuthentication(
1103 std::unique_ptr<UserContext> user_context) {
1104 NOTREACHED();
1105}
1106
Yuta Hijikata27bf2f3a2021-07-08 08:03:561107void LoginDisplayHostWebUI::StartBrowserDataMigration() {
1108 NOTREACHED();
1109}
1110
yilkal164e3aa2020-11-06 18:39:591111void LoginDisplayHostWebUI::AddObserver(LoginDisplayHost::Observer* observer) {
1112 observers_.AddObserver(observer);
1113}
yilkal76f9ae22020-10-12 19:48:501114
1115void LoginDisplayHostWebUI::RemoveObserver(
yilkal164e3aa2020-11-06 18:39:591116 LoginDisplayHost::Observer* observer) {
1117 observers_.RemoveObserver(observer);
1118}
yilkal76f9ae22020-10-12 19:48:501119
Sammie Quon0ab09822021-08-24 18:16:101120void LoginDisplayHostWebUI::OnLoginOrLockScreenVisible() {
Sammie Quon5ddda102021-08-18 17:32:071121 VLOG(1) << "Login WebUI >> WEBUI_VISIBLE";
1122 ShowWebUI();
Sammie Quon5ddda102021-08-18 17:32:071123}
1124
Alexander Alekseev118edff2021-09-03 12:24:521125SigninUI* LoginDisplayHostWebUI::GetSigninUI() {
Edman Anjosd6ea31b2023-10-11 16:51:461126 if (!GetWizardController()) {
Alexander Alekseev118edff2021-09-03 12:24:521127 return nullptr;
Edman Anjosd6ea31b2023-10-11 16:51:461128 }
Alexander Alekseev118edff2021-09-03 12:24:521129 return this;
1130}
1131
1132bool LoginDisplayHostWebUI::IsWizardControllerCreated() const {
1133 return wizard_controller_.get();
1134}
1135
Alexander Alekseevf7e3a102021-08-23 12:19:081136bool LoginDisplayHostWebUI::GetKeyboardRemappedPrefValue(
1137 const std::string& pref_name,
1138 int* value) const {
Alexander Alekseevf7e3a102021-08-23 12:19:081139 return false;
1140}
1141
Alexander Alekseev29428722021-11-24 02:08:521142bool LoginDisplayHostWebUI::IsWebUIStarted() const {
1143 return true;
1144}
1145
Alexander Alekseevc1710c92018-08-03 21:02:481146void LoginDisplayHostWebUI::PlayStartupSoundIfPossible() {
Edman Anjosd6ea31b2023-10-11 16:51:461147 if (!need_to_play_startup_sound_ || oobe_startup_sound_played_) {
Alexander Alekseevc1710c92018-08-03 21:02:481148 return;
Edman Anjosd6ea31b2023-10-11 16:51:461149 }
Alexander Alekseevc1710c92018-08-03 21:02:481150
Edman Anjosd6ea31b2023-10-11 16:51:461151 if (login_prompt_visible_time_.is_null()) {
Alexander Alekseevc1710c92018-08-03 21:02:481152 return;
Edman Anjosd6ea31b2023-10-11 16:51:461153 }
Alexander Alekseevc1710c92018-08-03 21:02:481154
Edman Anjosd6ea31b2023-10-11 16:51:461155 if (!CanPlayStartupSound()) {
Alexander Alekseevc1710c92018-08-03 21:02:481156 return;
Edman Anjosd6ea31b2023-10-11 16:51:461157 }
Alexander Alekseevc1710c92018-08-03 21:02:481158
1159 need_to_play_startup_sound_ = false;
1160 oobe_startup_sound_played_ = true;
1161
Alexander Alekseevec0ed3d2018-08-14 08:27:421162 const base::TimeDelta time_since_login_prompt_visible =
1163 base::TimeTicks::Now() - login_prompt_visible_time_;
Roman Sorokin73e8d5082021-04-14 11:09:251164 base::UmaHistogramTimes("Accessibility.OOBEStartupSoundDelay",
1165 time_since_login_prompt_visible);
Alexander Alekseevc1710c92018-08-03 21:02:481166
Alexander Alekseevec0ed3d2018-08-14 08:27:421167 // Don't try to play startup sound if login prompt has been already visible
1168 // for a long time.
1169 if (time_since_login_prompt_visible >
Peter Kastinge5a38ed2021-10-02 03:06:351170 base::Milliseconds(kStartupSoundMaxDelayMs)) {
Alexander Alekseevec0ed3d2018-08-14 08:27:421171 return;
1172 }
Henrique Ferreirobd3e9972021-01-14 18:48:481173 AccessibilityManager::Get()->PlayEarcon(Sound::kStartup,
Henrique Ferreirodc3226db2021-01-15 01:44:141174 PlaySoundOption::kAlways);
Alexander Alekseevc1710c92018-08-03 21:02:481175}
1176
nkostylev@chromium.org4ac57882013-04-22 05:22:451177////////////////////////////////////////////////////////////////////////////////
1178// external
1179
tfarina@chromium.org7ccd8882012-05-13 22:47:071180// Declared in login_wizard.h so that others don't need to depend on our .h.
nkostylev@chromium.org770e03b2011-03-18 11:27:051181// TODO(nkostylev): Split this into a smaller functions.
Jacob Dufaultb7eb2342019-05-01 21:40:371182void ShowLoginWizard(OobeScreenId first_screen) {
Edman Anjosd6ea31b2023-10-11 16:51:461183 if (browser_shutdown::IsTryingToQuit()) {
oshima@google.coma1c2f8f2011-09-12 19:33:311184 return;
Edman Anjosd6ea31b2023-10-11 16:51:461185 }
oshima@google.coma1c2f8f2011-09-12 19:33:311186
Jacob Dufaultb7eb2342019-05-01 21:40:371187 VLOG(1) << "Showing OOBE screen: " << first_screen;
nkostylev@chromium.org770e03b2011-03-18 11:27:051188
Jacob Dufaultd052b5c62018-02-08 23:56:001189 input_method::InputMethodManager* manager =
1190 input_method::InputMethodManager::Get();
yusukes@chromium.orga9a81812011-09-16 11:01:171191
Istvan Nagy37b75cec2023-06-20 13:54:381192 if (g_browser_process && g_browser_process->local_state()) {
1193 manager->GetActiveIMEState()->SetInputMethodLoginDefault();
1194 }
1195
denniskempin@chromium.org158775422014-04-03 18:15:591196 system::InputDeviceSettings::Get()->SetNaturalScroll(
avi3ef9ec9e2014-12-22 22:50:171197 base::CommandLine::ForCurrentProcess()->HasSwitch(
denniskempin@chromium.org158775422014-04-03 18:15:591198 switches::kNaturalScrollDefault));
kinaba@chromium.orgbbd08262013-10-30 09:04:271199
Jacob Dufault76d2b412018-03-21 20:38:121200 auto session_state = session_manager::SessionState::OOBE;
Edman Anjosd6ea31b2023-10-11 16:51:461201 if (IsOobeComplete()) {
Jacob Dufault76d2b412018-03-21 20:38:121202 session_state = session_manager::SessionState::LOGIN_PRIMARY;
Edman Anjosd6ea31b2023-10-11 16:51:461203 }
Jacob Dufault76d2b412018-03-21 20:38:121204 session_manager::SessionManager::Get()->SetSessionState(session_state);
nkostylev@chromium.orgb88d2c62014-07-16 18:20:441205
Edman Anjosd6ea31b2023-10-11 16:51:461206 if (first_screen == AppLaunchSplashScreenView::kScreenId) {
1207 auto app = KioskController::Get().GetAutoLaunchApp();
1208 CHECK(app.has_value());
1209
Jacob Dufault2ab65572017-11-15 21:15:051210 // Manages its own lifetime. See ShutdownDisplayHost().
Jacob Dufaultd052b5c62018-02-08 23:56:001211 auto* display_host = new LoginDisplayHostWebUI();
Edman Anjosd6ea31b2023-10-11 16:51:461212 display_host->StartKiosk(app->id(), /*is_auto_launch=*/true);
tengs@chromium.org535d2b12013-08-20 12:14:471213 return;
1214 }
1215
nkostylev@chromium.orgb88d2c62014-07-16 18:20:441216 // Check whether we need to execute OOBE flow.
mnissler007bfca62014-12-17 12:13:581217 const policy::EnrollmentConfig enrollment_config =
Artem Sumaneevf17d6902022-04-29 09:12:131218 policy::EnrollmentConfig::GetPrescribedEnrollmentConfig();
jdufault9e47a74b2017-01-09 20:46:561219 if (enrollment_config.should_enroll() &&
Roman Sorokinba7e9062022-04-13 16:45:521220 first_screen == ash::OOBE_SCREEN_UNKNOWN) {
Jacob Dufault2ab65572017-11-15 21:15:051221 // Manages its own lifetime. See ShutdownDisplayHost().
Jacob Dufaultd052b5c62018-02-08 23:56:001222 auto* display_host = new LoginDisplayHostWebUI();
xiyuan@chromium.org940893f2014-01-10 07:11:501223 // Shows networks screen instead of enrollment screen to resume the
1224 // interrupted auto start enrollment flow because enrollment screen does
1225 // not handle flaky network. See http://crbug.com/332572
Jacob Dufaultd8c51ab2019-05-03 19:44:551226 display_host->StartWizard(WelcomeView::kScreenId);
Simon Ziegltrum503b22d2023-11-03 12:47:391227 // Make sure we load an initial wallpaper here. If the boot animation
Danila Kuzminf60c66732023-05-22 19:50:261228 // might be played it will be covered by the StartWizard call.
Simon Ziegltrum503b22d2023-11-03 12:47:391229 if (!ash::features::IsBootAnimationEnabled()) {
Danila Kuzminf60c66732023-05-22 19:50:261230 WallpaperControllerClientImpl::Get()->SetInitialWallpaper();
1231 }
xiyuan@chromium.orgbfdd1292013-12-03 01:25:561232 return;
1233 }
1234
alemate@chromium.org94365822014-04-23 14:17:571235 if (StartupUtils::IsEulaAccepted()) {
Kush Sinhaaad43afc2023-03-23 17:40:421236 DelayNetworkCall(ServicesCustomizationDocument::GetInstance()
Peter Kastinge5a38ed2021-10-02 03:06:351237 ->EnsureCustomizationAppliedClosure());
alemate48255f32015-01-30 18:11:411238
alemate75b7a5c2016-03-29 06:39:461239 g_browser_process->platform_part()
1240 ->GetTimezoneResolverManager()
1241 ->UpdateTimezoneResolver();
alemate@chromium.org94365822014-04-23 14:17:571242 }
1243
pmarko8c3ffb52017-02-08 12:18:351244 PrefService* prefs = g_browser_process->local_state();
Ran Ji73f3b432018-07-15 22:10:271245 std::string current_locale =
1246 prefs->GetString(language::prefs::kApplicationLocale);
Claudio Magnie0a80bb2018-01-31 02:52:581247 language::ConvertToActualUILocale(&current_locale);
pmarko8c3ffb52017-02-08 12:18:351248 VLOG(1) << "Current locale: " << current_locale;
nkostylev@chromium.org770e03b2011-03-18 11:27:051249
pmarko8c3ffb52017-02-08 12:18:351250 if (ShouldShowSigninScreen(first_screen)) {
1251 std::string switch_locale = GetManagedLoginScreenLocale();
Edman Anjosd6ea31b2023-10-11 16:51:461252 if (switch_locale == current_locale) {
pmarko8c3ffb52017-02-08 12:18:351253 switch_locale.clear();
Edman Anjosd6ea31b2023-10-11 16:51:461254 }
pmarko8c3ffb52017-02-08 12:18:351255
1256 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data =
Jinho Bang341ce5b02018-01-17 22:46:031257 std::make_unique<ShowLoginWizardSwitchLanguageCallbackData>(
Jacob Dufault2ab65572017-11-15 21:15:051258 first_screen, nullptr);
pmarko8c3ffb52017-02-08 12:18:351259 TriggerShowLoginWizardFinish(switch_locale, std::move(data));
nkostylev@chromium.org770e03b2011-03-18 11:27:051260 return;
1261 }
1262
1263 // Load startup manifest.
nkostylev@chromium.orgb88d2c62014-07-16 18:20:441264 const StartupCustomizationDocument* startup_manifest =
1265 StartupCustomizationDocument::GetInstance();
nkostylev@chromium.org770e03b2011-03-18 11:27:051266
dpolukhin@chromium.orgd356d7e2011-08-16 10:45:071267 // Switch to initial locale if specified by customization
1268 // and has not been set yet. We cannot call
nkostylev@chromium.orgb88d2c62014-07-16 18:20:441269 // LanguageSwitchMenu::SwitchLanguage here before
dpolukhin@chromium.orgd356d7e2011-08-16 10:45:071270 // EmitLoginPromptReady.
shuchen@chromium.org2ae5bc92014-06-16 15:53:561271 const std::string& locale = startup_manifest->initial_locale_default();
nona@chromium.orga99692f2013-08-22 07:29:371272
shuchen@chromium.org2ae5bc92014-06-16 15:53:561273 const std::string& layout = startup_manifest->keyboard_layout();
Jorge Lucangeli Obes8bce54f2019-02-01 20:50:251274 VLOG(1) << "Initial locale: " << locale << " keyboard layout: " << layout;
nona@chromium.org396991402014-02-17 10:56:171275
1276 // Determine keyboard layout from OEM customization (if provided) or
1277 // initial locale and save it in preferences.
alemate@chromium.orgf0881cf2014-08-15 23:31:421278 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale,
1279 layout);
nona@chromium.org396991402014-02-17 10:56:171280
pmarko8c3ffb52017-02-08 12:18:351281 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data(
Jacob Dufault2ab65572017-11-15 21:15:051282 new ShowLoginWizardSwitchLanguageCallbackData(first_screen,
1283 startup_manifest));
pmarko8c3ffb52017-02-08 12:18:351284
alemate@chromium.orgfcb10a482013-11-13 20:08:431285 if (!current_locale.empty() || locale.empty()) {
pmarko8c3ffb52017-02-08 12:18:351286 TriggerShowLoginWizardFinish(std::string(), std::move(data));
alemate@chromium.orgfcb10a482013-11-13 20:08:431287 return;
nkostylev@chromium.org770e03b2011-03-18 11:27:051288 }
1289
alemate@chromium.orgfcb10a482013-11-13 20:08:431290 // Save initial locale from VPD/customization manifest as current
1291 // Chrome locale. Otherwise it will be lost if Chrome restarts.
1292 // Don't need to schedule pref save because setting initial local
1293 // will enforce preference saving.
Ran Ji73f3b432018-07-15 22:10:271294 prefs->SetString(language::prefs::kApplicationLocale, locale);
nkostylev@chromium.orgb88d2c62014-07-16 18:20:441295 StartupUtils::SetInitialLocale(locale);
nkostylev@chromium.org770e03b2011-03-18 11:27:051296
pmarko8c3ffb52017-02-08 12:18:351297 TriggerShowLoginWizardFinish(locale, std::move(data));
nkostylev@chromium.org770e03b2011-03-18 11:27:051298}
1299
Roman Sorokin373dd992020-04-24 07:40:461300void SwitchWebUItoMojo() {
1301 DCHECK_EQ(LoginDisplayHost::default_host()->GetOobeUI()->display_type(),
1302 OobeUI::kOobeDisplay);
1303
Roman Sorokin373dd992020-04-24 07:40:461304 // This replaces WebUI host with the Mojo (views) host.
Roman Sorokinba7e9062022-04-13 16:45:521305 ShowLoginWizard(ash::OOBE_SCREEN_UNKNOWN);
Roman Sorokin373dd992020-04-24 07:40:461306}
1307
Henrique Ferreirofb734d82021-07-21 15:01:021308} // namespace ash