Home | History | Annotate | Download | only in enrollment
      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_ENROLLMENT_ENROLLMENT_SCREEN_ACTOR_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_ACTOR_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/callback_forward.h"
     12 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
     13 
     14 class GoogleServiceAuthError;
     15 
     16 namespace chromeos {
     17 
     18 // Interface class for the enterprise enrollment screen actor.
     19 class EnrollmentScreenActor {
     20  public:
     21   // Enumeration of the possible errors that can occur during enrollment which
     22   // are not covered by GoogleServiceAuthError or EnrollmentStatus.
     23   enum UIError {
     24     // Existing enrollment domain doesn't match authentication user.
     25     UI_ERROR_DOMAIN_MISMATCH,
     26     // Requested device mode not supported with auto enrollment.
     27     UI_ERROR_AUTO_ENROLLMENT_BAD_MODE,
     28     // Unexpected error condition, indicates a bug in the code.
     29     UI_ERROR_FATAL,
     30   };
     31 
     32   // This defines the interface for controllers which will be called back when
     33   // something happens on the UI.
     34   class Controller {
     35    public:
     36     virtual ~Controller() {}
     37 
     38     virtual void OnLoginDone(const std::string& user) = 0;
     39     virtual void OnAuthError(const GoogleServiceAuthError& error) = 0;
     40     virtual void OnOAuthTokenAvailable(const std::string& oauth_token) = 0;
     41     virtual void OnRetry() = 0;
     42     virtual void OnCancel() = 0;
     43     virtual void OnConfirmationClosed() = 0;
     44   };
     45 
     46   virtual ~EnrollmentScreenActor() {}
     47 
     48   // Initializes the actor with parameters.
     49   virtual void SetParameters(Controller* controller,
     50                              bool is_auto_enrollment,
     51                              bool can_exit_enrollment,
     52                              const std::string& user) = 0;
     53 
     54   // Prepare the contents to showing.
     55   virtual void PrepareToShow() = 0;
     56 
     57   // Shows the contents of the screen.
     58   virtual void Show() = 0;
     59 
     60   // Hides the contents of the screen.
     61   virtual void Hide() = 0;
     62 
     63   // Starts fetching the OAuth token.
     64   virtual void FetchOAuthToken() = 0;
     65 
     66   // Resets the authentication state and invokes the passed callback on
     67   // completion.
     68   virtual void ResetAuth(const base::Closure& callback) = 0;
     69 
     70   // Shows the signin screen.
     71   virtual void ShowSigninScreen() = 0;
     72 
     73   // Shows the spinner screen for enrollment.
     74   virtual void ShowEnrollmentSpinnerScreen() = 0;
     75 
     76   // Shows the spinner screen for login after auto-enrollment.
     77   virtual void ShowLoginSpinnerScreen() = 0;
     78 
     79   // Show an authentication error.
     80   virtual void ShowAuthError(const GoogleServiceAuthError& error) = 0;
     81 
     82   // Show non-authentication error.
     83   virtual void ShowUIError(UIError error) = 0;
     84 
     85   // Update the UI to report the |status| of the enrollment procedure.
     86   virtual void ShowEnrollmentStatus(policy::EnrollmentStatus status) = 0;
     87 };
     88 
     89 }  // namespace chromeos
     90 
     91 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_ACTOR_H_
     92