• 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/accessibility/accessibility_manager.h"
11 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
12 #include "chrome/browser/chromeos/login/version_info_updater.h"
13 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
14 #include "chrome/browser/ui/webui/chromeos/login/demo_mode_detector.h"
15 
16 namespace base {
17 class ListValue;
18 }
19 
20 namespace gfx {
21 class Rect;
22 }
23 
24 namespace chromeos {
25 
26 class HelpAppLauncher;
27 class OobeUI;
28 
29 // The core handler for Javascript messages related to the "oobe" view.
30 class CoreOobeHandler : public BaseScreenHandler,
31                         public VersionInfoUpdater::Delegate,
32                         public CoreOobeActor {
33  public:
34   class Delegate {
35    public:
36     // Called when current screen is changed.
37     virtual void OnCurrentScreenChanged(const std::string& screen) = 0;
38   };
39 
40   explicit CoreOobeHandler(OobeUI* oobe_ui);
41   virtual ~CoreOobeHandler();
42 
43   void SetDelegate(Delegate* delegate);
44 
45   // BaseScreenHandler implementation:
46   virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
47   virtual void Initialize() OVERRIDE;
48 
49   // WebUIMessageHandler implementation.
50   virtual void RegisterMessages() OVERRIDE;
51 
52   // VersionInfoUpdater::Delegate implementation:
53   virtual void OnOSVersionLabelTextUpdated(
54       const std::string& os_version_label_text) OVERRIDE;
55   virtual void OnEnterpriseInfoUpdated(
56       const std::string& message_text) OVERRIDE;
57 
58   // Show or hide OOBE UI.
59   void ShowOobeUI(bool show);
60 
show_oobe_ui()61   bool show_oobe_ui() const {
62     return show_oobe_ui_;
63   }
64 
65  private:
66   // CoreOobeActor implementation:
67   virtual void ShowSignInError(
68       int login_attempts,
69       const std::string& error_text,
70       const std::string& help_link_text,
71       HelpAppLauncher::HelpTopic help_topic_id) OVERRIDE;
72   virtual void ShowTpmError() OVERRIDE;
73   virtual void ShowSignInUI(const std::string& email) OVERRIDE;
74   virtual void ResetSignInUI(bool force_online) OVERRIDE;
75   virtual void ClearUserPodPassword() OVERRIDE;
76   virtual void RefocusCurrentPod() OVERRIDE;
77   virtual void ShowPasswordChangedScreen(bool show_password_error) OVERRIDE;
78   virtual void SetUsageStats(bool checked) OVERRIDE;
79   virtual void SetOemEulaUrl(const std::string& oem_eula_url) OVERRIDE;
80   virtual void SetTpmPassword(const std::string& tmp_password) OVERRIDE;
81   virtual void ClearErrors() OVERRIDE;
82   virtual void ReloadContent(const base::DictionaryValue& dictionary) OVERRIDE;
83   virtual void ShowControlBar(bool show) OVERRIDE;
84   virtual void SetKeyboardState(bool shown, const gfx::Rect& bounds) OVERRIDE;
85   virtual void SetClientAreaSize(int width, int height) OVERRIDE;
86   virtual void ShowDeviceResetScreen() OVERRIDE;
87   virtual void InitDemoModeDetection() OVERRIDE;
88   virtual void StopDemoModeDetection() OVERRIDE;
89 
90   // Handlers for JS WebUI messages.
91   void HandleEnableLargeCursor(bool enabled);
92   void HandleEnableHighContrast(bool enabled);
93   void HandleEnableVirtualKeyboard(bool enabled);
94   void HandleEnableScreenMagnifier(bool enabled);
95   void HandleEnableSpokenFeedback();
96   void HandleInitialized();
97   void HandleSkipUpdateEnrollAfterEula();
98   void HandleUpdateCurrentScreen(const std::string& screen);
99   void HandleSetDeviceRequisition(const std::string& requisition);
100   void HandleScreenAssetsLoaded(const std::string& screen_async_load_id);
101   void HandleSkipToLoginForTesting(const base::ListValue* args);
102   void HandleLaunchHelpApp(double help_topic_id);
103   void HandleToggleResetScreen();
104   void HandleHeaderBarVisible();
105 
106   // Updates a11y menu state based on the current a11y features state(on/off).
107   void UpdateA11yState();
108 
109   // Calls javascript to sync OOBE UI visibility with show_oobe_ui_.
110   void UpdateOobeUIVisibility();
111 
112   // Updates label with specified id with specified text.
113   void UpdateLabel(const std::string& id, const std::string& text);
114 
115   // Updates the device requisition string on the UI side.
116   void UpdateDeviceRequisition();
117 
118   // Updates virtual keyboard state.
119   void UpdateKeyboardState();
120 
121   // Updates client area size based on the primary screen size.
122   void UpdateClientAreaSize();
123 
124   // Notification of a change in the accessibility settings.
125   void OnAccessibilityStatusChanged(
126       const AccessibilityStatusEventDetails& details);
127 
128   // Owner of this handler.
129   OobeUI* oobe_ui_;
130 
131   // True if we should show OOBE instead of login.
132   bool show_oobe_ui_;
133 
134   // Updates when version info is changed.
135   VersionInfoUpdater version_info_updater_;
136 
137   // Help application used for help dialogs.
138   scoped_refptr<HelpAppLauncher> help_app_;
139 
140   Delegate* delegate_;
141 
142   scoped_ptr<AccessibilityStatusSubscription> accessibility_subscription_;
143 
144   DemoModeDetector demo_mode_detector_;
145 
146   DISALLOW_COPY_AND_ASSIGN(CoreOobeHandler);
147 };
148 
149 }  // namespace chromeos
150 
151 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
152