Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / login / core_oobe_handler.h
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
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 HandleEnableVirtualKeyboard(bool enabled);
85   void HandleEnableScreenMagnifier(bool enabled);
86   void HandleEnableSpokenFeedback();
87   void HandleInitialized();
88   void HandleSkipUpdateEnrollAfterEula();
89   void HandleUpdateCurrentScreen(const std::string& screen);
90   void HandleSetDeviceRequisition(const std::string& requisition);
91   void HandleScreenAssetsLoaded(const std::string& screen_async_load_id);
92   void HandleSkipToLoginForTesting(const base::ListValue* args);
93
94   // Updates a11y menu state based on the current a11y features state(on/off).
95   void UpdateA11yState();
96
97   // Calls javascript to sync OOBE UI visibility with show_oobe_ui_.
98   void UpdateOobeUIVisibility();
99
100   // Updates label with specified id with specified text.
101   void UpdateLabel(const std::string& id, const std::string& text);
102
103   // Updates the device requisition string on the UI side.
104   void UpdateDeviceRequisition();
105
106   // content::NotificationObserver implementation:
107   virtual void Observe(int type,
108                        const content::NotificationSource& source,
109                        const content::NotificationDetails& details) OVERRIDE;
110
111   // Owner of this handler.
112   OobeUI* oobe_ui_;
113
114   // True if we should show OOBE instead of login.
115   bool show_oobe_ui_;
116
117   // Updates when version info is changed.
118   VersionInfoUpdater version_info_updater_;
119
120   Delegate* delegate_;
121
122   content::NotificationRegistrar registrar_;
123
124   DISALLOW_COPY_AND_ASSIGN(CoreOobeHandler);
125 };
126
127 }  // namespace chromeos
128
129 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_