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_UI_WEBUI_CHROMEOS_LOGIN_ERROR_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ERROR_SCREEN_HANDLER_H_ 7 8 #include "base/cancelable_callback.h" 9 #include "base/compiler_specific.h" 10 #include "base/memory/ref_counted.h" 11 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" 12 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 13 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" 14 15 namespace base { 16 class DictionaryValue; 17 } 18 19 namespace chromeos { 20 21 class CaptivePortalWindowProxy; 22 class NativeWindowDelegate; 23 class NetworkStateInformer; 24 25 // A class that handles the WebUI hooks in error screen. 26 class ErrorScreenHandler : public BaseScreenHandler, 27 public ErrorScreenActor { 28 public: 29 ErrorScreenHandler( 30 const scoped_refptr<NetworkStateInformer>& network_state_informer); 31 virtual ~ErrorScreenHandler(); 32 33 // ErrorScreenActor implementation: 34 virtual void SetDelegate(ErrorScreenActorDelegate* delegate) OVERRIDE; 35 virtual void Show(OobeDisplay::Screen parent_screen, 36 base::DictionaryValue* params) OVERRIDE; 37 virtual void Show(OobeDisplay::Screen parent_screen, 38 base::DictionaryValue* params, 39 const base::Closure& on_hide) OVERRIDE; 40 virtual void Hide() OVERRIDE; 41 virtual void FixCaptivePortal() OVERRIDE; 42 virtual void ShowCaptivePortal() OVERRIDE; 43 virtual void HideCaptivePortal() OVERRIDE; 44 virtual void SetUIState(ErrorScreen::UIState ui_state) OVERRIDE; 45 virtual void SetErrorState(ErrorScreen::ErrorState error_state, 46 const std::string& network) OVERRIDE; 47 virtual void AllowGuestSignin(bool allowed) OVERRIDE; 48 virtual void AllowOfflineLogin(bool allowed) OVERRIDE; 49 virtual void ShowConnectingIndicator(bool show) OVERRIDE; 50 51 private: 52 // Sends notification that error message is shown. 53 void NetworkErrorShown(); 54 55 bool GetScreenName(OobeUI::Screen screen, std::string* name) const; 56 57 // Default hide_closure for Show/Hide. 58 void CheckAndShowScreen(); 59 60 // WebUI message handlers. 61 void HandleShowCaptivePortal(); 62 void HandleHideCaptivePortal(); 63 void HandleLocalStateErrorPowerwashButtonClicked(); 64 void HandleRebootButtonClicked(); 65 void HandleDiagnoseButtonClicked(); 66 void HandleConfigureCerts(); 67 void HandleLaunchOobeGuestSession(); 68 69 // WebUIMessageHandler implementation: 70 virtual void RegisterMessages() OVERRIDE; 71 72 // BaseScreenHandler implementation: 73 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE; 74 virtual void Initialize() OVERRIDE; 75 76 // Non-owning ptr. 77 ErrorScreenActorDelegate* delegate_; 78 79 // Proxy which manages showing of the window for captive portal entering. 80 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_; 81 82 // Network state informer used to keep error screen up. 83 scoped_refptr<NetworkStateInformer> network_state_informer_; 84 85 // NativeWindowDelegate used to get reference to NativeWindow. 86 NativeWindowDelegate* native_window_delegate_; 87 88 // Keeps whether screen should be shown right after initialization. 89 bool show_on_init_; 90 91 scoped_ptr<base::Closure> on_hide_; 92 93 base::WeakPtrFactory<ErrorScreenHandler> weak_ptr_factory_; 94 95 DISALLOW_COPY_AND_ASSIGN(ErrorScreenHandler); 96 }; 97 98 } // namespace chromeos 99 100 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ERROR_SCREEN_HANDLER_H_ 101