Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / oobe_ui.h
blob72e85688ac92b6c51586292b4e9dbf769d52451f
1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OOBE_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OOBE_UI_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "chrome/browser/chromeos/login/ui/oobe_display.h"
17 #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h"
18 #include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
19 #include "content/public/browser/web_ui_controller.h"
21 namespace base {
22 class DictionaryValue;
23 } // namespace base
25 namespace chromeos {
26 class AppLaunchSplashScreenActor;
27 class AutoEnrollmentCheckScreenActor;
28 class BaseScreenHandler;
29 class ControllerPairingScreenActor;
30 class DeviceDisabledScreenActor;
31 class ErrorScreen;
32 class ErrorScreenHandler;
33 class GaiaScreenHandler;
34 class HostPairingScreenActor;
35 class KioskAppMenuHandler;
36 class KioskEnableScreenActor;
37 class LoginScreenContext;
38 class NativeWindowDelegate;
39 class NetworkDropdownHandler;
40 class NetworkStateInformer;
41 class SigninScreenHandler;
42 class SigninScreenHandlerDelegate;
43 class UserBoardScreenHandler;
45 // A custom WebUI that defines datasource for out-of-box-experience (OOBE) UI:
46 // - welcome screen (setup language/keyboard/network).
47 // - eula screen (CrOS (+ OEM) EULA content/TPM password/crash reporting).
48 // - update screen.
49 class OobeUI : public OobeDisplay,
50 public content::WebUIController,
51 public CoreOobeHandler::Delegate,
52 public ShutdownPolicyHandler::Delegate {
53 public:
54 class Observer {
55 public:
56 virtual ~Observer() {}
57 virtual void OnCurrentScreenChanged(
58 Screen current_screen, Screen new_screen) = 0;
61 // List of known types of OobeUI. Type added as path in chrome://oobe url, for
62 // example chrome://oobe/user-adding.
63 static const char kOobeDisplay[];
64 static const char kLoginDisplay[];
65 static const char kLockDisplay[];
66 static const char kUserAddingDisplay[];
67 static const char kAppLaunchSplashDisplay[];
69 // JS oobe/login screens names.
70 static const char kScreenOobeHIDDetection[];
71 static const char kScreenOobeNetwork[];
72 static const char kScreenOobeEnableDebugging[];
73 static const char kScreenOobeEula[];
74 static const char kScreenOobeUpdate[];
75 static const char kScreenOobeEnrollment[];
76 static const char kScreenOobeReset[];
77 static const char kScreenGaiaSignin[];
78 static const char kScreenAccountPicker[];
79 static const char kScreenKioskAutolaunch[];
80 static const char kScreenKioskEnable[];
81 static const char kScreenErrorMessage[];
82 static const char kScreenUserImagePicker[];
83 static const char kScreenTpmError[];
84 static const char kScreenPasswordChanged[];
85 static const char kScreenSupervisedUserCreationFlow[];
86 static const char kScreenTermsOfService[];
87 static const char kScreenWrongHWID[];
88 static const char kScreenAutoEnrollmentCheck[];
89 static const char kScreenAppLaunchSplash[];
90 static const char kScreenConfirmPassword[];
91 static const char kScreenFatalError[];
92 static const char kScreenHIDDetection[];
93 static const char kScreenControllerPairing[];
94 static const char kScreenHostPairing[];
95 static const char kScreenDeviceDisabled[];
97 OobeUI(content::WebUI* web_ui, const GURL& url);
98 ~OobeUI() override;
100 // OobeDisplay implementation:
101 CoreOobeActor* GetCoreOobeActor() override;
102 NetworkView* GetNetworkView() override;
103 EulaView* GetEulaView() override;
104 UpdateView* GetUpdateView() override;
105 EnableDebuggingScreenActor* GetEnableDebuggingScreenActor() override;
106 EnrollmentScreenActor* GetEnrollmentScreenActor() override;
107 ResetView* GetResetView() override;
108 KioskAutolaunchScreenActor* GetKioskAutolaunchScreenActor() override;
109 KioskEnableScreenActor* GetKioskEnableScreenActor() override;
110 TermsOfServiceScreenActor* GetTermsOfServiceScreenActor() override;
111 UserImageView* GetUserImageView() override;
112 ErrorScreen* GetErrorScreen() override;
113 WrongHWIDScreenActor* GetWrongHWIDScreenActor() override;
114 AutoEnrollmentCheckScreenActor* GetAutoEnrollmentCheckScreenActor() override;
115 SupervisedUserCreationScreenHandler* GetSupervisedUserCreationScreenActor()
116 override;
117 AppLaunchSplashScreenActor* GetAppLaunchSplashScreenActor() override;
118 bool IsJSReady(const base::Closure& display_is_ready_callback) override;
119 HIDDetectionView* GetHIDDetectionView() override;
120 ControllerPairingScreenActor* GetControllerPairingScreenActor() override;
121 HostPairingScreenActor* GetHostPairingScreenActor() override;
122 DeviceDisabledScreenActor* GetDeviceDisabledScreenActor() override;
123 GaiaScreenHandler* GetGaiaScreenActor() override;
124 UserBoardView* GetUserBoardScreenActor() override;
126 // ShutdownPolicyObserver::Delegate
127 void OnShutdownPolicyChanged(bool reboot_on_shutdown) override;
129 // Collects localized strings from the owned handlers.
130 void GetLocalizedStrings(base::DictionaryValue* localized_strings);
132 // Initializes the handlers.
133 void InitializeHandlers();
135 // Invoked after the async assets load. The screen handler that has the same
136 // async assets load id will be initialized.
137 void OnScreenAssetsLoaded(const std::string& async_assets_load_id);
139 // Shows or hides OOBE UI elements.
140 void ShowOobeUI(bool show);
142 // Shows the signin screen.
143 void ShowSigninScreen(const LoginScreenContext& context,
144 SigninScreenHandlerDelegate* delegate,
145 NativeWindowDelegate* native_window_delegate);
147 // Resets the delegate set in ShowSigninScreen.
148 void ResetSigninScreenHandlerDelegate();
150 // Add and remove observers for screen change events.
151 void AddObserver(Observer* observer);
152 void RemoveObserver(Observer* observer);
154 Screen current_screen() const { return current_screen_; }
156 Screen previous_screen() const { return previous_screen_; }
158 const std::string& display_type() const { return display_type_; }
160 const std::string& GetScreenName(Screen screen) const;
162 SigninScreenHandler* signin_screen_handler_for_test() {
163 return signin_screen_handler_;
166 NetworkStateInformer* network_state_informer_for_test() const {
167 return network_state_informer_.get();
170 private:
171 // Initializes |screen_ids_| and |screen_names_| structures.
172 void InitializeScreenMaps();
174 void AddScreenHandler(BaseScreenHandler* handler);
176 // CoreOobeHandler::Delegate implementation:
177 void OnCurrentScreenChanged(const std::string& screen) override;
179 // Type of UI.
180 std::string display_type_;
182 // Reference to NetworkStateInformer that handles changes in network
183 // state.
184 scoped_refptr<NetworkStateInformer> network_state_informer_;
186 // Reference to CoreOobeHandler that handles common requests of Oobe page.
187 CoreOobeHandler* core_handler_;
189 // Reference to NetworkDropdownHandler that handles interaction with
190 // network dropdown.
191 NetworkDropdownHandler* network_dropdown_handler_;
193 // Screens actors. Note, OobeUI owns them via |handlers_|, not directly here.
194 UpdateView* update_view_;
195 NetworkView* network_view_;
196 EnableDebuggingScreenActor* debugging_screen_actor_;
197 EulaView* eula_view_;
198 EnrollmentScreenActor* enrollment_screen_actor_;
199 ResetView* reset_view_;
200 HIDDetectionView* hid_detection_view_;
201 KioskAutolaunchScreenActor* autolaunch_screen_actor_;
202 KioskEnableScreenActor* kiosk_enable_screen_actor_;
203 WrongHWIDScreenActor* wrong_hwid_screen_actor_;
204 AutoEnrollmentCheckScreenActor* auto_enrollment_check_screen_actor_;
205 SupervisedUserCreationScreenHandler*
206 supervised_user_creation_screen_actor_;
207 AppLaunchSplashScreenActor* app_launch_splash_screen_actor_;
208 ControllerPairingScreenActor* controller_pairing_screen_actor_;
209 HostPairingScreenActor* host_pairing_screen_actor_;
210 DeviceDisabledScreenActor* device_disabled_screen_actor_;
212 // Reference to ErrorScreenHandler that handles error screen
213 // requests and forward calls from native code to JS side.
214 ErrorScreenHandler* error_screen_handler_;
216 // Reference to GaiaScreenHandler that handles gaia screen requests and
217 // forwards calls from native code to JS side.
218 GaiaScreenHandler* gaia_screen_handler_;
220 // Reference to UserBoardScreenHandler, that allows to pick user on device
221 // and attempt authentication.
222 UserBoardScreenHandler* user_board_screen_handler_;
224 // Reference to SigninScreenHandler that handles sign-in screen requests and
225 // forwards calls from native code to JS side.
226 SigninScreenHandler* signin_screen_handler_;
228 TermsOfServiceScreenActor* terms_of_service_screen_actor_;
229 UserImageView* user_image_view_;
231 std::vector<BaseScreenHandler*> handlers_; // Non-owning pointers.
233 KioskAppMenuHandler* kiosk_app_menu_handler_; // Non-owning pointers.
235 scoped_ptr<ErrorScreen> error_screen_;
237 // Id of the current oobe/login screen.
238 Screen current_screen_;
240 // Id of the previous oobe/login screen.
241 Screen previous_screen_;
243 // Maps JS screen names to screen ids.
244 std::map<std::string, Screen> screen_ids_;
246 // Maps screen ids to JS screen names.
247 std::vector<std::string> screen_names_;
249 // Flag that indicates whether JS part is fully loaded and ready to accept
250 // calls.
251 bool ready_;
253 // Callbacks to notify when JS part is fully loaded and ready to accept calls.
254 std::vector<base::Closure> ready_callbacks_;
256 // List of registered observers.
257 base::ObserverList<Observer> observer_list_;
259 // Observer of CrosSettings watching the kRebootOnShutdown policy.
260 scoped_ptr<ShutdownPolicyHandler> shutdown_policy_handler_;
262 DISALLOW_COPY_AND_ASSIGN(OobeUI);
265 } // namespace chromeos
267 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OOBE_UI_H_