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   // Describes the enrollment mode.  Must be kept in sync with
     33   // |kEnrollmentModes| in enrollment_screen_handler.cc.
     34   enum EnrollmentMode {
     35     ENROLLMENT_MODE_MANUAL,    // Manually triggered enrollment.
     36     ENROLLMENT_MODE_FORCED,    // Forced enrollment, user can't skip.
     37     ENROLLMENT_MODE_AUTO,      // Auto-enrollment during first sign-in.
     38     ENROLLMENT_MODE_RECOVERY,  // Recover from "spontaneous unenrollment".
     39     ENROLLMENT_MODE_COUNT      // Counter must be last. Not an enrollment mode.
     40   };
     41 
     42   // This defines the interface for controllers which will be called back when
     43   // something happens on the UI.
     44   class Controller {
     45    public:
     46     virtual ~Controller() {}
     47 
     48     virtual void OnLoginDone(const std::string& user) = 0;
     49     virtual void OnAuthError(const GoogleServiceAuthError& error) = 0;
     50     virtual void OnOAuthTokenAvailable(const std::string& oauth_token) = 0;
     51     virtual void OnRetry() = 0;
     52     virtual void OnCancel() = 0;
     53     virtual void OnConfirmationClosed() = 0;
     54   };
     55 
     56   virtual ~EnrollmentScreenActor() {}
     57 
     58   // Initializes the actor with parameters.
     59   virtual void SetParameters(Controller* controller,
     60                              EnrollmentMode enrollment_mode,
     61                              const std::string& management_domain) = 0;
     62 
     63   // Prepare the contents to showing.
     64   virtual void PrepareToShow() = 0;
     65 
     66   // Shows the contents of the screen.
     67   virtual void Show() = 0;
     68 
     69   // Hides the contents of the screen.
     70   virtual void Hide() = 0;
     71 
     72   // Starts fetching the OAuth token.
     73   virtual void FetchOAuthToken() = 0;
     74 
     75   // Resets the authentication state and invokes the passed callback on
     76   // completion.
     77   virtual void ResetAuth(const base::Closure& callback) = 0;
     78 
     79   // Shows the signin screen.
     80   virtual void ShowSigninScreen() = 0;
     81 
     82   // Shows the spinner screen for enrollment.
     83   virtual void ShowEnrollmentSpinnerScreen() = 0;
     84 
     85   // Shows the spinner screen for login after auto-enrollment.
     86   virtual void ShowLoginSpinnerScreen() = 0;
     87 
     88   // Show an authentication error.
     89   virtual void ShowAuthError(const GoogleServiceAuthError& error) = 0;
     90 
     91   // Show non-authentication error.
     92   virtual void ShowUIError(UIError error) = 0;
     93 
     94   // Update the UI to report the |status| of the enrollment procedure.
     95   virtual void ShowEnrollmentStatus(policy::EnrollmentStatus status) = 0;
     96 };
     97 
     98 }  // namespace chromeos
     99 
    100 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_ACTOR_H_
    101