Home | History | Annotate | Download | only in screens
      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_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_ACTOR_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_ACTOR_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "chrome/browser/chromeos/login/screens/error_screen.h"
     12 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
     13 
     14 namespace base {
     15 class DictionaryValue;
     16 }
     17 
     18 namespace chromeos {
     19 
     20 class ErrorScreenActor {
     21  public:
     22   // Possible network error reasons.
     23   enum ErrorReason {
     24     ERROR_REASON_PROXY_AUTH_CANCELLED = 0,
     25     ERROR_REASON_PROXY_AUTH_SUPPLIED,
     26     ERROR_REASON_PROXY_CONNECTION_FAILED,
     27     ERROR_REASON_PROXY_CONFIG_CHANGED,
     28     ERROR_REASON_LOADING_TIMEOUT,
     29     ERROR_REASON_PORTAL_DETECTED,
     30     // Reason for a case when default network has changed.
     31     ERROR_REASON_NETWORK_STATE_CHANGED,
     32     // Reason for a case when JS side requires error screen update.
     33     ERROR_REASON_UPDATE,
     34     ERROR_REASON_FRAME_ERROR
     35   };
     36 
     37   ErrorScreenActor();
     38   virtual ~ErrorScreenActor();
     39 
     40   ErrorScreen::UIState ui_state() const { return ui_state_; }
     41   ErrorScreen::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   // Shows the screen.
     49   virtual void Show(OobeDisplay::Screen parent_screen,
     50                     base::DictionaryValue* params) = 0;
     51 
     52   // Hides the screen.
     53   virtual void Hide() = 0;
     54 
     55   // Initializes captive portal dialog and shows that if needed.
     56   virtual void FixCaptivePortal() = 0;
     57 
     58   // Shows captive portal dialog.
     59   virtual void ShowCaptivePortal() = 0;
     60 
     61   // Hides captive portal dialog.
     62   virtual void HideCaptivePortal() = 0;
     63 
     64   virtual void SetUIState(ErrorScreen::UIState ui_state) = 0;
     65   virtual void SetErrorState(ErrorScreen::ErrorState error_state,
     66                              const std::string& network) = 0;
     67 
     68   virtual void AllowGuestSignin(bool allowed) = 0;
     69   virtual void AllowOfflineLogin(bool allowed) = 0;
     70 
     71   static const char* ErrorReasonString(ErrorReason reason);
     72 
     73  protected:
     74   ErrorScreen::UIState ui_state_;
     75   ErrorScreen::ErrorState error_state_;
     76   std::string network_;
     77   bool guest_signin_allowed_;
     78   bool offline_login_allowed_;
     79 
     80   OobeUI::Screen parent_screen_;
     81 
     82   DISALLOW_COPY_AND_ASSIGN(ErrorScreenActor);
     83 };
     84 
     85 }  // namespace chromeos
     86 
     87 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_ERROR_SCREEN_ACTOR_H_
     88