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

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: . 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
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/observer_list.h"
9 #include "chromeos/chromeos_export.h"
10 #include "chromeos/dbus/session_manager_client.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 : public SessionManagerClient::Observer {
16 public:
17 enum State {
18 LOGGED_IN_UNKNOWN,
19 LOGGED_IN_OOBE, // Out of box experience not completed
20 LOGGED_IN_NONE, // Not logged in
21 LOGGED_IN_LOCKED, // A user has locked the screen
22 LOGGED_IN_USER, // A normal user is logged in
23 LOGGED_IN_OWNER, // The owner of the device is logged in
24 LOGGED_IN_GUEST, // A guest is logged in (i.e. incognito)
25 LOGGED_IN_RETAIL_MODE, // Is in retail mode
26 LOGGED_IN_PUBLIC, // A public account is logged in
27 LOGGED_IN_LOCALLY_MANAGED, // A locally managed user is logged in
28 LOGGED_IN_KIOSK_APP // Is in kiosk app mode
29 };
30
31 class Observer {
32 public:
33 // Called when the login state changes.
34 virtual void LoginStateChanged(LoginState::State state) = 0;
35
36 protected:
37 virtual ~Observer() {}
38 };
39
40 // Manage singleton instance. Must be initialized after DBusThreadManager.
41 static void Initialize();
42 static void Shutdown();
43 static LoginState* Get();
44
45 // Add/remove observers.
46 void AddObserver(Observer* observer);
47 void RemoveObserver(Observer* observer);
48
49 // Set the base login state to |state|. Note, other factors (e.g. screen lock)
50 // may affect the result of GetLoginState().
51 void SetLoginState(LoginState::State state);
52
53 // Returns the current login state.
54 LoginState::State GetLoginState() const;
55
56 // Returns true if |state_| is a logged in state.
57 bool IsLoggedIn();
58
59 private:
60 LoginState();
61 virtual ~LoginState();
62
63 // SessionManagerClient::Observer
64 virtual void LockScreen() OVERRIDE;
65 virtual void UnlockScreen() OVERRIDE;
66
67 void NotifyObservers();
68
69 State state_;
70 bool screen_locked_;
71 ObserverList<LoginState::Observer> observer_list_;
72
73 DISALLOW_COPY_AND_ASSIGN(LoginState);
74 };
75
76 } // namespace chromeos
77
78 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698