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

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: Address feedback 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 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..73cc94dabd0deedeac81b5ae124d6bd0ea03140e
--- /dev/null
+++ b/chromeos/login/login_state.h
@@ -0,0 +1,79 @@
+// 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/basictypes.h"
+#include "base/compiler_specific.h"
bartfab (slow) 2013/04/10 18:51:20 Nit: Where is this used?
stevenjb 2013/04/10 20:46:41 Done.
+#include "base/observer_list.h"
+#include "chromeos/chromeos_export.h"
+
+namespace chromeos {
+
+// Tracks the login state of chrome, accessible to Ash and other chromeos code.
+class CHROMEOS_EXPORT LoginState {
+ public:
+ enum LoggedInState {
+ LOGGED_IN_OOBE, // Out of box experience not completed
+ LOGGED_IN_NONE, // Not logged in
+ LOGGED_IN_ACTIVE // A user has logged in
+ };
+
+ enum LoggedInUserType {
+ LOGGED_IN_USER_NONE, // User is not logged in
+ LOGGED_IN_USER_REGULAR, // A regular user is logged in
+ LOGGED_IN_USER_OWNER, // The owner of the device is logged in
+ LOGGED_IN_USER_GUEST, // A guest is logged in (i.e. incognito)
+ LOGGED_IN_USER_RETAIL_MODE, // Is in retail mode
+ LOGGED_IN_USER_PUBLIC_ACCOUNT, // A public account is logged in
+ LOGGED_IN_USER_LOCALLY_MANAGED, // A locally managed user is logged in
+ LOGGED_IN_USER_KIOSK_APP // Is in kiosk app mode
+ };
+
+ class Observer {
+ public:
+ // Called when the login state changes.
+ virtual void LoggedInStateChanged(LoggedInState state) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ // Manage singleton instance.
+ static void Initialize();
+ static void Shutdown();
+ static LoginState* Get();
+ static bool IsInitialized();
+
+ // Add/remove observers.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ // Set the logged in state and user type.
+ void SetLoggedInState(LoggedInState state, LoggedInUserType type);
+
+ // Get the logged in state / user type.
+ LoggedInState GetLoggedInState() const;
+ LoggedInUserType GetLoggedInUserType() const;
+
+ // Returns true if |logged_in_state_| is active.
+ bool IsUserLoggedIn() const;
+
+ private:
+ LoginState();
+ virtual ~LoginState();
+
+ void NotifyObservers();
+
+ LoggedInState logged_in_state_;
+ LoggedInUserType logged_in_user_type_;
+ ObserverList<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