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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
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..c64001cc1fcbf3e9a440b3e6c3ce2718f77367e5
--- /dev/null
+++ b/chromeos/login/login_state.h
@@ -0,0 +1,78 @@
+// 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 {
+ LOGGED_IN_UNKNOWN,
+ LOGGED_IN_OOBE, // Out of box experience not completed
+ LOGGED_IN_NONE, // Not logged in
+ LOGGED_IN_LOCKED, // A user has locked the screen
+ LOGGED_IN_USER, // A normal user is logged in
+ LOGGED_IN_OWNER, // The owner of the device is logged in
+ LOGGED_IN_GUEST, // A guest is logged in (i.e. incognito)
+ LOGGED_IN_RETAIL_MODE, // Is in retail mode
+ LOGGED_IN_PUBLIC, // A public account is logged in
+ LOGGED_IN_LOCALLY_MANAGED, // A locally managed user is logged in
+ LOGGED_IN_KIOSK_APP // Is in kiosk app mode
+ };
+
+ class Observer {
+ public:
+ // Called when the login state changes.
+ virtual void LoginStateChanged(LoginState::State state) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ // Manage singleton instance. Must be initialized after DBusThreadManager.
+ static void Initialize();
+ static void Shutdown();
+ static LoginState* Get();
+
+ // 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 IsLoggedIn();
+
+ private:
+ LoginState();
+ virtual ~LoginState();
+
+ // SessionManagerClient::Observer
+ virtual void LockScreen() OVERRIDE;
+ virtual void UnlockScreen() OVERRIDE;
+
+ void NotifyObservers();
+
+ State state_;
+ bool screen_locked_;
+ ObserverList<LoginState::Observer> observer_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoginState);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_LOGIN_LOGIN_STATE_H_

Powered by Google App Engine
This is Rietveld 408576698