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

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: Feedback round 1 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 {
bartfab (slow) 2013/04/05 13:16:33 1/ This is essentially a redefinition of ash::user
18 LOGGED_IN_OOBE, // Out of box experience not completed
bartfab (slow) 2013/04/05 13:16:33 Full stops missing at the ends of all comments.
stevenjb 2013/04/05 18:17:15 Not a requirement. This is a phrase not a sentence
bartfab (slow) 2013/04/08 15:18:36 True, not required by the style guide but generall
19 LOGGED_IN_NONE, // Not logged in
bartfab (slow) 2013/04/05 13:16:33 Nit: A better comment would be "No session in prog
stevenjb 2013/04/05 18:17:15 I'm not sure if that level of detail helps us here
20 LOGGED_IN_LOCKED, // A user has locked the screen
21 LOGGED_IN_USER, // A normal user is logged in
Nikita (slow) 2013/04/05 04:08:53 nit: normal > regular To match naming that we have
stevenjb 2013/04/05 18:17:15 Done.
22 LOGGED_IN_OWNER, // The owner of the device is logged in
23 LOGGED_IN_GUEST, // A guest is logged in (i.e. incognito)
bartfab (slow) 2013/04/05 13:16:33 Nit: A better comment would be "Guest session in p
24 LOGGED_IN_RETAIL_MODE, // Is in retail mode
bartfab (slow) 2013/04/05 13:16:33 Nit: I presume that this constant means a retail m
25 LOGGED_IN_PUBLIC, // A public account is logged in
bartfab (slow) 2013/04/05 13:16:33 Nit: A better comment would be "Public session in
26 LOGGED_IN_KIOSK_APP // Is in kiosk app mode
bartfab (slow) 2013/04/05 13:16:33 Nit: I presume that this constant means a kiosk ap
stevenjb 2013/04/05 18:17:15 All of the above seem like good candidates for fut
27 };
28
29 class Observer {
30 public:
31 // Called when the login state changes.
32 virtual void LoginStateChanged(LoginState::State state) = 0;
bartfab (slow) 2013/04/05 13:16:33 Nit: No need for the |LoginState::| prefix here.
stevenjb 2013/04/05 18:17:15 Done.
33
34 protected:
35 virtual ~Observer() {}
36 };
37
38 // Manage singleton instance. Must be initialized after DBusThreadManager.
39 static void Initialize();
40 static void Shutdown();
41 static LoginState* Get();
bartfab (slow) 2013/04/05 13:16:33 One of the goals for our upcoming hackathon is to
stevenjb 2013/04/05 18:17:15 Implicit singletons are bad. We use explicit singl
42 static bool IsInitialized();
43
44 // Add/remove observers.
45 void AddObserver(Observer* observer);
46 void RemoveObserver(Observer* observer);
47
48 // Set the base login state to |state|. Note, other factors (e.g. screen lock)
49 // may affect the result of GetLoginState().
50 void SetLoginState(LoginState::State state);
51
52 // Returns the current login state.
53 LoginState::State GetLoginState() const;
54
55 // Returns true if |state_| is a logged in state.
56 bool IsUserLoggedIn();
57
58 // Tracks wherther the user is logged in and the browser process has started.
Nikita (slow) 2013/04/05 04:08:53 Browser instance has been created to be more speci
stevenjb 2013/04/05 18:17:15 Done.
59 void SetSessionStarted(bool session_started);
60 bool IsSessionStarted() const;
61
62 private:
63 LoginState();
64 virtual ~LoginState();
65
66 // SessionManagerClient::Observer
bartfab (slow) 2013/04/05 13:16:33 Nit: Full stop or colon at the end of line.
stevenjb 2013/04/05 18:17:15 We use this pattern throughout the code for label
67 virtual void LockScreen() OVERRIDE;
bartfab (slow) 2013/04/05 13:16:33 #include "base/compiler_specific.h"
stevenjb 2013/04/05 18:17:15 Done.
68 virtual void UnlockScreen() OVERRIDE;
69
70 void NotifyObservers();
71
72 State state_;
73 bool session_started_;
74 bool screen_locked_;
75 ObserverList<LoginState::Observer> observer_list_;
bartfab (slow) 2013/04/05 13:16:33 Nit: No need for the |LoginState::| prefix here.
stevenjb 2013/04/05 18:17:15 Done.
76
77 DISALLOW_COPY_AND_ASSIGN(LoginState);
bartfab (slow) 2013/04/05 13:16:33 #include "base/basictypes.h"
stevenjb 2013/04/05 18:17:15 Done.
78 };
79
80 } // namespace chromeos
81
82 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698