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

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

Powered by Google App Engine
This is Rietveld 408576698