Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chromeos/login/login_state.h

Issue 13495003: Add LoginState class to src/chromeos/login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/login/login_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/observer_list.h"
10 #include "chromeos/chromeos_export.h"
11
12 namespace chromeos {
13
14 // Tracks the login state of chrome, accessible to Ash and other chromeos code.
15 class CHROMEOS_EXPORT LoginState {
16 public:
17 enum LoggedInState {
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
21 };
22
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
32 };
33
34 class Observer {
35 public:
36 // Called when the login state changes.
37 virtual void LoggedInStateChanged(LoggedInState state) = 0;
38
39 protected:
40 virtual ~Observer() {}
41 };
42
43 // Manage singleton instance.
44 static void Initialize();
45 static void Shutdown();
46 static LoginState* Get();
47 static bool IsInitialized();
48
49 // Add/remove observers.
50 void AddObserver(Observer* observer);
51 void RemoveObserver(Observer* observer);
52
53 // Set the logged in state and user type.
54 void SetLoggedInState(LoggedInState state, LoggedInUserType type);
55
56 // Get the logged in state / user type.
57 LoggedInState GetLoggedInState() const;
58 LoggedInUserType GetLoggedInUserType() const;
59
60 // Returns true if |logged_in_state_| is active.
61 bool IsUserLoggedIn() const;
62
63 // Returns true if the user is an authenticated user (i.e. non public account)
64 bool IsUserAuthenticated() const;
65
66 private:
67 LoginState();
68 virtual ~LoginState();
69
70 void NotifyObservers();
71
72 LoggedInState logged_in_state_;
73 LoggedInUserType logged_in_user_type_;
74 ObserverList<Observer> observer_list_;
75
76 DISALLOW_COPY_AND_ASSIGN(LoginState);
77 };
78
79 } // namespace chromeos
80
81 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_
OLDNEW
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/login/login_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698