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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
      6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
      7 
      8 #include <string>
      9 
     10 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
     11 #include "chrome/browser/chromeos/login/version_info_updater.h"
     12 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
     13 #include "content/public/browser/notification_observer.h"
     14 #include "content/public/browser/notification_registrar.h"
     15 
     16 namespace chromeos {
     17 
     18 class OobeUI;
     19 
     20 // The core handler for Javascript messages related to the "oobe" view.
     21 class CoreOobeHandler : public BaseScreenHandler,
     22                         public VersionInfoUpdater::Delegate,
     23                         public content::NotificationObserver,
     24                         public CoreOobeActor {
     25  public:
     26   class Delegate {
     27    public:
     28     // Called when current screen is changed.
     29     virtual void OnCurrentScreenChanged(const std::string& screen) = 0;
     30   };
     31 
     32   explicit CoreOobeHandler(OobeUI* oobe_ui);
     33   virtual ~CoreOobeHandler();
     34 
     35   void SetDelegate(Delegate* delegate);
     36 
     37   // BaseScreenHandler implementation:
     38   virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
     39   virtual void Initialize() OVERRIDE;
     40 
     41   // WebUIMessageHandler implementation.
     42   virtual void RegisterMessages() OVERRIDE;
     43 
     44   // VersionInfoUpdater::Delegate implementation:
     45   virtual void OnOSVersionLabelTextUpdated(
     46       const std::string& os_version_label_text) OVERRIDE;
     47   virtual void OnEnterpriseInfoUpdated(
     48       const std::string& message_text) OVERRIDE;
     49 
     50   // Show or hide OOBE UI.
     51   void ShowOobeUI(bool show);
     52 
     53   bool show_oobe_ui() const {
     54     return show_oobe_ui_;
     55   }
     56 
     57  private:
     58   // CoreOobeActor implementation:
     59   virtual void ShowSignInError(
     60       int login_attempts,
     61       const std::string& error_text,
     62       const std::string& help_link_text,
     63       HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE;
     64   virtual void ShowTpmError() OVERRIDE;
     65   virtual void ShowSignInUI(const std::string& email) OVERRIDE;
     66   virtual void ResetSignInUI(bool force_online) OVERRIDE;
     67   virtual void ClearUserPodPassword() OVERRIDE;
     68   virtual void RefocusCurrentPod() OVERRIDE;
     69   virtual void OnLoginSuccess(const std::string& username) OVERRIDE;
     70   virtual void ShowPasswordChangedScreen(bool show_password_error) OVERRIDE;
     71   virtual void SetUsageStats(bool checked) OVERRIDE;
     72   virtual void SetOemEulaUrl(const std::string& oem_eula_url) OVERRIDE;
     73   virtual void SetTpmPassword(const std::string& tmp_password) OVERRIDE;
     74   virtual void ClearErrors() OVERRIDE;
     75   virtual void ReloadContent(const base::DictionaryValue& dictionary) OVERRIDE;
     76 
     77   // Handlers for JS WebUI messages.
     78   void HandleEnableLargeCursor(bool enabled);
     79   void HandleEnableHighContrast(bool enabled);
     80   void HandleEnableScreenMagnifier(bool enabled);
     81   void HandleEnableSpokenFeedback();
     82   void HandleInitialized();
     83   void HandleSkipUpdateEnrollAfterEula();
     84   void HandleUpdateCurrentScreen(const std::string& screen);
     85   void HandleSetDeviceRequisition(const std::string& requisition);
     86   void HandleSkipToLoginForTesting();
     87 
     88   // Updates a11y menu state based on the current a11y features state(on/off).
     89   void UpdateA11yState();
     90 
     91   // Calls javascript to sync OOBE UI visibility with show_oobe_ui_.
     92   void UpdateOobeUIVisibility();
     93 
     94   // Updates label with specified id with specified text.
     95   void UpdateLabel(const std::string& id, const std::string& text);
     96 
     97   // Updates the device requisition string on the UI side.
     98   void UpdateDeviceRequisition();
     99 
    100   // content::NotificationObserver implementation:
    101   virtual void Observe(int type,
    102                        const content::NotificationSource& source,
    103                        const content::NotificationDetails& details) OVERRIDE;
    104 
    105   // Owner of this handler.
    106   OobeUI* oobe_ui_;
    107 
    108   // True if we should show OOBE instead of login.
    109   bool show_oobe_ui_;
    110 
    111   // Updates when version info is changed.
    112   VersionInfoUpdater version_info_updater_;
    113 
    114   Delegate* delegate_;
    115 
    116   content::NotificationRegistrar registrar_;
    117 
    118   DISALLOW_COPY_AND_ASSIGN(CoreOobeHandler);
    119 };
    120 
    121 }  // namespace chromeos
    122 
    123 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
    124