1 // Copyright (c) 2013 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.
5 #ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_
6 #define CHROMEOS_LOGIN_LOGIN_STATE_H_
8 #include "base/basictypes.h"
9 #include "base/observer_list.h"
10 #include "chromeos/chromeos_export.h"
14 // Tracks the login state of chrome, accessible to Ash and other chromeos code.
15 class CHROMEOS_EXPORT LoginState
{
18 LOGGED_IN_OOBE
, // Out of box experience not completed
19 LOGGED_IN_NONE
, // Not logged in
20 LOGGED_IN_ACTIVE
// A user has logged in
23 enum LoggedInUserType
{
24 LOGGED_IN_USER_NONE
, // User is not logged in
25 LOGGED_IN_USER_REGULAR
, // A regular user is logged in
26 LOGGED_IN_USER_OWNER
, // The owner of the device is logged in
27 LOGGED_IN_USER_GUEST
, // A guest is logged in (i.e. incognito)
28 LOGGED_IN_USER_RETAIL_MODE
, // Is in retail mode
29 LOGGED_IN_USER_PUBLIC_ACCOUNT
, // A public account is logged in
30 LOGGED_IN_USER_LOCALLY_MANAGED
, // A locally managed user is logged in
31 LOGGED_IN_USER_KIOSK_APP
// Is in kiosk app mode
36 // Called when the login state changes.
37 virtual void LoggedInStateChanged(LoggedInState state
) = 0;
40 virtual ~Observer() {}
43 // Manage singleton instance.
44 static void Initialize();
45 static void Shutdown();
46 static LoginState
* Get();
47 static bool IsInitialized();
49 // Add/remove observers.
50 void AddObserver(Observer
* observer
);
51 void RemoveObserver(Observer
* observer
);
53 // Set the logged in state and user type.
54 void SetLoggedInState(LoggedInState state
, LoggedInUserType type
);
56 // Get the logged in state / user type.
57 LoggedInState
GetLoggedInState() const;
58 LoggedInUserType
GetLoggedInUserType() const;
60 // Returns true if |logged_in_state_| is active.
61 bool IsUserLoggedIn() const;
63 // Returns true if logged in and is a guest, retail, public, or kiosk user.
64 bool IsGuestUser() const;
66 // Returns true if the user is an authenticated user (i.e. non public account)
67 bool IsUserAuthenticated() const;
69 // Returns true if the user is authenticated by logging into Google account
70 // (i.e., non public nor locally managed account).
71 bool IsUserGaiaAuthenticated() const;
75 virtual ~LoginState();
77 void NotifyObservers();
79 LoggedInState logged_in_state_
;
80 LoggedInUserType logged_in_user_type_
;
81 ObserverList
<Observer
> observer_list_
;
83 DISALLOW_COPY_AND_ASSIGN(LoginState
);
86 } // namespace chromeos
88 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_