OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 12 #include "chrome/browser/chromeos/login/screens/network_error.h" |
13 #include "chrome/browser/chromeos/login/screens/error_screen_actor_delegate.h" | 13 #include "chrome/browser/chromeos/login/screens/network_error_model.h" |
14 #include "chrome/browser/chromeos/login/ui/oobe_display.h" | 14 #include "chrome/browser/chromeos/login/ui/oobe_display.h" |
15 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 16 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
16 #include "chromeos/login/auth/login_performer.h" | 17 #include "chromeos/login/auth/login_performer.h" |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 class BaseScreenDelegate; | 21 class BaseScreenDelegate; |
| 22 class CaptivePortalWindowProxy; |
| 23 class NetworkErrorView; |
21 | 24 |
22 // Controller for the error screen. | 25 // Controller for the error screen. |
23 class ErrorScreen : public BaseScreen, | 26 class ErrorScreen : public NetworkErrorModel, public LoginPerformer::Delegate { |
24 public ErrorScreenActorDelegate, | |
25 public LoginPerformer::Delegate { | |
26 public: | 27 public: |
27 enum UIState { | 28 ErrorScreen(BaseScreenDelegate* base_screen_delegate, NetworkErrorView* view); |
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_NONE, | |
45 // States above are being logged to histograms. | |
46 // Please keep ERROR_STATE_NONE as the last one of the histogram values. | |
47 ERROR_STATE_KIOSK_ONLINE, | |
48 }; | |
49 | |
50 ErrorScreen(BaseScreenDelegate* base_screen_delegate, | |
51 ErrorScreenActor* actor); | |
52 ~ErrorScreen() override; | 29 ~ErrorScreen() override; |
53 | 30 |
54 // BaseScreen implementation. | 31 // NetworkErrorModel: |
55 void PrepareToShow() override; | 32 void PrepareToShow() override; |
56 void Show() override; | 33 void Show() override; |
57 void Hide() override; | 34 void Hide() override; |
58 std::string GetName() const override; | 35 void OnShow() override; |
59 | 36 void OnHide() override; |
60 // ErrorScreenActorDelegate implementation: | 37 void OnUserAction(const std::string& action_id) override; |
61 void OnErrorShow() override; | 38 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType& key) override; |
62 void OnErrorHide() override; | 39 void AllowGuestSignin(bool allowed) override; |
63 void OnLaunchOobeGuestSession() override; | 40 void AllowOfflineLogin(bool allowed) override; |
64 void OnActorDestroyed() override; | 41 void FixCaptivePortal() override; |
| 42 NetworkError::UIState GetUIState() const override; |
| 43 NetworkError::ErrorState GetErrorState() const override; |
| 44 OobeUI::Screen GetParentScreen() const override; |
| 45 void HideCaptivePortal() override; |
| 46 void OnViewDestroyed(NetworkErrorView* view) override; |
| 47 void SetUIState(NetworkError::UIState ui_state) override; |
| 48 void SetErrorState(NetworkError::ErrorState error_state, |
| 49 const std::string& network) override; |
| 50 void SetParentScreen(OobeUI::Screen parent_screen) override; |
| 51 void SetHideCallback(const base::Closure& on_hide) override; |
| 52 void ShowCaptivePortal() override; |
| 53 void ShowConnectingIndicator(bool show) override; |
65 | 54 |
66 // LoginPerformer::Delegate implementation: | 55 // LoginPerformer::Delegate implementation: |
67 void OnAuthFailure(const AuthFailure& error) override; | 56 void OnAuthFailure(const AuthFailure& error) override; |
68 void OnAuthSuccess(const UserContext& user_context) override; | 57 void OnAuthSuccess(const UserContext& user_context) override; |
69 void OnOffTheRecordAuthSuccess() override; | 58 void OnOffTheRecordAuthSuccess() override; |
70 void OnPasswordChangeDetected() override; | 59 void OnPasswordChangeDetected() override; |
71 void WhiteListCheckFailed(const std::string& email) override; | 60 void WhiteListCheckFailed(const std::string& email) override; |
72 void PolicyLoadFailed() override; | 61 void PolicyLoadFailed() override; |
73 void OnOnlineChecked(const std::string& username, bool success) override; | 62 void OnOnlineChecked(const std::string& username, bool success) override; |
74 | 63 |
75 // Initializes captive portal dialog and shows that if needed. | 64 private: |
76 void FixCaptivePortal(); | 65 // Default hide_closure for Hide(). |
| 66 void DefaultHideCallback(); |
77 | 67 |
78 // Shows captive portal dialog. | 68 // Handle user action to configure certificates. |
79 void ShowCaptivePortal(); | 69 void OnConfigureCerts(); |
80 | 70 |
81 // Hides captive portal dialog. | 71 // Handle user action to diagnose network configuration. |
82 void HideCaptivePortal(); | 72 void OnDiagnoseButtonClicked(); |
83 | 73 |
84 // Sets current UI state. | 74 // Handle user action to launch guest session from out-of-box. |
85 void SetUIState(UIState ui_state); | 75 void OnLaunchOobeGuestSession(); |
86 | 76 |
87 UIState GetUIState() const; | 77 // Handle user action to launch Powerwash in case of |
| 78 // Local State critical error. |
| 79 void OnLocalStateErrorPowerwashButtonClicked(); |
88 | 80 |
89 // Sets current error screen content according to current UI state, | 81 // Handle uses action to reboot device. |
90 // |error_state|, and |network|. | 82 void OnRebootButtonClicked(); |
91 void SetErrorState(ErrorState error_state, const std::string& network); | |
92 | 83 |
93 ErrorState GetErrorState() const; | |
94 | |
95 // Toggles the guest sign-in prompt. | |
96 void AllowGuestSignin(bool allow); | |
97 | |
98 // Toggles the connection pending indicator. | |
99 void ShowConnectingIndicator(bool show); | |
100 | |
101 void set_parent_screen(OobeDisplay::Screen parent_screen) { | |
102 parent_screen_ = parent_screen; | |
103 } | |
104 OobeDisplay::Screen parent_screen() const { return parent_screen_; } | |
105 | |
106 private: | |
107 // Handles the response of an ownership check and starts the guest session if | 84 // Handles the response of an ownership check and starts the guest session if |
108 // applicable. | 85 // applicable. |
109 void StartGuestSessionAfterOwnershipCheck( | 86 void StartGuestSessionAfterOwnershipCheck( |
110 DeviceSettingsService::OwnershipStatus ownership_status); | 87 DeviceSettingsService::OwnershipStatus ownership_status); |
111 | 88 |
112 ErrorScreenActor* actor_; | 89 NetworkErrorView* view_; |
113 | |
114 OobeDisplay::Screen parent_screen_; | |
115 | 90 |
116 scoped_ptr<LoginPerformer> guest_login_performer_; | 91 scoped_ptr<LoginPerformer> guest_login_performer_; |
117 | 92 |
| 93 // Proxy which manages showing of the window for captive portal entering. |
| 94 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_; |
| 95 |
| 96 // Network state informer used to keep error screen up. |
| 97 scoped_refptr<NetworkStateInformer> network_state_informer_; |
| 98 |
| 99 NetworkError::UIState ui_state_; |
| 100 NetworkError::ErrorState error_state_; |
| 101 |
| 102 OobeUI::Screen parent_screen_; |
| 103 |
| 104 // Optional callback that is called when NetworkError screen is hidden. |
| 105 scoped_ptr<base::Closure> on_hide_callback_; |
| 106 |
118 base::WeakPtrFactory<ErrorScreen> weak_factory_; | 107 base::WeakPtrFactory<ErrorScreen> weak_factory_; |
119 | 108 |
120 DISALLOW_COPY_AND_ASSIGN(ErrorScreen); | 109 DISALLOW_COPY_AND_ASSIGN(ErrorScreen); |
121 }; | 110 }; |
122 | 111 |
123 } // namespace chromeos | 112 } // namespace chromeos |
124 | 113 |
125 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_ | 114 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_ |
OLD | NEW |