Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_ | |
| 6 #define CHROMEOS_LOGIN_LOGIN_STATE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/observer_list.h" | |
| 11 #include "chromeos/chromeos_export.h" | |
| 12 | |
| 13 namespace chromeos { | |
| 14 | |
| 15 // Tracks the login state of chrome, accessible to Ash and other chromeos code. | |
| 16 class CHROMEOS_EXPORT LoginState { | |
| 17 public: | |
| 18 enum LoggedInState { | |
| 19 LOGGED_IN_OOBE, // Out of box experience not completed | |
| 20 LOGGED_IN_NONE, // Not logged in | |
| 21 LOGGED_IN_ACTIVE // A user has logged in | |
|
Nikita (slow)
2013/04/10 08:09:22
I like that it is now called "active". In my multi
stevenjb
2013/04/10 16:32:17
Good to hear. I struggled with the name for a bit;
| |
| 22 }; | |
| 23 | |
| 24 enum LoggedInUserType { | |
| 25 LOGGED_IN_USER_NONE, // User is not logged in | |
| 26 LOGGED_IN_USER_REGULAR, // A regular user is logged in | |
| 27 LOGGED_IN_USER_OWNER, // The owner of the device is logged in | |
| 28 LOGGED_IN_USER_GUEST, // A guest is logged in (i.e. incognito) | |
| 29 LOGGED_IN_USER_RETAIL_MODE, // Is in retail mode | |
| 30 LOGGED_IN_USER_PUBLIC_ACCOUNT, // A public account is logged in | |
| 31 LOGGED_IN_USER_LOCALLY_MANAGED, // A locally managed user is logged in | |
| 32 LOGGED_IN_USER_KIOSK_APP // Is in kiosk app mode | |
| 33 }; | |
| 34 | |
| 35 class Observer { | |
| 36 public: | |
| 37 // Called when the login state changes. | |
| 38 virtual void LoggedInStateChanged(LoggedInState state) = 0; | |
| 39 | |
| 40 protected: | |
| 41 virtual ~Observer() {} | |
| 42 }; | |
| 43 | |
| 44 // Manage singleton instance. | |
| 45 static void Initialize(); | |
| 46 static void Shutdown(); | |
| 47 static LoginState* Get(); | |
| 48 static bool IsInitialized(); | |
| 49 | |
| 50 // Add/remove observers. | |
| 51 void AddObserver(Observer* observer); | |
| 52 void RemoveObserver(Observer* observer); | |
| 53 | |
| 54 // Set the logged in state and user type. | |
| 55 void SetLoggedInState(LoggedInState state, LoggedInUserType type); | |
| 56 | |
| 57 // Get the logged in state / user type. | |
| 58 LoggedInState GetLoggedInState() const; | |
| 59 LoggedInUserType GetLoggedInUserType() const; | |
| 60 | |
| 61 // Returns true if |logged_in_state_| is active. | |
| 62 bool IsUserLoggedIn() const; | |
| 63 | |
| 64 private: | |
| 65 LoginState(); | |
| 66 virtual ~LoginState(); | |
| 67 | |
| 68 void NotifyObservers(); | |
| 69 | |
| 70 LoggedInState logged_in_state_; | |
| 71 LoggedInUserType logged_in_user_type_; | |
| 72 ObserverList<Observer> observer_list_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(LoginState); | |
| 75 }; | |
| 76 | |
| 77 } // namespace chromeos | |
| 78 | |
| 79 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ | |
| OLD | NEW |