OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_NETWORK_ERROR_MODEL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_ERROR_MODEL_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 10 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 11 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 12 |
| 13 namespace base { |
| 14 class ListValue; |
| 15 } |
| 16 |
| 17 namespace chromeos { |
| 18 |
| 19 class BaseScreenDelegate; |
| 20 class NetworkErrorView; |
| 21 |
| 22 class NetworkErrorModel : public BaseScreen { |
| 23 public: |
| 24 static const char kContextKeyErrorStateCode[]; |
| 25 static const char kContextKeyErrorStateNetwork[]; |
| 26 static const char kContextKeyGuestSigninAllowed[]; |
| 27 static const char kContextKeyOfflineSigninAllowed[]; |
| 28 static const char kContextKeyShowConnectingIndicator[]; |
| 29 static const char kContextKeyUIState[]; |
| 30 static const char kUserActionConfigureCertsButtonClicked[]; |
| 31 static const char kUserActionDiagnoseButtonClicked[]; |
| 32 static const char kUserActionLaunchOobeGuestSessionClicked[]; |
| 33 static const char kUserActionLocalStateErrorPowerwashButtonClicked[]; |
| 34 static const char kUserActionRebootButtonClicked[]; |
| 35 static const char kUserActionShowCaptivePortalClicked[]; |
| 36 |
| 37 explicit NetworkErrorModel(BaseScreenDelegate* base_screen_delegate); |
| 38 ~NetworkErrorModel() override; |
| 39 |
| 40 NetworkError::UIState ui_state() const { return ui_state_; } |
| 41 NetworkError::ErrorState error_state() const { return error_state_; } |
| 42 |
| 43 // Returns id of the screen behind error screen ("caller" screen). |
| 44 // Returns OobeUI::SCREEN_UNKNOWN if error screen isn't the current |
| 45 // screen. |
| 46 OobeUI::Screen parent_screen() const { return parent_screen_; } |
| 47 |
| 48 // BaseScreen: |
| 49 std::string GetName() const override; |
| 50 void OnHide() override; |
| 51 |
| 52 // Toggles the guest sign-in prompt. |
| 53 virtual void AllowGuestSignin(bool allowed); |
| 54 |
| 55 // Toggles the offline sign-in. |
| 56 virtual void AllowOfflineLogin(bool allowed); |
| 57 |
| 58 // Initializes captive portal dialog and shows that if needed. |
| 59 virtual void FixCaptivePortal() = 0; |
| 60 |
| 61 // Called when we're asked to hide captive portal dialog. |
| 62 virtual void HideCaptivePortal() = 0; |
| 63 |
| 64 // This method is called, when view is being destroyed. Note, if model |
| 65 // is destroyed earlier then it has to call Unbind(). |
| 66 virtual void OnViewDestroyed(NetworkErrorView* view) = 0; |
| 67 |
| 68 // Sets current UI state. |
| 69 void SetUIState(NetworkError::UIState ui_state); |
| 70 |
| 71 // Sets current error screen content according to current UI state, |
| 72 // |error_state|, and |network|. |
| 73 void SetErrorState(NetworkError::ErrorState error_state, |
| 74 const std::string& network); |
| 75 |
| 76 // Sets "parent screen" i.e. one that has initiated this network error screen |
| 77 // instance. |
| 78 virtual void SetParentScreen(OobeUI::Screen parent_screen); |
| 79 |
| 80 // Sets callback that is called on hide. |
| 81 void SetHideCallback(const base::Closure& on_hide); |
| 82 |
| 83 // Shows captive portal dialog. |
| 84 virtual void ShowCaptivePortal() = 0; |
| 85 |
| 86 // Toggles the connection pending indicator. |
| 87 virtual void ShowConnectingIndicator(bool show); |
| 88 |
| 89 protected: |
| 90 base::Closure* on_hide_callback() { return on_hide_.get(); } |
| 91 |
| 92 private: |
| 93 NetworkError::UIState ui_state_; |
| 94 NetworkError::ErrorState error_state_; |
| 95 |
| 96 OobeUI::Screen parent_screen_; |
| 97 |
| 98 // Optional callback that is called when NetworkError screen is hidden. |
| 99 scoped_ptr<base::Closure> on_hide_; |
| 100 }; |
| 101 |
| 102 } // namespace chromeos |
| 103 |
| 104 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_NETWORK_ERROR_MODEL_H_ |
OLD | NEW |