Home | History | Annotate | Download | only in login
      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.
      4 
      5 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
      6 
      7 #include "ash/ash_switches.h"
      8 #include "base/command_line.h"
      9 #include "base/logging.h"
     10 #include "base/memory/ref_counted_memory.h"
     11 #include "base/values.h"
     12 #include "chrome/browser/browser_about_handler.h"
     13 #include "chrome/browser/chrome_notification_types.h"
     14 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
     15 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_actor.h"
     16 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h"
     17 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
     18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
     19 #include "chrome/browser/chromeos/login/users/user_manager.h"
     20 #include "chrome/browser/chromeos/login/wizard_controller.h"
     21 #include "chrome/browser/chromeos/system/input_device_settings.h"
     22 #include "chrome/browser/profiles/profile.h"
     23 #include "chrome/browser/ui/webui/about_ui.h"
     24 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
     25 #include "chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h"
     26 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
     27 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
     28 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
     29 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
     30 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
     31 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
     32 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
     33 #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h"
     34 #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h"
     35 #include "chrome/browser/ui/webui/chromeos/login/locally_managed_user_creation_screen_handler.h"
     36 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h"
     37 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
     38 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
     39 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
     40 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
     41 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h"
     42 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
     43 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
     44 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h"
     45 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
     46 #include "chrome/browser/ui/webui/theme_source.h"
     47 #include "chrome/common/chrome_constants.h"
     48 #include "chrome/common/url_constants.h"
     49 #include "chromeos/chromeos_constants.h"
     50 #include "chromeos/chromeos_switches.h"
     51 #include "content/public/browser/web_ui.h"
     52 #include "content/public/browser/web_ui_data_source.h"
     53 #include "grit/browser_resources.h"
     54 #include "ui/base/resource/resource_bundle.h"
     55 #include "ui/base/webui/web_ui_util.h"
     56 
     57 namespace chromeos {
     58 
     59 namespace {
     60 
     61 const char* kKnownDisplayTypes[] = {
     62   OobeUI::kOobeDisplay,
     63   OobeUI::kLoginDisplay,
     64   OobeUI::kLockDisplay,
     65   OobeUI::kUserAddingDisplay,
     66   OobeUI::kAppLaunchSplashDisplay
     67 };
     68 
     69 const char kStringsJSPath[] = "strings.js";
     70 const char kLoginJSPath[] = "login.js";
     71 const char kOobeJSPath[] = "oobe.js";
     72 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js";
     73 const char kDemoUserLoginJSPath[] = "demo_user_login.js";
     74 
     75 // Paths for deferred resource loading.
     76 const char kEnrollmentHTMLPath[] = "enrollment.html";
     77 const char kEnrollmentCSSPath[] = "enrollment.css";
     78 const char kEnrollmentJSPath[] = "enrollment.js";
     79 
     80 // Creates a WebUIDataSource for chrome://oobe
     81 content::WebUIDataSource* CreateOobeUIDataSource(
     82     const base::DictionaryValue& localized_strings,
     83     const std::string& display_type) {
     84   content::WebUIDataSource* source =
     85       content::WebUIDataSource::Create(chrome::kChromeUIOobeHost);
     86   source->SetUseJsonJSFormatV2();
     87   source->AddLocalizedStrings(localized_strings);
     88   source->SetJsonPath(kStringsJSPath);
     89 
     90   if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) {
     91     source->SetDefaultResource(IDR_DEMO_USER_LOGIN_HTML);
     92     source->AddResourcePath(kDemoUserLoginJSPath, IDR_DEMO_USER_LOGIN_JS);
     93     return source;
     94   }
     95   if (display_type == OobeUI::kOobeDisplay) {
     96     source->SetDefaultResource(IDR_OOBE_HTML);
     97     source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS);
     98   } else {
     99     source->SetDefaultResource(IDR_LOGIN_HTML);
    100     source->AddResourcePath(kLoginJSPath, IDR_LOGIN_JS);
    101   }
    102   source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
    103   source->OverrideContentSecurityPolicyFrameSrc(
    104       "frame-src chrome://terms/ "
    105       "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/;");
    106 
    107   // Serve deferred resources.
    108   source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML);
    109   source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS);
    110   source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS);
    111 
    112   return source;
    113 }
    114 
    115 std::string GetDisplayType(const GURL& url) {
    116   std::string path = url.path().size() ? url.path().substr(1) : "";
    117   if (std::find(kKnownDisplayTypes,
    118                 kKnownDisplayTypes + arraysize(kKnownDisplayTypes),
    119                 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) {
    120     LOG(ERROR) << "Unknown display type '" << path << "'. Setting default.";
    121     return OobeUI::kLoginDisplay;
    122   }
    123   return path;
    124 }
    125 
    126 }  // namespace
    127 
    128 // static
    129 const char OobeUI::kOobeDisplay[] = "oobe";
    130 const char OobeUI::kLoginDisplay[] = "login";
    131 const char OobeUI::kLockDisplay[] = "lock";
    132 const char OobeUI::kUserAddingDisplay[] = "user-adding";
    133 const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash";
    134 
    135 // static
    136 const char OobeUI::kScreenOobeHIDDetection[] = "hid-detection";
    137 const char OobeUI::kScreenOobeNetwork[]      = "connect";
    138 const char OobeUI::kScreenOobeEula[]         = "eula";
    139 const char OobeUI::kScreenOobeUpdate[]       = "update";
    140 const char OobeUI::kScreenOobeEnrollment[]   = "oauth-enrollment";
    141 const char OobeUI::kScreenOobeReset[]        = "reset";
    142 const char OobeUI::kScreenGaiaSignin[]       = "gaia-signin";
    143 const char OobeUI::kScreenAccountPicker[]    = "account-picker";
    144 const char OobeUI::kScreenKioskAutolaunch[]  = "autolaunch";
    145 const char OobeUI::kScreenKioskEnable[]      = "kiosk-enable";
    146 const char OobeUI::kScreenErrorMessage[]     = "error-message";
    147 const char OobeUI::kScreenUserImagePicker[]  = "user-image";
    148 const char OobeUI::kScreenTpmError[]         = "tpm-error-message";
    149 const char OobeUI::kScreenPasswordChanged[]  = "password-changed";
    150 const char OobeUI::kScreenManagedUserCreationFlow[]
    151                                              = "managed-user-creation";
    152 const char OobeUI::kScreenTermsOfService[]   = "terms-of-service";
    153 const char OobeUI::kScreenWrongHWID[]        = "wrong-hwid";
    154 const char OobeUI::kScreenAutoEnrollmentCheck[]
    155                                              = "auto-enrollment-check";
    156 const char OobeUI::kScreenHIDDetection[]     = "hid-detection";
    157 const char OobeUI::kScreenAppLaunchSplash[]  = "app-launch-splash";
    158 const char OobeUI::kScreenConfirmPassword[]  = "confirm-password";
    159 const char OobeUI::kScreenFatalError[]       = "fatal-error";
    160 
    161 OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
    162     : WebUIController(web_ui),
    163       core_handler_(NULL),
    164       network_dropdown_handler_(NULL),
    165       update_screen_handler_(NULL),
    166       network_screen_actor_(NULL),
    167       eula_screen_actor_(NULL),
    168       hid_detection_screen_actor_(NULL),
    169       reset_screen_actor_(NULL),
    170       autolaunch_screen_actor_(NULL),
    171       kiosk_enable_screen_actor_(NULL),
    172       wrong_hwid_screen_actor_(NULL),
    173       auto_enrollment_check_screen_actor_(NULL),
    174       locally_managed_user_creation_screen_actor_(NULL),
    175       error_screen_handler_(NULL),
    176       signin_screen_handler_(NULL),
    177       terms_of_service_screen_actor_(NULL),
    178       user_image_screen_actor_(NULL),
    179       kiosk_app_menu_handler_(NULL),
    180       current_screen_(SCREEN_UNKNOWN),
    181       previous_screen_(SCREEN_UNKNOWN),
    182       ready_(false) {
    183   display_type_ = GetDisplayType(url);
    184   InitializeScreenMaps();
    185 
    186   network_state_informer_ = new NetworkStateInformer();
    187   network_state_informer_->Init();
    188 
    189   core_handler_ = new CoreOobeHandler(this);
    190   AddScreenHandler(core_handler_);
    191   core_handler_->SetDelegate(this);
    192 
    193   network_dropdown_handler_ = new NetworkDropdownHandler();
    194   AddScreenHandler(network_dropdown_handler_);
    195 
    196   update_screen_handler_ = new UpdateScreenHandler();
    197   AddScreenHandler(update_screen_handler_);
    198   network_dropdown_handler_->AddObserver(update_screen_handler_);
    199 
    200   if (display_type_ == kOobeDisplay) {
    201     NetworkScreenHandler* network_screen_handler =
    202         new NetworkScreenHandler(core_handler_);
    203     network_screen_actor_ = network_screen_handler;
    204     AddScreenHandler(network_screen_handler);
    205   }
    206 
    207   EulaScreenHandler* eula_screen_handler = new EulaScreenHandler(core_handler_);
    208   eula_screen_actor_ = eula_screen_handler;
    209   AddScreenHandler(eula_screen_handler);
    210 
    211   ResetScreenHandler* reset_screen_handler = new ResetScreenHandler();
    212   reset_screen_actor_ = reset_screen_handler;
    213   AddScreenHandler(reset_screen_handler);
    214 
    215   KioskAutolaunchScreenHandler* autolaunch_screen_handler =
    216       new KioskAutolaunchScreenHandler();
    217   autolaunch_screen_actor_ = autolaunch_screen_handler;
    218   AddScreenHandler(autolaunch_screen_handler);
    219 
    220   KioskEnableScreenHandler* kiosk_enable_screen_handler =
    221       new KioskEnableScreenHandler();
    222   kiosk_enable_screen_actor_ = kiosk_enable_screen_handler;
    223   AddScreenHandler(kiosk_enable_screen_handler);
    224 
    225   LocallyManagedUserCreationScreenHandler*
    226       locally_managed_user_creation_screen_handler =
    227           new LocallyManagedUserCreationScreenHandler();
    228   locally_managed_user_creation_screen_actor_ =
    229       locally_managed_user_creation_screen_handler;
    230   AddScreenHandler(locally_managed_user_creation_screen_handler);
    231 
    232   WrongHWIDScreenHandler* wrong_hwid_screen_handler =
    233       new WrongHWIDScreenHandler();
    234   wrong_hwid_screen_actor_ = wrong_hwid_screen_handler;
    235   AddScreenHandler(wrong_hwid_screen_handler);
    236 
    237   AutoEnrollmentCheckScreenHandler* auto_enrollment_check_screen_handler =
    238       new AutoEnrollmentCheckScreenHandler();
    239   auto_enrollment_check_screen_actor_ = auto_enrollment_check_screen_handler;
    240   AddScreenHandler(auto_enrollment_check_screen_handler);
    241 
    242   HIDDetectionScreenHandler* hid_detection_screen_handler =
    243       new HIDDetectionScreenHandler(core_handler_);
    244   hid_detection_screen_actor_ = hid_detection_screen_handler;
    245   AddScreenHandler(hid_detection_screen_handler);
    246 
    247   EnrollmentScreenHandler* enrollment_screen_handler =
    248       new EnrollmentScreenHandler();
    249   enrollment_screen_actor_ = enrollment_screen_handler;
    250   AddScreenHandler(enrollment_screen_handler);
    251 
    252   TermsOfServiceScreenHandler* terms_of_service_screen_handler =
    253       new TermsOfServiceScreenHandler;
    254   terms_of_service_screen_actor_ = terms_of_service_screen_handler;
    255   AddScreenHandler(terms_of_service_screen_handler);
    256 
    257   UserImageScreenHandler* user_image_screen_handler =
    258       new UserImageScreenHandler();
    259   user_image_screen_actor_ = user_image_screen_handler;
    260   AddScreenHandler(user_image_screen_handler);
    261 
    262   error_screen_handler_ = new ErrorScreenHandler(network_state_informer_);
    263   AddScreenHandler(error_screen_handler_);
    264 
    265   gaia_screen_handler_ = new GaiaScreenHandler(network_state_informer_);
    266   AddScreenHandler(gaia_screen_handler_);
    267 
    268   signin_screen_handler_ = new SigninScreenHandler(network_state_informer_,
    269                                                    error_screen_handler_,
    270                                                    core_handler_,
    271                                                    gaia_screen_handler_);
    272   AddScreenHandler(signin_screen_handler_);
    273 
    274   AppLaunchSplashScreenHandler* app_launch_splash_screen_handler =
    275       new AppLaunchSplashScreenHandler(network_state_informer_,
    276                                        error_screen_handler_);
    277   AddScreenHandler(app_launch_splash_screen_handler);
    278   app_launch_splash_screen_actor_ = app_launch_splash_screen_handler;
    279 
    280   // Initialize KioskAppMenuHandler. Note that it is NOT a screen handler.
    281   kiosk_app_menu_handler_ = new KioskAppMenuHandler(network_state_informer_);
    282   web_ui->AddMessageHandler(kiosk_app_menu_handler_);
    283 
    284   base::DictionaryValue localized_strings;
    285   GetLocalizedStrings(&localized_strings);
    286 
    287   Profile* profile = Profile::FromWebUI(web_ui);
    288   // Set up the chrome://theme/ source, for Chrome logo.
    289   ThemeSource* theme = new ThemeSource(profile);
    290   content::URLDataSource::Add(profile, theme);
    291 
    292   // Set up the chrome://terms/ data source, for EULA content.
    293   AboutUIHTMLSource* about_source =
    294       new AboutUIHTMLSource(chrome::kChromeUITermsHost, profile);
    295   content::URLDataSource::Add(profile, about_source);
    296 
    297   // Set up the chrome://oobe/ source.
    298   content::WebUIDataSource::Add(profile,
    299                                 CreateOobeUIDataSource(localized_strings,
    300                                                        display_type_));
    301 
    302   // Set up the chrome://userimage/ source.
    303   options::UserImageSource* user_image_source =
    304       new options::UserImageSource();
    305   content::URLDataSource::Add(profile, user_image_source);
    306 }
    307 
    308 OobeUI::~OobeUI() {
    309   core_handler_->SetDelegate(NULL);
    310   network_dropdown_handler_->RemoveObserver(update_screen_handler_);
    311 }
    312 
    313 void OobeUI::ShowScreen(WizardScreen* screen) {
    314   screen->Show();
    315 }
    316 
    317 void OobeUI::HideScreen(WizardScreen* screen) {
    318   screen->Hide();
    319 }
    320 
    321 CoreOobeActor* OobeUI::GetCoreOobeActor() {
    322   return core_handler_;
    323 }
    324 
    325 UpdateScreenActor* OobeUI::GetUpdateScreenActor() {
    326   return update_screen_handler_;
    327 }
    328 
    329 NetworkScreenActor* OobeUI::GetNetworkScreenActor() {
    330   return network_screen_actor_;
    331 }
    332 
    333 EulaScreenActor* OobeUI::GetEulaScreenActor() {
    334   return eula_screen_actor_;
    335 }
    336 
    337 EnrollmentScreenActor* OobeUI::GetEnrollmentScreenActor() {
    338   return enrollment_screen_actor_;
    339 }
    340 
    341 ResetScreenActor* OobeUI::GetResetScreenActor() {
    342   return reset_screen_actor_;
    343 }
    344 
    345 KioskAutolaunchScreenActor* OobeUI::GetKioskAutolaunchScreenActor() {
    346   return autolaunch_screen_actor_;
    347 }
    348 
    349 KioskEnableScreenActor* OobeUI::GetKioskEnableScreenActor() {
    350   return kiosk_enable_screen_actor_;
    351 }
    352 
    353 TermsOfServiceScreenActor* OobeUI::GetTermsOfServiceScreenActor() {
    354   return terms_of_service_screen_actor_;
    355 }
    356 
    357 WrongHWIDScreenActor* OobeUI::GetWrongHWIDScreenActor() {
    358   return wrong_hwid_screen_actor_;
    359 }
    360 
    361 AutoEnrollmentCheckScreenActor* OobeUI::GetAutoEnrollmentCheckScreenActor() {
    362   return auto_enrollment_check_screen_actor_;
    363 }
    364 
    365 HIDDetectionScreenActor* OobeUI::GetHIDDetectionScreenActor() {
    366   return hid_detection_screen_actor_;
    367 }
    368 
    369 UserImageScreenActor* OobeUI::GetUserImageScreenActor() {
    370   return user_image_screen_actor_;
    371 }
    372 
    373 ErrorScreenActor* OobeUI::GetErrorScreenActor() {
    374   return error_screen_handler_;
    375 }
    376 
    377 LocallyManagedUserCreationScreenHandler*
    378     OobeUI::GetLocallyManagedUserCreationScreenActor() {
    379   return locally_managed_user_creation_screen_actor_;
    380 }
    381 
    382 AppLaunchSplashScreenActor*
    383       OobeUI::GetAppLaunchSplashScreenActor() {
    384   return app_launch_splash_screen_actor_;
    385 }
    386 
    387 void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
    388   // Note, handlers_[0] is a GenericHandler used by the WebUI.
    389   for (size_t i = 0; i < handlers_.size(); ++i)
    390     handlers_[i]->GetLocalizedStrings(localized_strings);
    391   webui::SetFontAndTextDirection(localized_strings);
    392   kiosk_app_menu_handler_->GetLocalizedStrings(localized_strings);
    393 
    394 #if defined(GOOGLE_CHROME_BUILD)
    395   localized_strings->SetString("buildType", "chrome");
    396 #else
    397   localized_strings->SetString("buildType", "chromium");
    398 #endif
    399 
    400   // If we're not doing boot animation then WebUI should trigger
    401   // wallpaper load on boot.
    402   if (CommandLine::ForCurrentProcess()->HasSwitch(
    403           switches::kDisableBootAnimation)) {
    404     localized_strings->SetString("bootIntoWallpaper", "on");
    405   } else {
    406     localized_strings->SetString("bootIntoWallpaper", "off");
    407   }
    408 
    409   bool keyboard_driven_oobe =
    410       system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation();
    411   localized_strings->SetString("highlightStrength",
    412                                keyboard_driven_oobe ? "strong" : "normal");
    413 
    414   bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI();
    415   localized_strings->SetString("newKioskUI", new_kiosk_ui ? "on" : "off");
    416 }
    417 
    418 void OobeUI::InitializeScreenMaps() {
    419   screen_names_.resize(SCREEN_UNKNOWN);
    420   screen_names_[SCREEN_OOBE_HID_DETECTION] = kScreenOobeHIDDetection;
    421   screen_names_[SCREEN_OOBE_NETWORK] = kScreenOobeNetwork;
    422   screen_names_[SCREEN_OOBE_EULA] = kScreenOobeEula;
    423   screen_names_[SCREEN_OOBE_UPDATE] = kScreenOobeUpdate;
    424   screen_names_[SCREEN_OOBE_ENROLLMENT] = kScreenOobeEnrollment;
    425   screen_names_[SCREEN_OOBE_RESET] = kScreenOobeReset;
    426   screen_names_[SCREEN_GAIA_SIGNIN] = kScreenGaiaSignin;
    427   screen_names_[SCREEN_ACCOUNT_PICKER] = kScreenAccountPicker;
    428   screen_names_[SCREEN_KIOSK_AUTOLAUNCH] = kScreenKioskAutolaunch;
    429   screen_names_[SCREEN_KIOSK_ENABLE] = kScreenKioskEnable;
    430   screen_names_[SCREEN_ERROR_MESSAGE] = kScreenErrorMessage;
    431   screen_names_[SCREEN_USER_IMAGE_PICKER] = kScreenUserImagePicker;
    432   screen_names_[SCREEN_TPM_ERROR] = kScreenTpmError;
    433   screen_names_[SCREEN_PASSWORD_CHANGED] = kScreenPasswordChanged;
    434   screen_names_[SCREEN_CREATE_MANAGED_USER_FLOW] =
    435       kScreenManagedUserCreationFlow;
    436   screen_names_[SCREEN_TERMS_OF_SERVICE] = kScreenTermsOfService;
    437   screen_names_[SCREEN_WRONG_HWID] = kScreenWrongHWID;
    438   screen_names_[SCREEN_AUTO_ENROLLMENT_CHECK] = kScreenAutoEnrollmentCheck;
    439   screen_names_[SCREEN_APP_LAUNCH_SPLASH] = kScreenAppLaunchSplash;
    440   screen_names_[SCREEN_CONFIRM_PASSWORD] = kScreenConfirmPassword;
    441   screen_names_[SCREEN_FATAL_ERROR] = kScreenFatalError;
    442 
    443   screen_ids_.clear();
    444   for (size_t i = 0; i < screen_names_.size(); ++i)
    445     screen_ids_[screen_names_[i]] = static_cast<Screen>(i);
    446 }
    447 
    448 void OobeUI::AddScreenHandler(BaseScreenHandler* handler) {
    449   web_ui()->AddMessageHandler(handler);
    450   handlers_.push_back(handler);
    451 }
    452 
    453 void OobeUI::InitializeHandlers() {
    454   ready_ = true;
    455   for (size_t i = 0; i < ready_callbacks_.size(); ++i)
    456     ready_callbacks_[i].Run();
    457   ready_callbacks_.clear();
    458 
    459   // Notify 'initialize' for synchronously loaded screens.
    460   for (size_t i = 0; i < handlers_.size(); ++i) {
    461     if (handlers_[i]->async_assets_load_id().empty())
    462       handlers_[i]->InitializeBase();
    463   }
    464 }
    465 
    466 void OobeUI::OnScreenAssetsLoaded(const std::string& async_assets_load_id) {
    467   DCHECK(!async_assets_load_id.empty());
    468 
    469   for (size_t i = 0; i < handlers_.size(); ++i) {
    470     if (handlers_[i]->async_assets_load_id() == async_assets_load_id)
    471       handlers_[i]->InitializeBase();
    472   }
    473 }
    474 
    475 bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) {
    476   if (!ready_)
    477     ready_callbacks_.push_back(display_is_ready_callback);
    478   return ready_;
    479 }
    480 
    481 void OobeUI::ShowOobeUI(bool show) {
    482   core_handler_->ShowOobeUI(show);
    483 }
    484 
    485 void OobeUI::ShowRetailModeLoginSpinner() {
    486   signin_screen_handler_->ShowRetailModeLoginSpinner();
    487 }
    488 
    489 void OobeUI::ShowSigninScreen(const LoginScreenContext& context,
    490                               SigninScreenHandlerDelegate* delegate,
    491                               NativeWindowDelegate* native_window_delegate) {
    492   signin_screen_handler_->SetDelegate(delegate);
    493   signin_screen_handler_->SetNativeWindowDelegate(native_window_delegate);
    494 
    495   LoginScreenContext actual_context(context);
    496   actual_context.set_oobe_ui(core_handler_->show_oobe_ui());
    497   signin_screen_handler_->Show(actual_context);
    498 }
    499 
    500 void OobeUI::ResetSigninScreenHandlerDelegate() {
    501   signin_screen_handler_->SetDelegate(NULL);
    502   signin_screen_handler_->SetNativeWindowDelegate(NULL);
    503 }
    504 
    505 
    506 void OobeUI::AddObserver(Observer* observer) {
    507   observer_list_.AddObserver(observer);
    508 }
    509 
    510 void OobeUI::RemoveObserver(Observer* observer) {
    511   observer_list_.RemoveObserver(observer);
    512 }
    513 
    514 const std::string& OobeUI::GetScreenName(Screen screen) const {
    515   DCHECK(screen >= 0 && screen < SCREEN_UNKNOWN);
    516   return screen_names_[static_cast<size_t>(screen)];
    517 }
    518 
    519 void OobeUI::OnCurrentScreenChanged(const std::string& screen) {
    520   previous_screen_ = current_screen_;
    521   if (screen_ids_.count(screen)) {
    522     Screen new_screen = screen_ids_[screen];
    523     FOR_EACH_OBSERVER(Observer,
    524                       observer_list_,
    525                       OnCurrentScreenChanged(current_screen_, new_screen));
    526     current_screen_ = new_screen;
    527   } else {
    528     NOTREACHED() << "Screen should be registered in InitializeScreenMaps()";
    529     current_screen_ = SCREEN_UNKNOWN;
    530   }
    531 }
    532 
    533 }  // namespace chromeos
    534