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

Side by Side Diff: chromeos/login/login_state.h

Issue 24072006: Return correct window when user is logged in but before session is started. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit test compile error Created 7 years, 3 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_ 5 #ifndef CHROMEOS_LOGIN_LOGIN_STATE_H_
6 #define CHROMEOS_LOGIN_LOGIN_STATE_H_ 6 #define CHROMEOS_LOGIN_LOGIN_STATE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "chromeos/chromeos_export.h" 10 #include "chromeos/chromeos_export.h"
(...skipping 16 matching lines...) Expand all
27 LOGGED_IN_USER_GUEST, // A guest is logged in (i.e. incognito) 27 LOGGED_IN_USER_GUEST, // A guest is logged in (i.e. incognito)
28 LOGGED_IN_USER_RETAIL_MODE, // Is in retail mode 28 LOGGED_IN_USER_RETAIL_MODE, // Is in retail mode
29 LOGGED_IN_USER_PUBLIC_ACCOUNT, // A public account is logged in 29 LOGGED_IN_USER_PUBLIC_ACCOUNT, // A public account is logged in
30 LOGGED_IN_USER_LOCALLY_MANAGED, // A locally managed user is logged in 30 LOGGED_IN_USER_LOCALLY_MANAGED, // A locally managed user is logged in
31 LOGGED_IN_USER_KIOSK_APP // Is in kiosk app mode 31 LOGGED_IN_USER_KIOSK_APP // Is in kiosk app mode
32 }; 32 };
33 33
34 class Observer { 34 class Observer {
35 public: 35 public:
36 // Called when either the login state or the logged in user type changes. 36 // Called when either the login state or the logged in user type changes.
37 // TODO(tengs): Should we notify the observer when the session is started?
37 virtual void LoggedInStateChanged(LoggedInState state) = 0; 38 virtual void LoggedInStateChanged(LoggedInState state) = 0;
38 39
39 protected: 40 protected:
40 virtual ~Observer() {} 41 virtual ~Observer() {}
41 }; 42 };
42 43
43 // Manage singleton instance. 44 // Manage singleton instance.
44 static void Initialize(); 45 static void Initialize();
45 static void Shutdown(); 46 static void Shutdown();
46 static LoginState* Get(); 47 static LoginState* Get();
47 static bool IsInitialized(); 48 static bool IsInitialized();
48 49
49 // Add/remove observers. 50 // Add/remove observers.
50 void AddObserver(Observer* observer); 51 void AddObserver(Observer* observer);
51 void RemoveObserver(Observer* observer); 52 void RemoveObserver(Observer* observer);
52 53
53 // Set the logged in state and user type. 54 // Set the logged in state and user type.
54 void SetLoggedInState(LoggedInState state, LoggedInUserType type); 55 void SetLoggedInState(LoggedInState state, LoggedInUserType type);
55 56
57 // Set whether the browser session is started.
58 void SetSessionStarted(bool session_started);
59
56 // Get the logged in state / user type. 60 // Get the logged in state / user type.
57 LoggedInState GetLoggedInState() const; 61 LoggedInState GetLoggedInState() const;
58 LoggedInUserType GetLoggedInUserType() const; 62 LoggedInUserType GetLoggedInUserType() const;
59 63
60 // Returns true if |logged_in_state_| is active. 64 // Returns true if |logged_in_state_| is active.
61 bool IsUserLoggedIn() const; 65 bool IsUserLoggedIn() const;
62 66
63 // Returns true if logged in and is a guest, retail, public, or kiosk user. 67 // Returns true if logged in and is a guest, retail, public, or kiosk user.
64 bool IsGuestUser() const; 68 bool IsGuestUser() const;
65 69
66 // Returns true if the user is an authenticated user (i.e. non public account) 70 // Returns true if the user is an authenticated user (i.e. non public account)
67 bool IsUserAuthenticated() const; 71 bool IsUserAuthenticated() const;
68 72
69 // Returns true if the user is authenticated by logging into Google account 73 // Returns true if the user is authenticated by logging into Google account
70 // (i.e., non public nor locally managed account). 74 // (i.e., non public nor locally managed account).
71 bool IsUserGaiaAuthenticated() const; 75 bool IsUserGaiaAuthenticated() const;
72 76
77 // Returns true if the browser session is started. User login occurs before
78 // the session starts. Some procedures can take place during this iterval,
79 // so we need to provide this distinction.
80 bool IsSessionStarted() const;
81
73 private: 82 private:
74 LoginState(); 83 LoginState();
75 virtual ~LoginState(); 84 virtual ~LoginState();
76 85
77 void NotifyObservers(); 86 void NotifyObservers();
78 87
79 LoggedInState logged_in_state_; 88 LoggedInState logged_in_state_;
80 LoggedInUserType logged_in_user_type_; 89 LoggedInUserType logged_in_user_type_;
90 bool session_started_;
81 ObserverList<Observer> observer_list_; 91 ObserverList<Observer> observer_list_;
82 92
83 DISALLOW_COPY_AND_ASSIGN(LoginState); 93 DISALLOW_COPY_AND_ASSIGN(LoginState);
84 }; 94 };
85 95
86 } // namespace chromeos 96 } // namespace chromeos
87 97
88 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ 98 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698