Chromium Code Reviews| Index: chromeos/login/login_state.h |
| diff --git a/chromeos/login/login_state.h b/chromeos/login/login_state.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7e23253d6f3064b9a703a9ed6bbb4594375c48ab |
| --- /dev/null |
| +++ b/chromeos/login/login_state.h |
| @@ -0,0 +1,82 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_ |
| +#define CHROMEOS_LOGIN_LOGIN_STATE_H_ |
| + |
| +#include "base/observer_list.h" |
| +#include "chromeos/chromeos_export.h" |
| +#include "chromeos/dbus/session_manager_client.h" |
| + |
| +namespace chromeos { |
| + |
| +// Tracks the login state of chrome, accessible to Ash and other chromeos code. |
| +class CHROMEOS_EXPORT LoginState : public SessionManagerClient::Observer { |
| + public: |
| + enum State { |
|
bartfab (slow)
2013/04/05 13:16:33
1/ This is essentially a redefinition of ash::user
|
| + 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
|
| + 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
|
| + LOGGED_IN_LOCKED, // A user has locked the screen |
| + 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.
|
| + LOGGED_IN_OWNER, // The owner of the device is logged in |
| + 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
|
| + 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
|
| + 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
|
| + 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
|
| + }; |
| + |
| + class Observer { |
| + public: |
| + // Called when the login state changes. |
| + 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.
|
| + |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + |
| + // Manage singleton instance. Must be initialized after DBusThreadManager. |
| + static void Initialize(); |
| + static void Shutdown(); |
| + 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
|
| + static bool IsInitialized(); |
| + |
| + // Add/remove observers. |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + // Set the base login state to |state|. Note, other factors (e.g. screen lock) |
| + // may affect the result of GetLoginState(). |
| + void SetLoginState(LoginState::State state); |
| + |
| + // Returns the current login state. |
| + LoginState::State GetLoginState() const; |
| + |
| + // Returns true if |state_| is a logged in state. |
| + bool IsUserLoggedIn(); |
| + |
| + // 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.
|
| + void SetSessionStarted(bool session_started); |
| + bool IsSessionStarted() const; |
| + |
| + private: |
| + LoginState(); |
| + virtual ~LoginState(); |
| + |
| + // 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
|
| + 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.
|
| + virtual void UnlockScreen() OVERRIDE; |
| + |
| + void NotifyObservers(); |
| + |
| + State state_; |
| + bool session_started_; |
| + bool screen_locked_; |
| + 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.
|
| + |
| + 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.
|
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ |