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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_
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/screens/network_error.h"
13 #include "chrome/browser/chromeos/login/screens/network_error_model.h"
14 #include "chrome/browser/chromeos/login/ui/oobe_display.h"
15 #include "chrome/browser/chromeos/settings/device_settings_service.h"
16 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
17 #include "chromeos/login/auth/login_performer.h"
21 class BaseScreenDelegate
;
22 class CaptivePortalWindowProxy
;
23 class NetworkErrorView
;
25 // Controller for the error screen.
26 class ErrorScreen
: public NetworkErrorModel
, public LoginPerformer::Delegate
{
28 typedef scoped_ptr
<base::CallbackList
<void()>::Subscription
>
29 ConnectRequestCallbackSubscription
;
31 ErrorScreen(BaseScreenDelegate
* base_screen_delegate
, NetworkErrorView
* view
);
32 ~ErrorScreen() override
;
35 void PrepareToShow() override
;
38 void OnShow() override
;
39 void OnHide() override
;
40 void OnUserAction(const std::string
& action_id
) override
;
41 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType
& key
) override
;
42 void AllowGuestSignin(bool allowed
) override
;
43 void AllowOfflineLogin(bool allowed
) override
;
44 void FixCaptivePortal() override
;
45 NetworkError::UIState
GetUIState() const override
;
46 NetworkError::ErrorState
GetErrorState() const override
;
47 OobeUI::Screen
GetParentScreen() const override
;
48 void HideCaptivePortal() override
;
49 void OnViewDestroyed(NetworkErrorView
* view
) override
;
50 void SetUIState(NetworkError::UIState ui_state
) override
;
51 void SetErrorState(NetworkError::ErrorState error_state
,
52 const std::string
& network
) override
;
53 void SetParentScreen(OobeUI::Screen parent_screen
) override
;
54 void SetHideCallback(const base::Closure
& on_hide
) override
;
55 void ShowCaptivePortal() override
;
56 void ShowConnectingIndicator(bool show
) override
;
58 // LoginPerformer::Delegate implementation:
59 void OnAuthFailure(const AuthFailure
& error
) override
;
60 void OnAuthSuccess(const UserContext
& user_context
) override
;
61 void OnOffTheRecordAuthSuccess() override
;
62 void OnPasswordChangeDetected() override
;
63 void WhiteListCheckFailed(const std::string
& email
) override
;
64 void PolicyLoadFailed() override
;
65 void OnOnlineChecked(const std::string
& username
, bool success
) override
;
67 // Register a callback to be invoked when the user indicates that an attempt
68 // to connect to the network should be made.
69 ConnectRequestCallbackSubscription
RegisterConnectRequestCallback(
70 const base::Closure
& callback
);
73 // Default hide_closure for Hide().
74 void DefaultHideCallback();
76 // Handle user action to configure certificates.
77 void OnConfigureCerts();
79 // Handle user action to diagnose network configuration.
80 void OnDiagnoseButtonClicked();
82 // Handle user action to launch guest session from out-of-box.
83 void OnLaunchOobeGuestSession();
85 // Handle user action to launch Powerwash in case of
86 // Local State critical error.
87 void OnLocalStateErrorPowerwashButtonClicked();
89 // Handle uses action to reboot device.
90 void OnRebootButtonClicked();
92 // The user indicated to make an attempt to connect to the network.
93 void OnConnectRequested();
95 // Handles the response of an ownership check and starts the guest session if
97 void StartGuestSessionAfterOwnershipCheck(
98 DeviceSettingsService::OwnershipStatus ownership_status
);
100 NetworkErrorView
* view_
;
102 scoped_ptr
<LoginPerformer
> guest_login_performer_
;
104 // Proxy which manages showing of the window for captive portal entering.
105 scoped_ptr
<CaptivePortalWindowProxy
> captive_portal_window_proxy_
;
107 // Network state informer used to keep error screen up.
108 scoped_refptr
<NetworkStateInformer
> network_state_informer_
;
110 NetworkError::UIState ui_state_
;
111 NetworkError::ErrorState error_state_
;
113 OobeUI::Screen parent_screen_
;
115 // Optional callback that is called when NetworkError screen is hidden.
116 scoped_ptr
<base::Closure
> on_hide_callback_
;
118 // Callbacks to be invoked when a connection attempt is requested.
119 base::CallbackList
<void()> connect_request_callbacks_
;
121 base::WeakPtrFactory
<ErrorScreen
> weak_factory_
;
123 DISALLOW_COPY_AND_ASSIGN(ErrorScreen
);
126 } // namespace chromeos
128 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_