error_screen.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "base/memory/scoped_ptr.h"
11#include "base/memory/weak_ptr.h"
12#include "chrome/browser/chromeos/login/auth/login_performer.h"
13#include "chrome/browser/chromeos/login/screens/error_screen_actor_delegate.h"
14#include "chrome/browser/chromeos/login/screens/wizard_screen.h"
15#include "chrome/browser/chromeos/login/ui/oobe_display.h"
16#include "chrome/browser/chromeos/settings/device_settings_service.h"
17
18namespace chromeos {
19
20class ScreenObserver;
21
22// Controller for the error screen.
23class ErrorScreen : public WizardScreen,
24                    public ErrorScreenActorDelegate,
25                    public LoginPerformer::Delegate {
26 public:
27  enum UIState {
28    UI_STATE_UNKNOWN = 0,
29    UI_STATE_UPDATE,
30    UI_STATE_SIGNIN,
31    UI_STATE_SUPERVISED,
32    UI_STATE_KIOSK_MODE,
33    UI_STATE_LOCAL_STATE_ERROR,
34    UI_STATE_AUTO_ENROLLMENT_ERROR,
35    UI_STATE_ROLLBACK_ERROR,
36  };
37
38  enum ErrorState {
39    ERROR_STATE_UNKNOWN = 0,
40    ERROR_STATE_PORTAL,
41    ERROR_STATE_OFFLINE,
42    ERROR_STATE_PROXY,
43    ERROR_STATE_AUTH_EXT_TIMEOUT,
44    ERROR_STATE_KIOSK_ONLINE
45  };
46
47  ErrorScreen(ScreenObserver* screen_observer, ErrorScreenActor* actor);
48  virtual ~ErrorScreen();
49
50  // WizardScreen implementation.
51  virtual void PrepareToShow() OVERRIDE;
52  virtual void Show() OVERRIDE;
53  virtual void Hide() OVERRIDE;
54  virtual std::string GetName() const OVERRIDE;
55
56  // ErrorScreenActorDelegate implementation:
57  virtual void OnErrorShow() OVERRIDE;
58  virtual void OnErrorHide() OVERRIDE;
59  virtual void OnLaunchOobeGuestSession() OVERRIDE;
60
61  // LoginPerformer::Delegate implementation:
62  virtual void OnAuthFailure(const AuthFailure& error) OVERRIDE;
63  virtual void OnAuthSuccess(const UserContext& user_context) OVERRIDE;
64  virtual void OnOffTheRecordAuthSuccess() OVERRIDE;
65  virtual void OnPasswordChangeDetected() OVERRIDE;
66  virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE;
67  virtual void PolicyLoadFailed() OVERRIDE;
68  virtual void OnOnlineChecked(const std::string& username,
69                               bool success) OVERRIDE;
70
71  // Initializes captive portal dialog and shows that if needed.
72  void FixCaptivePortal();
73
74  // Shows captive portal dialog.
75  void ShowCaptivePortal();
76
77  // Hides captive portal dialog.
78  void HideCaptivePortal();
79
80  // Sets current UI state.
81  void SetUIState(UIState ui_state);
82
83  UIState GetUIState() const;
84
85  // Sets current error screen content according to current UI state,
86  // |error_state|, and |network|.
87  void SetErrorState(ErrorState error_state, const std::string& network);
88
89  // Toggles the guest sign-in prompt.
90  void AllowGuestSignin(bool allow);
91
92  // Toggles the connection pending indicator.
93  void ShowConnectingIndicator(bool show);
94
95  void set_parent_screen(OobeDisplay::Screen parent_screen) {
96    parent_screen_ = parent_screen;
97  }
98  OobeDisplay::Screen parent_screen() const { return parent_screen_; }
99
100 private:
101  // Handles the response of an ownership check and starts the guest session if
102  // applicable.
103  void StartGuestSessionAfterOwnershipCheck(
104      DeviceSettingsService::OwnershipStatus ownership_status);
105
106  ErrorScreenActor* actor_;
107
108  OobeDisplay::Screen parent_screen_;
109
110  scoped_ptr<LoginPerformer> guest_login_performer_;
111
112  base::WeakPtrFactory<ErrorScreen> weak_factory_;
113
114  DISALLOW_COPY_AND_ASSIGN(ErrorScreen);
115};
116
117}  // namespace chromeos
118
119#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_
120