OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_ | 5 #ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_ |
6 #define CHROMEOS_LOGIN_LOGIN_STATE_H_ | 6 #define CHROMEOS_LOGIN_LOGIN_STATE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "chromeos/chromeos_export.h" | 10 #include "chromeos/chromeos_export.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 | 13 |
14 // Tracks the login state of chrome, accessible to Ash and other chromeos code. | 14 // Tracks the login state of chrome, accessible to Ash and other chromeos code. |
15 class CHROMEOS_EXPORT LoginState { | 15 class CHROMEOS_EXPORT LoginState { |
16 public: | 16 public: |
17 enum LoggedInState { | 17 enum LoggedInState { |
18 LOGGED_IN_OOBE, // Out of box experience not completed | 18 LOGGED_IN_OOBE, // Out of box experience not completed |
19 LOGGED_IN_NONE, // Not logged in | 19 LOGGED_IN_NONE, // Not logged in |
20 LOGGED_IN_ACTIVE // A user has logged in | 20 LOGGED_IN_SAFE_MODE, // Not logged in and login not allowed for non-owners |
21 LOGGED_IN_ACTIVE // A user has logged in | |
21 }; | 22 }; |
22 | 23 |
23 enum LoggedInUserType { | 24 enum LoggedInUserType { |
24 LOGGED_IN_USER_NONE, // User is not logged in | 25 LOGGED_IN_USER_NONE, // User is not logged in |
25 LOGGED_IN_USER_REGULAR, // A regular user is logged in | 26 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_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_GUEST, // A guest is logged in (i.e. incognito) |
28 LOGGED_IN_USER_RETAIL_MODE, // Is in retail mode | 29 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_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_LOCALLY_MANAGED, // A locally managed user is logged in |
31 LOGGED_IN_USER_KIOSK_APP // Is in kiosk app mode | 32 LOGGED_IN_USER_KIOSK_APP // Is in kiosk app mode |
32 }; | 33 }; |
33 | 34 |
34 class Observer { | 35 class Observer { |
35 public: | 36 public: |
36 // Called when the login state changes. | 37 // Called when the login state changes. |
37 virtual void LoggedInStateChanged(LoggedInState state) = 0; | 38 virtual void LoggedInStateChanged() = 0; |
38 | 39 |
39 protected: | 40 protected: |
40 virtual ~Observer() {} | 41 virtual ~Observer() {} |
41 }; | 42 }; |
42 | 43 |
43 // Manage singleton instance. | 44 // Manage singleton instance. |
44 static void Initialize(); | 45 static void Initialize(); |
45 static void Shutdown(); | 46 static void Shutdown(); |
46 static LoginState* Get(); | 47 static LoginState* Get(); |
47 static bool IsInitialized(); | 48 static bool IsInitialized(); |
48 | 49 |
49 // Add/remove observers. | 50 // Add/remove observers. |
50 void AddObserver(Observer* observer); | 51 void AddObserver(Observer* observer); |
51 void RemoveObserver(Observer* observer); | 52 void RemoveObserver(Observer* observer); |
52 | 53 |
53 // Set the logged in state and user type. | 54 // Set the logged in state and user type. |
54 void SetLoggedInState(LoggedInState state, LoggedInUserType type); | 55 void SetLoggedInState(LoggedInState state, LoggedInUserType type); |
55 | 56 |
56 // Get the logged in state / user type. | 57 // Get the logged in user type. |
57 LoggedInState GetLoggedInState() const; | |
58 LoggedInUserType GetLoggedInUserType() const; | 58 LoggedInUserType GetLoggedInUserType() const; |
59 | 59 |
60 // Returns true if |logged_in_state_| is active. | 60 // Returns true if an user is considered to be logged in. |
stevenjb
2013/09/12 00:48:01
nit: 'a user' (English sucks)
tbarzic
2013/09/12 01:18:12
:)
| |
61 bool IsUserLoggedIn() const; | 61 bool IsUserLoggedIn() const; |
62 | 62 |
63 // Returns true if |logged_in_state_| is safe mode (i.e. the user is not yet | |
64 // logged in, and only the owner will be allowed to log in). | |
65 bool IsInSafeMode() const; | |
66 | |
63 // Returns true if logged in and is a guest, retail, public, or kiosk user. | 67 // Returns true if logged in and is a guest, retail, public, or kiosk user. |
64 bool IsGuestUser() const; | 68 bool IsGuestUser() const; |
65 | 69 |
66 // Returns true if the user is an authenticated user (i.e. non public account) | 70 // Returns true if the user is an authenticated user (i.e. non public account) |
67 bool IsUserAuthenticated() const; | 71 bool IsUserAuthenticated() const; |
68 | 72 |
69 // Returns true if the user is authenticated by logging into Google account | 73 // Returns true if the user is authenticated by logging into Google account |
70 // (i.e., non public nor locally managed account). | 74 // (i.e., non public nor locally managed account). |
71 bool IsUserGaiaAuthenticated() const; | 75 bool IsUserGaiaAuthenticated() const; |
72 | 76 |
73 private: | 77 private: |
74 LoginState(); | 78 LoginState(); |
75 virtual ~LoginState(); | 79 virtual ~LoginState(); |
76 | 80 |
77 void NotifyObservers(); | 81 void NotifyObservers(); |
78 | 82 |
79 LoggedInState logged_in_state_; | 83 LoggedInState logged_in_state_; |
80 LoggedInUserType logged_in_user_type_; | 84 LoggedInUserType logged_in_user_type_; |
81 ObserverList<Observer> observer_list_; | 85 ObserverList<Observer> observer_list_; |
82 | 86 |
83 DISALLOW_COPY_AND_ASSIGN(LoginState); | 87 DISALLOW_COPY_AND_ASSIGN(LoginState); |
84 }; | 88 }; |
85 | 89 |
86 } // namespace chromeos | 90 } // namespace chromeos |
87 | 91 |
88 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ | 92 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ |
OLD | NEW |