Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / login / screens / error_screen.h
blobb73284c8dd68f0dd63c88aac7fd84624594c689a
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"
19 namespace chromeos {
21 class BaseScreenDelegate;
22 class CaptivePortalWindowProxy;
23 class NetworkErrorView;
25 // Controller for the error screen.
26 class ErrorScreen : public NetworkErrorModel, public LoginPerformer::Delegate {
27 public:
28 typedef scoped_ptr<base::CallbackList<void()>::Subscription>
29 ConnectRequestCallbackSubscription;
31 ErrorScreen(BaseScreenDelegate* base_screen_delegate, NetworkErrorView* view);
32 ~ErrorScreen() override;
34 // NetworkErrorModel:
35 void PrepareToShow() override;
36 void Show() override;
37 void Hide() 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;
66 // Register a callback to be invoked when the user indicates that an attempt
67 // to connect to the network should be made.
68 ConnectRequestCallbackSubscription RegisterConnectRequestCallback(
69 const base::Closure& callback);
71 private:
72 // Default hide_closure for Hide().
73 void DefaultHideCallback();
75 // Handle user action to configure certificates.
76 void OnConfigureCerts();
78 // Handle user action to diagnose network configuration.
79 void OnDiagnoseButtonClicked();
81 // Handle user action to launch guest session from out-of-box.
82 void OnLaunchOobeGuestSession();
84 // Handle user action to launch Powerwash in case of
85 // Local State critical error.
86 void OnLocalStateErrorPowerwashButtonClicked();
88 // Handle uses action to reboot device.
89 void OnRebootButtonClicked();
91 // The user indicated to make an attempt to connect to the network.
92 void OnConnectRequested();
94 // Handles the response of an ownership check and starts the guest session if
95 // applicable.
96 void StartGuestSessionAfterOwnershipCheck(
97 DeviceSettingsService::OwnershipStatus ownership_status);
99 NetworkErrorView* view_;
101 scoped_ptr<LoginPerformer> guest_login_performer_;
103 // Proxy which manages showing of the window for captive portal entering.
104 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_;
106 // Network state informer used to keep error screen up.
107 scoped_refptr<NetworkStateInformer> network_state_informer_;
109 NetworkError::UIState ui_state_;
110 NetworkError::ErrorState error_state_;
112 OobeUI::Screen parent_screen_;
114 // Optional callback that is called when NetworkError screen is hidden.
115 scoped_ptr<base::Closure> on_hide_callback_;
117 // Callbacks to be invoked when a connection attempt is requested.
118 base::CallbackList<void()> connect_request_callbacks_;
120 base::WeakPtrFactory<ErrorScreen> weak_factory_;
122 DISALLOW_COPY_AND_ASSIGN(ErrorScreen);
125 } // namespace chromeos
127 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_H_