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
,
78 OobeUI::kNewOobeDisplay
81 const char kStringsJSPath
[] = "strings.js";
82 const char kLoginJSPath
[] = "login.js";
83 const char kOobeJSPath
[] = "oobe.js";
84 const char kKeyboardUtilsJSPath
[] = "keyboard_utils.js";
85 const char kCustomElementsHTMLPath
[] = "custom_elements.html";
86 const char kCustomElementsJSPath
[] = "custom_elements.js";
88 // Paths for deferred resource loading.
89 const char kEnrollmentHTMLPath
[] = "enrollment.html";
90 const char kEnrollmentCSSPath
[] = "enrollment.css";
91 const char kEnrollmentJSPath
[] = "enrollment.js";
93 content::WebUIDataSource
* CreateNewOobeUIDataSource(
94 const base::DictionaryValue
& localized_strings
) {
95 content::WebUIDataSource
* source
=
96 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost
);
97 source
->AddLocalizedStrings(localized_strings
);
98 source
->SetJsonPath(kStringsJSPath
);
99 source
->SetDefaultResource(IDR_NEW_OOBE_HTML
);
100 source
->AddResourcePath(kOobeJSPath
, IDR_NEW_OOBE_JS
);
104 // Creates a WebUIDataSource for chrome://oobe
105 content::WebUIDataSource
* CreateOobeUIDataSource(
106 const base::DictionaryValue
& localized_strings
,
107 const std::string
& display_type
) {
108 if (display_type
== OobeUI::kNewOobeDisplay
) {
109 return CreateNewOobeUIDataSource(localized_strings
);
111 content::WebUIDataSource
* source
=
112 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost
);
113 source
->AddLocalizedStrings(localized_strings
);
114 source
->SetJsonPath(kStringsJSPath
);
116 if (display_type
== OobeUI::kOobeDisplay
) {
117 source
->SetDefaultResource(IDR_OOBE_HTML
);
118 source
->AddResourcePath(kOobeJSPath
, IDR_OOBE_JS
);
120 source
->SetDefaultResource(IDR_LOGIN_HTML
);
121 source
->AddResourcePath(kLoginJSPath
, IDR_LOGIN_JS
);
123 source
->AddResourcePath(kKeyboardUtilsJSPath
, IDR_KEYBOARD_UTILS_JS
);
124 source
->OverrideContentSecurityPolicyFrameSrc(
126 "frame-src chrome://terms/ %s/;",
127 extensions::kGaiaAuthExtensionOrigin
));
128 source
->OverrideContentSecurityPolicyObjectSrc("object-src *;");
129 bool is_webview_signin_enabled
= StartupUtils::IsWebviewSigninEnabled();
130 source
->AddResourcePath("gaia_auth_host.js", is_webview_signin_enabled
?
131 IDR_GAIA_AUTH_AUTHENTICATOR_JS
: IDR_GAIA_AUTH_HOST_JS
);
133 // Serve deferred resources.
134 source
->AddResourcePath(kEnrollmentHTMLPath
, IDR_OOBE_ENROLLMENT_HTML
);
135 source
->AddResourcePath(kEnrollmentCSSPath
, IDR_OOBE_ENROLLMENT_CSS
);
136 source
->AddResourcePath(kEnrollmentJSPath
, IDR_OOBE_ENROLLMENT_JS
);
138 if (display_type
== OobeUI::kOobeDisplay
) {
139 source
->AddResourcePath(kCustomElementsHTMLPath
, IDR_CUSTOM_ELEMENTS_HTML
);
140 source
->AddResourcePath(kCustomElementsJSPath
, IDR_CUSTOM_ELEMENTS_JS
);
142 source
->AddResourcePath("Roboto-Thin.ttf", IDR_FONT_ROBOTO_THIN
);
143 source
->AddResourcePath("Roboto-Light.ttf", IDR_FONT_ROBOTO_LIGHT
);
144 source
->AddResourcePath("Roboto-Regular.ttf", IDR_FONT_ROBOTO_REGULAR
);
145 source
->AddResourcePath("Roboto-Medium.ttf", IDR_FONT_ROBOTO_MEDIUM
);
146 source
->AddResourcePath("Roboto-Bold.ttf", IDR_FONT_ROBOTO_BOLD
);
152 std::string
GetDisplayType(const GURL
& url
) {
153 std::string path
= url
.path().size() ? url
.path().substr(1) : "";
154 if (std::find(kKnownDisplayTypes
,
155 kKnownDisplayTypes
+ arraysize(kKnownDisplayTypes
),
156 path
) == kKnownDisplayTypes
+ arraysize(kKnownDisplayTypes
)) {
157 LOG(ERROR
) << "Unknown display type '" << path
<< "'. Setting default.";
158 return OobeUI::kLoginDisplay
;
166 const char OobeUI::kOobeDisplay
[] = "oobe";
167 const char OobeUI::kLoginDisplay
[] = "login";
168 const char OobeUI::kLockDisplay
[] = "lock";
169 const char OobeUI::kUserAddingDisplay
[] = "user-adding";
170 const char OobeUI::kAppLaunchSplashDisplay
[] = "app-launch-splash";
171 const char OobeUI::kNewOobeDisplay
[] = "new-oobe";
174 const char OobeUI::kScreenOobeHIDDetection
[] = "hid-detection";
175 const char OobeUI::kScreenOobeNetwork
[] = "connect";
176 const char OobeUI::kScreenOobeEnableDebugging
[] = "debugging";
177 const char OobeUI::kScreenOobeEula
[] = "eula";
178 const char OobeUI::kScreenOobeUpdate
[] = "update";
179 const char OobeUI::kScreenOobeEnrollment
[] = "oauth-enrollment";
180 const char OobeUI::kScreenOobeReset
[] = "reset";
181 const char OobeUI::kScreenGaiaSignin
[] = "gaia-signin";
182 const char OobeUI::kScreenAccountPicker
[] = "account-picker";
183 const char OobeUI::kScreenKioskAutolaunch
[] = "autolaunch";
184 const char OobeUI::kScreenKioskEnable
[] = "kiosk-enable";
185 const char OobeUI::kScreenErrorMessage
[] = "error-message";
186 const char OobeUI::kScreenUserImagePicker
[] = "user-image";
187 const char OobeUI::kScreenTpmError
[] = "tpm-error-message";
188 const char OobeUI::kScreenPasswordChanged
[] = "password-changed";
189 const char OobeUI::kScreenSupervisedUserCreationFlow
[] =
190 "supervised-user-creation";
191 const char OobeUI::kScreenTermsOfService
[] = "terms-of-service";
192 const char OobeUI::kScreenWrongHWID
[] = "wrong-hwid";
193 const char OobeUI::kScreenAutoEnrollmentCheck
[] = "auto-enrollment-check";
194 const char OobeUI::kScreenHIDDetection
[] = "hid-detection";
195 const char OobeUI::kScreenAppLaunchSplash
[] = "app-launch-splash";
196 const char OobeUI::kScreenConfirmPassword
[] = "confirm-password";
197 const char OobeUI::kScreenFatalError
[] = "fatal-error";
198 const char OobeUI::kScreenControllerPairing
[] = "controller-pairing";
199 const char OobeUI::kScreenHostPairing
[] = "host-pairing";
200 const char OobeUI::kScreenDeviceDisabled
[] = "device-disabled";
202 OobeUI::OobeUI(content::WebUI
* web_ui
, const GURL
& url
)
203 : WebUIController(web_ui
),
204 core_handler_(nullptr),
205 network_dropdown_handler_(nullptr),
206 update_screen_handler_(nullptr),
207 network_view_(nullptr),
208 debugging_screen_actor_(nullptr),
210 reset_view_(nullptr),
211 hid_detection_view_(nullptr),
212 autolaunch_screen_actor_(nullptr),
213 kiosk_enable_screen_actor_(nullptr),
214 wrong_hwid_screen_actor_(nullptr),
215 auto_enrollment_check_screen_actor_(nullptr),
216 supervised_user_creation_screen_actor_(nullptr),
217 app_launch_splash_screen_actor_(nullptr),
218 controller_pairing_screen_actor_(nullptr),
219 host_pairing_screen_actor_(nullptr),
220 device_disabled_screen_actor_(nullptr),
221 error_screen_handler_(nullptr),
222 signin_screen_handler_(nullptr),
223 terms_of_service_screen_actor_(nullptr),
224 user_image_view_(nullptr),
225 kiosk_app_menu_handler_(nullptr),
226 current_screen_(SCREEN_UNKNOWN
),
227 previous_screen_(SCREEN_UNKNOWN
),
229 display_type_
= GetDisplayType(url
);
230 InitializeScreenMaps();
232 network_state_informer_
= new NetworkStateInformer();
233 network_state_informer_
->Init();
235 core_handler_
= new CoreOobeHandler(this);
236 AddScreenHandler(core_handler_
);
237 core_handler_
->SetDelegate(this);
239 network_dropdown_handler_
= new NetworkDropdownHandler();
240 AddScreenHandler(network_dropdown_handler_
);
242 update_screen_handler_
= new UpdateScreenHandler();
243 AddScreenHandler(update_screen_handler_
);
244 network_dropdown_handler_
->AddObserver(update_screen_handler_
);
246 if (display_type_
== kOobeDisplay
|| display_type_
== kNewOobeDisplay
) {
247 NetworkScreenHandler
* network_screen_handler
=
248 new NetworkScreenHandler(core_handler_
);
249 network_view_
= network_screen_handler
;
250 AddScreenHandler(network_screen_handler
);
253 EnableDebuggingScreenHandler
* debugging_screen_handler
=
254 new EnableDebuggingScreenHandler();
255 debugging_screen_actor_
= debugging_screen_handler
;
256 AddScreenHandler(debugging_screen_handler
);
258 EulaScreenHandler
* eula_screen_handler
= new EulaScreenHandler(core_handler_
);
259 eula_view_
= eula_screen_handler
;
260 AddScreenHandler(eula_screen_handler
);
262 ResetScreenHandler
* reset_screen_handler
= new ResetScreenHandler();
263 reset_view_
= reset_screen_handler
;
264 AddScreenHandler(reset_screen_handler
);
266 KioskAutolaunchScreenHandler
* autolaunch_screen_handler
=
267 new KioskAutolaunchScreenHandler();
268 autolaunch_screen_actor_
= autolaunch_screen_handler
;
269 AddScreenHandler(autolaunch_screen_handler
);
271 KioskEnableScreenHandler
* kiosk_enable_screen_handler
=
272 new KioskEnableScreenHandler();
273 kiosk_enable_screen_actor_
= kiosk_enable_screen_handler
;
274 AddScreenHandler(kiosk_enable_screen_handler
);
276 SupervisedUserCreationScreenHandler
* supervised_user_creation_screen_handler
=
277 new SupervisedUserCreationScreenHandler();
278 supervised_user_creation_screen_actor_
=
279 supervised_user_creation_screen_handler
;
280 AddScreenHandler(supervised_user_creation_screen_handler
);
282 WrongHWIDScreenHandler
* wrong_hwid_screen_handler
=
283 new WrongHWIDScreenHandler();
284 wrong_hwid_screen_actor_
= wrong_hwid_screen_handler
;
285 AddScreenHandler(wrong_hwid_screen_handler
);
287 AutoEnrollmentCheckScreenHandler
* auto_enrollment_check_screen_handler
=
288 new AutoEnrollmentCheckScreenHandler();
289 auto_enrollment_check_screen_actor_
= auto_enrollment_check_screen_handler
;
290 AddScreenHandler(auto_enrollment_check_screen_handler
);
292 HIDDetectionScreenHandler
* hid_detection_screen_handler
=
293 new HIDDetectionScreenHandler(core_handler_
);
294 hid_detection_view_
= hid_detection_screen_handler
;
295 AddScreenHandler(hid_detection_screen_handler
);
297 error_screen_handler_
= new ErrorScreenHandler();
298 AddScreenHandler(error_screen_handler_
);
300 // Initialize ErrorScreen if it hasn't initialized so that NetworkErrorModel
301 // is binded properly.
302 NetworkErrorModel
* network_error_model
= nullptr;
303 if (WizardController::default_controller()) {
304 network_error_model
= static_cast<NetworkErrorModel
*>(
305 WizardController::default_controller()->GetScreen(
306 WizardController::kErrorScreenName
));
307 CHECK(network_error_model
);
309 error_screen_
.reset(new ErrorScreen(nullptr, error_screen_handler_
));
310 network_error_model
= error_screen_
.get();
313 EnrollmentScreenHandler
* enrollment_screen_handler
=
314 new EnrollmentScreenHandler(network_state_informer_
, network_error_model
);
315 enrollment_screen_actor_
= enrollment_screen_handler
;
316 AddScreenHandler(enrollment_screen_handler
);
318 TermsOfServiceScreenHandler
* terms_of_service_screen_handler
=
319 new TermsOfServiceScreenHandler(core_handler_
);
320 terms_of_service_screen_actor_
= terms_of_service_screen_handler
;
321 AddScreenHandler(terms_of_service_screen_handler
);
323 UserImageScreenHandler
* user_image_screen_handler
=
324 new UserImageScreenHandler();
325 user_image_view_
= user_image_screen_handler
;
326 AddScreenHandler(user_image_screen_handler
);
328 policy::ConsumerManagementService
* consumer_management
=
329 g_browser_process
->platform_part()->browser_policy_connector_chromeos()->
330 GetConsumerManagementService();
332 user_board_screen_handler_
= new UserBoardScreenHandler();
333 AddScreenHandler(user_board_screen_handler_
);
335 gaia_screen_handler_
=
336 new GaiaScreenHandler(
337 core_handler_
, network_state_informer_
, consumer_management
);
338 AddScreenHandler(gaia_screen_handler_
);
340 signin_screen_handler_
=
341 new SigninScreenHandler(network_state_informer_
, network_error_model
,
342 core_handler_
, gaia_screen_handler_
);
343 AddScreenHandler(signin_screen_handler_
);
345 AppLaunchSplashScreenHandler
* app_launch_splash_screen_handler
=
346 new AppLaunchSplashScreenHandler(network_state_informer_
,
347 network_error_model
);
348 AddScreenHandler(app_launch_splash_screen_handler
);
349 app_launch_splash_screen_actor_
= app_launch_splash_screen_handler
;
351 if (display_type_
== kOobeDisplay
) {
352 ControllerPairingScreenHandler
* handler
=
353 new ControllerPairingScreenHandler();
354 controller_pairing_screen_actor_
= handler
;
355 AddScreenHandler(handler
);
358 if (display_type_
== kOobeDisplay
) {
359 HostPairingScreenHandler
* handler
= new HostPairingScreenHandler();
360 host_pairing_screen_actor_
= handler
;
361 AddScreenHandler(handler
);
364 DeviceDisabledScreenHandler
* device_disabled_screen_handler
=
365 new DeviceDisabledScreenHandler
;
366 device_disabled_screen_actor_
= device_disabled_screen_handler
;
367 AddScreenHandler(device_disabled_screen_handler
);
369 // Initialize KioskAppMenuHandler. Note that it is NOT a screen handler.
370 kiosk_app_menu_handler_
= new KioskAppMenuHandler(network_state_informer_
);
371 web_ui
->AddMessageHandler(kiosk_app_menu_handler_
);
373 base::DictionaryValue localized_strings
;
374 GetLocalizedStrings(&localized_strings
);
376 Profile
* profile
= Profile::FromWebUI(web_ui
);
377 // Set up the chrome://theme/ source, for Chrome logo.
378 ThemeSource
* theme
= new ThemeSource(profile
);
379 content::URLDataSource::Add(profile
, theme
);
381 // Set up the chrome://terms/ data source, for EULA content.
382 AboutUIHTMLSource
* about_source
=
383 new AboutUIHTMLSource(chrome::kChromeUITermsHost
, profile
);
384 content::URLDataSource::Add(profile
, about_source
);
386 // Set up the chrome://oobe/ source.
387 content::WebUIDataSource::Add(profile
,
388 CreateOobeUIDataSource(localized_strings
,
391 // Set up the chrome://userimage/ source.
392 options::UserImageSource
* user_image_source
=
393 new options::UserImageSource();
394 content::URLDataSource::Add(profile
, user_image_source
);
396 // TabHelper is required for OOBE webui to make webview working on it.
397 content::WebContents
* contents
= web_ui
->GetWebContents();
398 extensions::TabHelper::CreateForWebContents(contents
);
402 core_handler_
->SetDelegate(nullptr);
403 network_dropdown_handler_
->RemoveObserver(update_screen_handler_
);
406 CoreOobeActor
* OobeUI::GetCoreOobeActor() {
407 return core_handler_
;
410 NetworkView
* OobeUI::GetNetworkView() {
411 return network_view_
;
414 EulaView
* OobeUI::GetEulaView() {
418 UpdateView
* OobeUI::GetUpdateView() {
419 return update_screen_handler_
;
422 EnableDebuggingScreenActor
* OobeUI::GetEnableDebuggingScreenActor() {
423 return debugging_screen_actor_
;
426 EnrollmentScreenActor
* OobeUI::GetEnrollmentScreenActor() {
427 return enrollment_screen_actor_
;
430 ResetView
* OobeUI::GetResetView() {
434 KioskAutolaunchScreenActor
* OobeUI::GetKioskAutolaunchScreenActor() {
435 return autolaunch_screen_actor_
;
438 KioskEnableScreenActor
* OobeUI::GetKioskEnableScreenActor() {
439 return kiosk_enable_screen_actor_
;
442 TermsOfServiceScreenActor
* OobeUI::GetTermsOfServiceScreenActor() {
443 return terms_of_service_screen_actor_
;
446 WrongHWIDScreenActor
* OobeUI::GetWrongHWIDScreenActor() {
447 return wrong_hwid_screen_actor_
;
450 AutoEnrollmentCheckScreenActor
* OobeUI::GetAutoEnrollmentCheckScreenActor() {
451 return auto_enrollment_check_screen_actor_
;
454 HIDDetectionView
* OobeUI::GetHIDDetectionView() {
455 return hid_detection_view_
;
458 ControllerPairingScreenActor
* OobeUI::GetControllerPairingScreenActor() {
459 return controller_pairing_screen_actor_
;
462 HostPairingScreenActor
* OobeUI::GetHostPairingScreenActor() {
463 return host_pairing_screen_actor_
;
466 DeviceDisabledScreenActor
* OobeUI::GetDeviceDisabledScreenActor() {
467 return device_disabled_screen_actor_
;
470 UserImageView
* OobeUI::GetUserImageView() {
471 return user_image_view_
;
474 NetworkErrorView
* OobeUI::GetNetworkErrorView() {
475 return error_screen_handler_
;
478 SupervisedUserCreationScreenHandler
*
479 OobeUI::GetSupervisedUserCreationScreenActor() {
480 return supervised_user_creation_screen_actor_
;
483 GaiaScreenHandler
* OobeUI::GetGaiaScreenActor() {
484 return gaia_screen_handler_
;
487 UserBoardView
* OobeUI::GetUserBoardScreenActor() {
488 return user_board_screen_handler_
;
491 void OobeUI::OnShutdownPolicyChanged(bool reboot_on_shutdown
) {
492 core_handler_
->UpdateShutdownAndRebootVisibility(reboot_on_shutdown
);
495 AppLaunchSplashScreenActor
*
496 OobeUI::GetAppLaunchSplashScreenActor() {
497 return app_launch_splash_screen_actor_
;
500 void OobeUI::GetLocalizedStrings(base::DictionaryValue
* localized_strings
) {
501 // Note, handlers_[0] is a GenericHandler used by the WebUI.
502 for (size_t i
= 0; i
< handlers_
.size(); ++i
) {
503 handlers_
[i
]->GetLocalizedStrings(localized_strings
);
505 const std::string
& app_locale
= g_browser_process
->GetApplicationLocale();
506 webui::SetLoadTimeDataDefaults(app_locale
, localized_strings
);
507 kiosk_app_menu_handler_
->GetLocalizedStrings(localized_strings
);
509 #if defined(GOOGLE_CHROME_BUILD)
510 localized_strings
->SetString("buildType", "chrome");
512 localized_strings
->SetString("buildType", "chromium");
515 // If we're not doing boot animation then WebUI should trigger
516 // wallpaper load on boot.
517 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
518 switches::kDisableBootAnimation
)) {
519 localized_strings
->SetString("bootIntoWallpaper", "on");
521 localized_strings
->SetString("bootIntoWallpaper", "off");
524 bool keyboard_driven_oobe
=
525 system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation();
526 localized_strings
->SetString("highlightStrength",
527 keyboard_driven_oobe
? "strong" : "normal");
529 bool new_kiosk_ui
= KioskAppMenuHandler::EnableNewKioskUI();
530 localized_strings
->SetString("newKioskUI", new_kiosk_ui
? "on" : "off");
533 void OobeUI::InitializeScreenMaps() {
534 screen_names_
.resize(SCREEN_UNKNOWN
);
535 screen_names_
[SCREEN_OOBE_HID_DETECTION
] = kScreenOobeHIDDetection
;
536 screen_names_
[SCREEN_OOBE_NETWORK
] = kScreenOobeNetwork
;
537 screen_names_
[SCREEN_OOBE_EULA
] = kScreenOobeEula
;
538 screen_names_
[SCREEN_OOBE_UPDATE
] = kScreenOobeUpdate
;
539 screen_names_
[SCREEN_OOBE_ENROLLMENT
] = kScreenOobeEnrollment
;
540 screen_names_
[SCREEN_OOBE_ENABLE_DEBUGGING
] = kScreenOobeEnableDebugging
;
541 screen_names_
[SCREEN_OOBE_RESET
] = kScreenOobeReset
;
542 screen_names_
[SCREEN_GAIA_SIGNIN
] = kScreenGaiaSignin
;
543 screen_names_
[SCREEN_ACCOUNT_PICKER
] = kScreenAccountPicker
;
544 screen_names_
[SCREEN_KIOSK_AUTOLAUNCH
] = kScreenKioskAutolaunch
;
545 screen_names_
[SCREEN_KIOSK_ENABLE
] = kScreenKioskEnable
;
546 screen_names_
[SCREEN_ERROR_MESSAGE
] = kScreenErrorMessage
;
547 screen_names_
[SCREEN_USER_IMAGE_PICKER
] = kScreenUserImagePicker
;
548 screen_names_
[SCREEN_TPM_ERROR
] = kScreenTpmError
;
549 screen_names_
[SCREEN_PASSWORD_CHANGED
] = kScreenPasswordChanged
;
550 screen_names_
[SCREEN_CREATE_SUPERVISED_USER_FLOW
] =
551 kScreenSupervisedUserCreationFlow
;
552 screen_names_
[SCREEN_TERMS_OF_SERVICE
] = kScreenTermsOfService
;
553 screen_names_
[SCREEN_WRONG_HWID
] = kScreenWrongHWID
;
554 screen_names_
[SCREEN_AUTO_ENROLLMENT_CHECK
] = kScreenAutoEnrollmentCheck
;
555 screen_names_
[SCREEN_APP_LAUNCH_SPLASH
] = kScreenAppLaunchSplash
;
556 screen_names_
[SCREEN_CONFIRM_PASSWORD
] = kScreenConfirmPassword
;
557 screen_names_
[SCREEN_FATAL_ERROR
] = kScreenFatalError
;
558 screen_names_
[SCREEN_OOBE_CONTROLLER_PAIRING
] = kScreenControllerPairing
;
559 screen_names_
[SCREEN_OOBE_HOST_PAIRING
] = kScreenHostPairing
;
560 screen_names_
[SCREEN_DEVICE_DISABLED
] = kScreenDeviceDisabled
;
563 for (size_t i
= 0; i
< screen_names_
.size(); ++i
)
564 screen_ids_
[screen_names_
[i
]] = static_cast<Screen
>(i
);
567 void OobeUI::AddScreenHandler(BaseScreenHandler
* handler
) {
568 web_ui()->AddMessageHandler(handler
);
569 handlers_
.push_back(handler
);
572 void OobeUI::InitializeHandlers() {
574 for (size_t i
= 0; i
< ready_callbacks_
.size(); ++i
)
575 ready_callbacks_
[i
].Run();
576 ready_callbacks_
.clear();
578 // Notify 'initialize' for synchronously loaded screens.
579 for (size_t i
= 0; i
< handlers_
.size(); ++i
) {
580 if (handlers_
[i
]->async_assets_load_id().empty())
581 handlers_
[i
]->InitializeBase();
584 // Instantiate the ShutdownPolicyHandler.
585 shutdown_policy_handler_
.reset(
586 new ShutdownPolicyHandler(CrosSettings::Get(), this));
588 // Trigger an initial update.
589 shutdown_policy_handler_
->CheckIfRebootOnShutdown(
590 base::Bind(&OobeUI::OnShutdownPolicyChanged
, base::Unretained(this)));
593 void OobeUI::OnScreenAssetsLoaded(const std::string
& async_assets_load_id
) {
594 DCHECK(!async_assets_load_id
.empty());
596 for (size_t i
= 0; i
< handlers_
.size(); ++i
) {
597 if (handlers_
[i
]->async_assets_load_id() == async_assets_load_id
)
598 handlers_
[i
]->InitializeBase();
602 bool OobeUI::IsJSReady(const base::Closure
& display_is_ready_callback
) {
604 ready_callbacks_
.push_back(display_is_ready_callback
);
608 void OobeUI::ShowOobeUI(bool show
) {
609 core_handler_
->ShowOobeUI(show
);
612 void OobeUI::ShowSigninScreen(const LoginScreenContext
& context
,
613 SigninScreenHandlerDelegate
* delegate
,
614 NativeWindowDelegate
* native_window_delegate
) {
615 // Check our device mode.
616 policy::BrowserPolicyConnectorChromeOS
* connector
=
617 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
618 if (connector
->GetDeviceMode() == policy::DEVICE_MODE_LEGACY_RETAIL_MODE
) {
619 // If we're in legacy retail mode, the best thing we can do is launch the
620 // new offline demo mode.
621 LoginDisplayHost
* host
= LoginDisplayHostImpl::default_host();
622 host
->StartDemoAppLaunch();
626 signin_screen_handler_
->SetDelegate(delegate
);
627 signin_screen_handler_
->SetNativeWindowDelegate(native_window_delegate
);
629 LoginScreenContext
actual_context(context
);
630 actual_context
.set_oobe_ui(core_handler_
->show_oobe_ui());
631 signin_screen_handler_
->Show(actual_context
);
634 void OobeUI::ResetSigninScreenHandlerDelegate() {
635 signin_screen_handler_
->SetDelegate(nullptr);
636 signin_screen_handler_
->SetNativeWindowDelegate(nullptr);
640 void OobeUI::AddObserver(Observer
* observer
) {
641 observer_list_
.AddObserver(observer
);
644 void OobeUI::RemoveObserver(Observer
* observer
) {
645 observer_list_
.RemoveObserver(observer
);
648 const std::string
& OobeUI::GetScreenName(Screen screen
) const {
649 DCHECK(screen
>= 0 && screen
< SCREEN_UNKNOWN
);
650 return screen_names_
[static_cast<size_t>(screen
)];
653 void OobeUI::OnCurrentScreenChanged(const std::string
& screen
) {
654 previous_screen_
= current_screen_
;
655 DCHECK(screen_ids_
.count(screen
))
656 << "Screen should be registered in InitializeScreenMaps()";
657 Screen new_screen
= screen_ids_
[screen
];
658 FOR_EACH_OBSERVER(Observer
,
660 OnCurrentScreenChanged(current_screen_
, new_screen
));
661 current_screen_
= new_screen
;
664 } // namespace chromeos