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