1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h"
11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/browser_process_platform_part.h"
14 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_actor.h"
15 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h"
16 #include "chrome/browser/chromeos/login/screens/error_screen.h"
17 #include "chrome/browser/chromeos/login/startup_utils.h"
18 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
20 #include "chrome/browser/chromeos/login/wizard_controller.h"
21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
22 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
23 #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h"
24 #include "chrome/browser/chromeos/system/input_device_settings.h"
25 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h"
26 #include "chrome/browser/extensions/tab_helper.h"
27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/webui/about_ui.h"
29 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
30 #include "chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h"
31 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
32 #include "chrome/browser/ui/webui/chromeos/login/controller_pairing_screen_handler.h"
33 #include "chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h"
34 #include "chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h"
35 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
36 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
37 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
38 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
39 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
40 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h"
41 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
42 #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h"
43 #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h"
44 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h"
45 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
46 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
47 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
48 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
49 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h"
50 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h"
51 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
52 #include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h"
53 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
54 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h"
55 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
56 #include "chrome/browser/ui/webui/theme_source.h"
57 #include "chrome/common/chrome_constants.h"
58 #include "chrome/common/url_constants.h"
59 #include "chromeos/chromeos_switches.h"
60 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
61 #include "content/public/browser/web_ui.h"
62 #include "content/public/browser/web_ui_data_source.h"
63 #include "grit/browser_resources.h"
64 #include "grit/chrome_unscaled_resources.h"
65 #include "ui/base/resource/resource_bundle.h"
66 #include "ui/base/webui/web_ui_util.h"
72 const char* kKnownDisplayTypes
[] = {
74 OobeUI::kLoginDisplay
,
76 OobeUI::kUserAddingDisplay
,
77 OobeUI::kAppLaunchSplashDisplay
80 const char kStringsJSPath
[] = "strings.js";
81 const char kLoginJSPath
[] = "login.js";
82 const char kOobeJSPath
[] = "oobe.js";
83 const char kKeyboardUtilsJSPath
[] = "keyboard_utils.js";
84 const char kCustomElementsHTMLPath
[] = "custom_elements.html";
85 const char kCustomElementsJSPath
[] = "custom_elements.js";
87 // Paths for deferred resource loading.
88 const char kEnrollmentHTMLPath
[] = "enrollment.html";
89 const char kEnrollmentCSSPath
[] = "enrollment.css";
90 const char kEnrollmentJSPath
[] = "enrollment.js";
92 // Creates a WebUIDataSource for chrome://oobe
93 content::WebUIDataSource
* CreateOobeUIDataSource(
94 const base::DictionaryValue
& localized_strings
,
95 const std::string
& display_type
) {
96 content::WebUIDataSource
* source
=
97 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost
);
98 source
->AddLocalizedStrings(localized_strings
);
99 source
->SetJsonPath(kStringsJSPath
);
101 if (display_type
== OobeUI::kOobeDisplay
) {
102 source
->SetDefaultResource(IDR_OOBE_HTML
);
103 source
->AddResourcePath(kOobeJSPath
, IDR_OOBE_JS
);
104 source
->AddResourcePath(kCustomElementsHTMLPath
,
105 IDR_CUSTOM_ELEMENTS_OOBE_HTML
);
106 source
->AddResourcePath(kCustomElementsJSPath
, IDR_CUSTOM_ELEMENTS_OOBE_JS
);
108 source
->SetDefaultResource(IDR_LOGIN_HTML
);
109 source
->AddResourcePath(kLoginJSPath
, IDR_LOGIN_JS
);
110 source
->AddResourcePath(kCustomElementsHTMLPath
,
111 IDR_CUSTOM_ELEMENTS_LOGIN_HTML
);
112 source
->AddResourcePath(kCustomElementsJSPath
,
113 IDR_CUSTOM_ELEMENTS_LOGIN_JS
);
115 source
->AddResourcePath(kKeyboardUtilsJSPath
, IDR_KEYBOARD_UTILS_JS
);
116 source
->OverrideContentSecurityPolicyFrameSrc(
118 "frame-src chrome://terms/ %s/;",
119 extensions::kGaiaAuthExtensionOrigin
));
120 source
->OverrideContentSecurityPolicyObjectSrc("object-src *;");
121 source
->AddResourcePath("gaia_auth_host.js",
122 StartupUtils::IsWebviewSigninEnabled()
123 ? IDR_GAIA_AUTH_AUTHENTICATOR_JS
124 : IDR_GAIA_AUTH_HOST_JS
);
126 // Serve deferred resources.
127 source
->AddResourcePath(kEnrollmentHTMLPath
, IDR_OOBE_ENROLLMENT_HTML
);
128 source
->AddResourcePath(kEnrollmentCSSPath
, IDR_OOBE_ENROLLMENT_CSS
);
129 source
->AddResourcePath(kEnrollmentJSPath
, IDR_OOBE_ENROLLMENT_JS
);
131 if (display_type
== OobeUI::kOobeDisplay
) {
132 source
->AddResourcePath("Roboto-Thin.ttf", IDR_FONT_ROBOTO_THIN
);
133 source
->AddResourcePath("Roboto-Light.ttf", IDR_FONT_ROBOTO_LIGHT
);
134 source
->AddResourcePath("Roboto-Regular.ttf", IDR_FONT_ROBOTO_REGULAR
);
135 source
->AddResourcePath("Roboto-Medium.ttf", IDR_FONT_ROBOTO_MEDIUM
);
136 source
->AddResourcePath("Roboto-Bold.ttf", IDR_FONT_ROBOTO_BOLD
);
142 std::string
GetDisplayType(const GURL
& url
) {
143 std::string path
= url
.path().size() ? url
.path().substr(1) : "";
144 if (std::find(kKnownDisplayTypes
,
145 kKnownDisplayTypes
+ arraysize(kKnownDisplayTypes
),
146 path
) == kKnownDisplayTypes
+ arraysize(kKnownDisplayTypes
)) {
147 LOG(ERROR
) << "Unknown display type '" << path
<< "'. Setting default.";
148 return OobeUI::kLoginDisplay
;
156 const char OobeUI::kOobeDisplay
[] = "oobe";
157 const char OobeUI::kLoginDisplay
[] = "login";
158 const char OobeUI::kLockDisplay
[] = "lock";
159 const char OobeUI::kUserAddingDisplay
[] = "user-adding";
160 const char OobeUI::kAppLaunchSplashDisplay
[] = "app-launch-splash";
163 const char OobeUI::kScreenOobeHIDDetection
[] = "hid-detection";
164 const char OobeUI::kScreenOobeNetwork
[] = "connect";
165 const char OobeUI::kScreenOobeEnableDebugging
[] = "debugging";
166 const char OobeUI::kScreenOobeEula
[] = "eula";
167 const char OobeUI::kScreenOobeUpdate
[] = "update";
168 const char OobeUI::kScreenOobeEnrollment
[] = "oauth-enrollment";
169 const char OobeUI::kScreenOobeReset
[] = "reset";
170 const char OobeUI::kScreenGaiaSignin
[] = "gaia-signin";
171 const char OobeUI::kScreenAccountPicker
[] = "account-picker";
172 const char OobeUI::kScreenKioskAutolaunch
[] = "autolaunch";
173 const char OobeUI::kScreenKioskEnable
[] = "kiosk-enable";
174 const char OobeUI::kScreenErrorMessage
[] = "error-message";
175 const char OobeUI::kScreenUserImagePicker
[] = "user-image";
176 const char OobeUI::kScreenTpmError
[] = "tpm-error-message";
177 const char OobeUI::kScreenPasswordChanged
[] = "password-changed";
178 const char OobeUI::kScreenSupervisedUserCreationFlow
[] =
179 "supervised-user-creation";
180 const char OobeUI::kScreenTermsOfService
[] = "terms-of-service";
181 const char OobeUI::kScreenWrongHWID
[] = "wrong-hwid";
182 const char OobeUI::kScreenAutoEnrollmentCheck
[] = "auto-enrollment-check";
183 const char OobeUI::kScreenHIDDetection
[] = "hid-detection";
184 const char OobeUI::kScreenAppLaunchSplash
[] = "app-launch-splash";
185 const char OobeUI::kScreenConfirmPassword
[] = "confirm-password";
186 const char OobeUI::kScreenFatalError
[] = "fatal-error";
187 const char OobeUI::kScreenControllerPairing
[] = "controller-pairing";
188 const char OobeUI::kScreenHostPairing
[] = "host-pairing";
189 const char OobeUI::kScreenDeviceDisabled
[] = "device-disabled";
191 OobeUI::OobeUI(content::WebUI
* web_ui
, const GURL
& url
)
192 : WebUIController(web_ui
),
193 core_handler_(nullptr),
194 network_dropdown_handler_(nullptr),
195 update_view_(nullptr),
196 network_view_(nullptr),
197 debugging_screen_actor_(nullptr),
199 reset_view_(nullptr),
200 hid_detection_view_(nullptr),
201 autolaunch_screen_actor_(nullptr),
202 kiosk_enable_screen_actor_(nullptr),
203 wrong_hwid_screen_actor_(nullptr),
204 auto_enrollment_check_screen_actor_(nullptr),
205 supervised_user_creation_screen_actor_(nullptr),
206 app_launch_splash_screen_actor_(nullptr),
207 controller_pairing_screen_actor_(nullptr),
208 host_pairing_screen_actor_(nullptr),
209 device_disabled_screen_actor_(nullptr),
210 error_screen_handler_(nullptr),
211 signin_screen_handler_(nullptr),
212 terms_of_service_screen_actor_(nullptr),
213 user_image_view_(nullptr),
214 kiosk_app_menu_handler_(nullptr),
215 current_screen_(SCREEN_UNKNOWN
),
216 previous_screen_(SCREEN_UNKNOWN
),
218 display_type_
= GetDisplayType(url
);
219 InitializeScreenMaps();
221 network_state_informer_
= new NetworkStateInformer();
222 network_state_informer_
->Init();
224 core_handler_
= new CoreOobeHandler(this);
225 AddScreenHandler(core_handler_
);
226 core_handler_
->SetDelegate(this);
228 network_dropdown_handler_
= new NetworkDropdownHandler();
229 AddScreenHandler(network_dropdown_handler_
);
231 UpdateScreenHandler
* update_screen_handler
= new UpdateScreenHandler();
232 update_view_
= update_screen_handler
;
233 AddScreenHandler(update_screen_handler
);
235 if (display_type_
== kOobeDisplay
) {
236 NetworkScreenHandler
* network_screen_handler
=
237 new NetworkScreenHandler(core_handler_
);
238 network_view_
= network_screen_handler
;
239 AddScreenHandler(network_screen_handler
);
242 EnableDebuggingScreenHandler
* debugging_screen_handler
=
243 new EnableDebuggingScreenHandler();
244 debugging_screen_actor_
= debugging_screen_handler
;
245 AddScreenHandler(debugging_screen_handler
);
247 EulaScreenHandler
* eula_screen_handler
= new EulaScreenHandler(core_handler_
);
248 eula_view_
= eula_screen_handler
;
249 AddScreenHandler(eula_screen_handler
);
251 ResetScreenHandler
* reset_screen_handler
= new ResetScreenHandler();
252 reset_view_
= reset_screen_handler
;
253 AddScreenHandler(reset_screen_handler
);
255 KioskAutolaunchScreenHandler
* autolaunch_screen_handler
=
256 new KioskAutolaunchScreenHandler();
257 autolaunch_screen_actor_
= autolaunch_screen_handler
;
258 AddScreenHandler(autolaunch_screen_handler
);
260 KioskEnableScreenHandler
* kiosk_enable_screen_handler
=
261 new KioskEnableScreenHandler();
262 kiosk_enable_screen_actor_
= kiosk_enable_screen_handler
;
263 AddScreenHandler(kiosk_enable_screen_handler
);
265 SupervisedUserCreationScreenHandler
* supervised_user_creation_screen_handler
=
266 new SupervisedUserCreationScreenHandler();
267 supervised_user_creation_screen_actor_
=
268 supervised_user_creation_screen_handler
;
269 AddScreenHandler(supervised_user_creation_screen_handler
);
271 WrongHWIDScreenHandler
* wrong_hwid_screen_handler
=
272 new WrongHWIDScreenHandler();
273 wrong_hwid_screen_actor_
= wrong_hwid_screen_handler
;
274 AddScreenHandler(wrong_hwid_screen_handler
);
276 AutoEnrollmentCheckScreenHandler
* auto_enrollment_check_screen_handler
=
277 new AutoEnrollmentCheckScreenHandler();
278 auto_enrollment_check_screen_actor_
= auto_enrollment_check_screen_handler
;
279 AddScreenHandler(auto_enrollment_check_screen_handler
);
281 HIDDetectionScreenHandler
* hid_detection_screen_handler
=
282 new HIDDetectionScreenHandler(core_handler_
);
283 hid_detection_view_
= hid_detection_screen_handler
;
284 AddScreenHandler(hid_detection_screen_handler
);
286 error_screen_handler_
= new ErrorScreenHandler();
287 AddScreenHandler(error_screen_handler_
);
288 network_dropdown_handler_
->AddObserver(error_screen_handler_
);
290 error_screen_
.reset(new ErrorScreen(nullptr, error_screen_handler_
));
291 NetworkErrorModel
* network_error_model
= error_screen_
.get();
293 EnrollmentScreenHandler
* enrollment_screen_handler
=
294 new EnrollmentScreenHandler(network_state_informer_
, network_error_model
);
295 enrollment_screen_actor_
= enrollment_screen_handler
;
296 AddScreenHandler(enrollment_screen_handler
);
298 TermsOfServiceScreenHandler
* terms_of_service_screen_handler
=
299 new TermsOfServiceScreenHandler(core_handler_
);
300 terms_of_service_screen_actor_
= terms_of_service_screen_handler
;
301 AddScreenHandler(terms_of_service_screen_handler
);
303 UserImageScreenHandler
* user_image_screen_handler
=
304 new UserImageScreenHandler();
305 user_image_view_
= user_image_screen_handler
;
306 AddScreenHandler(user_image_screen_handler
);
308 policy::ConsumerManagementService
* consumer_management
=
309 g_browser_process
->platform_part()->browser_policy_connector_chromeos()->
310 GetConsumerManagementService();
312 user_board_screen_handler_
= new UserBoardScreenHandler();
313 AddScreenHandler(user_board_screen_handler_
);
315 gaia_screen_handler_
=
316 new GaiaScreenHandler(
317 core_handler_
, network_state_informer_
, consumer_management
);
318 AddScreenHandler(gaia_screen_handler_
);
320 signin_screen_handler_
=
321 new SigninScreenHandler(network_state_informer_
, network_error_model
,
322 core_handler_
, gaia_screen_handler_
);
323 AddScreenHandler(signin_screen_handler_
);
325 AppLaunchSplashScreenHandler
* app_launch_splash_screen_handler
=
326 new AppLaunchSplashScreenHandler(network_state_informer_
,
327 network_error_model
);
328 AddScreenHandler(app_launch_splash_screen_handler
);
329 app_launch_splash_screen_actor_
= app_launch_splash_screen_handler
;
331 if (display_type_
== kOobeDisplay
) {
332 ControllerPairingScreenHandler
* handler
=
333 new ControllerPairingScreenHandler();
334 controller_pairing_screen_actor_
= handler
;
335 AddScreenHandler(handler
);
338 if (display_type_
== kOobeDisplay
) {
339 HostPairingScreenHandler
* handler
= new HostPairingScreenHandler();
340 host_pairing_screen_actor_
= handler
;
341 AddScreenHandler(handler
);
344 DeviceDisabledScreenHandler
* device_disabled_screen_handler
=
345 new DeviceDisabledScreenHandler
;
346 device_disabled_screen_actor_
= device_disabled_screen_handler
;
347 AddScreenHandler(device_disabled_screen_handler
);
349 // Initialize KioskAppMenuHandler. Note that it is NOT a screen handler.
350 kiosk_app_menu_handler_
= new KioskAppMenuHandler(network_state_informer_
);
351 web_ui
->AddMessageHandler(kiosk_app_menu_handler_
);
353 base::DictionaryValue localized_strings
;
354 GetLocalizedStrings(&localized_strings
);
356 Profile
* profile
= Profile::FromWebUI(web_ui
);
357 // Set up the chrome://theme/ source, for Chrome logo.
358 ThemeSource
* theme
= new ThemeSource(profile
);
359 content::URLDataSource::Add(profile
, theme
);
361 // Set up the chrome://terms/ data source, for EULA content.
362 AboutUIHTMLSource
* about_source
=
363 new AboutUIHTMLSource(chrome::kChromeUITermsHost
, profile
);
364 content::URLDataSource::Add(profile
, about_source
);
366 // Set up the chrome://oobe/ source.
367 content::WebUIDataSource::Add(profile
,
368 CreateOobeUIDataSource(localized_strings
,
371 // Set up the chrome://userimage/ source.
372 options::UserImageSource
* user_image_source
=
373 new options::UserImageSource();
374 content::URLDataSource::Add(profile
, user_image_source
);
376 // TabHelper is required for OOBE webui to make webview working on it.
377 content::WebContents
* contents
= web_ui
->GetWebContents();
378 extensions::TabHelper::CreateForWebContents(contents
);
382 core_handler_
->SetDelegate(nullptr);
383 network_dropdown_handler_
->RemoveObserver(error_screen_handler_
);
386 CoreOobeActor
* OobeUI::GetCoreOobeActor() {
387 return core_handler_
;
390 NetworkView
* OobeUI::GetNetworkView() {
391 return network_view_
;
394 EulaView
* OobeUI::GetEulaView() {
398 UpdateView
* OobeUI::GetUpdateView() {
402 EnableDebuggingScreenActor
* OobeUI::GetEnableDebuggingScreenActor() {
403 return debugging_screen_actor_
;
406 EnrollmentScreenActor
* OobeUI::GetEnrollmentScreenActor() {
407 return enrollment_screen_actor_
;
410 ResetView
* OobeUI::GetResetView() {
414 KioskAutolaunchScreenActor
* OobeUI::GetKioskAutolaunchScreenActor() {
415 return autolaunch_screen_actor_
;
418 KioskEnableScreenActor
* OobeUI::GetKioskEnableScreenActor() {
419 return kiosk_enable_screen_actor_
;
422 TermsOfServiceScreenActor
* OobeUI::GetTermsOfServiceScreenActor() {
423 return terms_of_service_screen_actor_
;
426 WrongHWIDScreenActor
* OobeUI::GetWrongHWIDScreenActor() {
427 return wrong_hwid_screen_actor_
;
430 AutoEnrollmentCheckScreenActor
* OobeUI::GetAutoEnrollmentCheckScreenActor() {
431 return auto_enrollment_check_screen_actor_
;
434 HIDDetectionView
* OobeUI::GetHIDDetectionView() {
435 return hid_detection_view_
;
438 ControllerPairingScreenActor
* OobeUI::GetControllerPairingScreenActor() {
439 return controller_pairing_screen_actor_
;
442 HostPairingScreenActor
* OobeUI::GetHostPairingScreenActor() {
443 return host_pairing_screen_actor_
;
446 DeviceDisabledScreenActor
* OobeUI::GetDeviceDisabledScreenActor() {
447 return device_disabled_screen_actor_
;
450 UserImageView
* OobeUI::GetUserImageView() {
451 return user_image_view_
;
454 ErrorScreen
* OobeUI::GetErrorScreen() {
455 return error_screen_
.get();
458 SupervisedUserCreationScreenHandler
*
459 OobeUI::GetSupervisedUserCreationScreenActor() {
460 return supervised_user_creation_screen_actor_
;
463 GaiaScreenHandler
* OobeUI::GetGaiaScreenActor() {
464 return gaia_screen_handler_
;
467 UserBoardView
* OobeUI::GetUserBoardScreenActor() {
468 return user_board_screen_handler_
;
471 void OobeUI::OnShutdownPolicyChanged(bool reboot_on_shutdown
) {
472 core_handler_
->UpdateShutdownAndRebootVisibility(reboot_on_shutdown
);
475 AppLaunchSplashScreenActor
*
476 OobeUI::GetAppLaunchSplashScreenActor() {
477 return app_launch_splash_screen_actor_
;
480 void OobeUI::GetLocalizedStrings(base::DictionaryValue
* localized_strings
) {
481 // Note, handlers_[0] is a GenericHandler used by the WebUI.
482 for (size_t i
= 0; i
< handlers_
.size(); ++i
) {
483 handlers_
[i
]->GetLocalizedStrings(localized_strings
);
485 const std::string
& app_locale
= g_browser_process
->GetApplicationLocale();
486 webui::SetLoadTimeDataDefaults(app_locale
, localized_strings
);
487 kiosk_app_menu_handler_
->GetLocalizedStrings(localized_strings
);
489 #if defined(GOOGLE_CHROME_BUILD)
490 localized_strings
->SetString("buildType", "chrome");
492 localized_strings
->SetString("buildType", "chromium");
495 // If we're not doing boot animation then WebUI should trigger
496 // wallpaper load on boot.
497 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
498 switches::kDisableBootAnimation
)) {
499 localized_strings
->SetString("bootIntoWallpaper", "on");
501 localized_strings
->SetString("bootIntoWallpaper", "off");
504 bool keyboard_driven_oobe
=
505 system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation();
506 localized_strings
->SetString("highlightStrength",
507 keyboard_driven_oobe
? "strong" : "normal");
509 bool new_kiosk_ui
= KioskAppMenuHandler::EnableNewKioskUI();
510 localized_strings
->SetString("newKioskUI", new_kiosk_ui
? "on" : "off");
513 void OobeUI::InitializeScreenMaps() {
514 screen_names_
.resize(SCREEN_UNKNOWN
);
515 screen_names_
[SCREEN_OOBE_HID_DETECTION
] = kScreenOobeHIDDetection
;
516 screen_names_
[SCREEN_OOBE_NETWORK
] = kScreenOobeNetwork
;
517 screen_names_
[SCREEN_OOBE_EULA
] = kScreenOobeEula
;
518 screen_names_
[SCREEN_OOBE_UPDATE
] = kScreenOobeUpdate
;
519 screen_names_
[SCREEN_OOBE_ENROLLMENT
] = kScreenOobeEnrollment
;
520 screen_names_
[SCREEN_OOBE_ENABLE_DEBUGGING
] = kScreenOobeEnableDebugging
;
521 screen_names_
[SCREEN_OOBE_RESET
] = kScreenOobeReset
;
522 screen_names_
[SCREEN_GAIA_SIGNIN
] = kScreenGaiaSignin
;
523 screen_names_
[SCREEN_ACCOUNT_PICKER
] = kScreenAccountPicker
;
524 screen_names_
[SCREEN_KIOSK_AUTOLAUNCH
] = kScreenKioskAutolaunch
;
525 screen_names_
[SCREEN_KIOSK_ENABLE
] = kScreenKioskEnable
;
526 screen_names_
[SCREEN_ERROR_MESSAGE
] = kScreenErrorMessage
;
527 screen_names_
[SCREEN_USER_IMAGE_PICKER
] = kScreenUserImagePicker
;
528 screen_names_
[SCREEN_TPM_ERROR
] = kScreenTpmError
;
529 screen_names_
[SCREEN_PASSWORD_CHANGED
] = kScreenPasswordChanged
;
530 screen_names_
[SCREEN_CREATE_SUPERVISED_USER_FLOW
] =
531 kScreenSupervisedUserCreationFlow
;
532 screen_names_
[SCREEN_TERMS_OF_SERVICE
] = kScreenTermsOfService
;
533 screen_names_
[SCREEN_WRONG_HWID
] = kScreenWrongHWID
;
534 screen_names_
[SCREEN_AUTO_ENROLLMENT_CHECK
] = kScreenAutoEnrollmentCheck
;
535 screen_names_
[SCREEN_APP_LAUNCH_SPLASH
] = kScreenAppLaunchSplash
;
536 screen_names_
[SCREEN_CONFIRM_PASSWORD
] = kScreenConfirmPassword
;
537 screen_names_
[SCREEN_FATAL_ERROR
] = kScreenFatalError
;
538 screen_names_
[SCREEN_OOBE_CONTROLLER_PAIRING
] = kScreenControllerPairing
;
539 screen_names_
[SCREEN_OOBE_HOST_PAIRING
] = kScreenHostPairing
;
540 screen_names_
[SCREEN_DEVICE_DISABLED
] = kScreenDeviceDisabled
;
543 for (size_t i
= 0; i
< screen_names_
.size(); ++i
)
544 screen_ids_
[screen_names_
[i
]] = static_cast<Screen
>(i
);
547 void OobeUI::AddScreenHandler(BaseScreenHandler
* handler
) {
548 web_ui()->AddMessageHandler(handler
);
549 handlers_
.push_back(handler
);
552 void OobeUI::InitializeHandlers() {
554 for (size_t i
= 0; i
< ready_callbacks_
.size(); ++i
)
555 ready_callbacks_
[i
].Run();
556 ready_callbacks_
.clear();
558 // Notify 'initialize' for synchronously loaded screens.
559 for (size_t i
= 0; i
< handlers_
.size(); ++i
) {
560 if (handlers_
[i
]->async_assets_load_id().empty())
561 handlers_
[i
]->InitializeBase();
564 // Instantiate the ShutdownPolicyHandler.
565 shutdown_policy_handler_
.reset(
566 new ShutdownPolicyHandler(CrosSettings::Get(), this));
568 // Trigger an initial update.
569 shutdown_policy_handler_
->CheckIfRebootOnShutdown(
570 base::Bind(&OobeUI::OnShutdownPolicyChanged
, base::Unretained(this)));
573 void OobeUI::OnScreenAssetsLoaded(const std::string
& async_assets_load_id
) {
574 DCHECK(!async_assets_load_id
.empty());
576 for (size_t i
= 0; i
< handlers_
.size(); ++i
) {
577 if (handlers_
[i
]->async_assets_load_id() == async_assets_load_id
)
578 handlers_
[i
]->InitializeBase();
582 bool OobeUI::IsJSReady(const base::Closure
& display_is_ready_callback
) {
584 ready_callbacks_
.push_back(display_is_ready_callback
);
588 void OobeUI::ShowOobeUI(bool show
) {
589 core_handler_
->ShowOobeUI(show
);
592 void OobeUI::ShowSigninScreen(const LoginScreenContext
& context
,
593 SigninScreenHandlerDelegate
* delegate
,
594 NativeWindowDelegate
* native_window_delegate
) {
595 // Check our device mode.
596 policy::BrowserPolicyConnectorChromeOS
* connector
=
597 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
598 if (connector
->GetDeviceMode() == policy::DEVICE_MODE_LEGACY_RETAIL_MODE
) {
599 // If we're in legacy retail mode, the best thing we can do is launch the
600 // new offline demo mode.
601 LoginDisplayHost
* host
= LoginDisplayHostImpl::default_host();
602 host
->StartDemoAppLaunch();
606 signin_screen_handler_
->SetDelegate(delegate
);
607 signin_screen_handler_
->SetNativeWindowDelegate(native_window_delegate
);
609 LoginScreenContext
actual_context(context
);
610 actual_context
.set_oobe_ui(core_handler_
->show_oobe_ui());
611 signin_screen_handler_
->Show(actual_context
);
614 void OobeUI::ResetSigninScreenHandlerDelegate() {
615 signin_screen_handler_
->SetDelegate(nullptr);
616 signin_screen_handler_
->SetNativeWindowDelegate(nullptr);
620 void OobeUI::AddObserver(Observer
* observer
) {
621 observer_list_
.AddObserver(observer
);
624 void OobeUI::RemoveObserver(Observer
* observer
) {
625 observer_list_
.RemoveObserver(observer
);
628 const std::string
& OobeUI::GetScreenName(Screen screen
) const {
629 DCHECK(screen
>= 0 && screen
< SCREEN_UNKNOWN
);
630 return screen_names_
[static_cast<size_t>(screen
)];
633 void OobeUI::OnCurrentScreenChanged(const std::string
& screen
) {
634 previous_screen_
= current_screen_
;
635 DCHECK(screen_ids_
.count(screen
))
636 << "Screen should be registered in InitializeScreenMaps()";
637 Screen new_screen
= screen_ids_
[screen
];
638 FOR_EACH_OBSERVER(Observer
,
640 OnCurrentScreenChanged(current_screen_
, new_screen
));
641 current_screen_
= new_screen
;
644 } // namespace chromeos