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

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

Issue 242983004: Disable some API calls in networkingPrivate for non-primary user (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fail to configure networks from non-primary user Created 6 years, 6 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // Manage singleton instance. 44 // Manage singleton instance.
45 static void Initialize(); 45 static void Initialize();
46 static void Shutdown(); 46 static void Shutdown();
47 static LoginState* Get(); 47 static LoginState* Get();
48 static bool IsInitialized(); 48 static bool IsInitialized();
49 49
50 // Add/remove observers. 50 // Add/remove observers.
51 void AddObserver(Observer* observer); 51 void AddObserver(Observer* observer);
52 void RemoveObserver(Observer* observer); 52 void RemoveObserver(Observer* observer);
53 53
54 // Set the logged in state and user type. 54 // Sets the logged in state, user type, and primary user hash. Also notifies
pneubeck (no reviews) 2014/06/12 09:51:01 I find this interface a bit odd in the light of mu
stevenjb 2014/06/12 20:27:51 This should be called exactly once when a user log
55 // observers.
56 void SetLoggedInStateAndPrimaryUser(
57 LoggedInState state,
58 LoggedInUserType type,
59 const std::string& primary_user_hash);
60
61 // Sets the logged in state and user type. Also notifies observers. Used
62 // in tests or situations where there is no primary user.
55 void SetLoggedInState(LoggedInState state, LoggedInUserType type); 63 void SetLoggedInState(LoggedInState state, LoggedInUserType type);
56 64
57 // Get the logged in user type. 65 // Gets the logged in user type.
58 LoggedInUserType GetLoggedInUserType() const; 66 LoggedInUserType GetLoggedInUserType() const;
59 67
60 // Returns true if a user is considered to be logged in. 68 // Returns true if a user is considered to be logged in.
61 bool IsUserLoggedIn() const; 69 bool IsUserLoggedIn() const;
62 70
63 // Returns true if |logged_in_state_| is safe mode (i.e. the user is not yet 71 // Returns true if |logged_in_state_| is safe mode (i.e. the user is not yet
64 // logged in, and only the owner will be allowed to log in). 72 // logged in, and only the owner will be allowed to log in).
65 bool IsInSafeMode() const; 73 bool IsInSafeMode() const;
66 74
67 // Returns true if logged in and is a guest, retail, or public user. 75 // Returns true if logged in and is a guest, retail, or public user.
68 bool IsGuestUser() const; 76 bool IsGuestUser() const;
69 77
70 // Returns true if logged in as a kiosk app. 78 // Returns true if logged in as a kiosk app.
71 bool IsKioskApp() const; 79 bool IsKioskApp() const;
72 80
73 // Whether a network profile is created for the user. 81 // Whether a network profile is created for the user.
74 bool UserHasNetworkProfile() const; 82 bool UserHasNetworkProfile() const;
75 83
76 // Returns true if the user is an authenticated user (i.e. non public account) 84 // Returns true if the user is an authenticated user (i.e. non public account)
77 bool IsUserAuthenticated() const; 85 bool IsUserAuthenticated() const;
78 86
79 // Returns true if the user is authenticated by logging into Google account 87 // Returns true if the user is authenticated by logging into Google account
80 // (i.e., non public nor locally managed account). 88 // (i.e., non public nor locally managed account).
81 bool IsUserGaiaAuthenticated() const; 89 bool IsUserGaiaAuthenticated() const;
82 90
83 void set_always_logged_in(bool always_logged_in) { 91 void set_always_logged_in(bool always_logged_in) {
84 always_logged_in_ = always_logged_in; 92 always_logged_in_ = always_logged_in;
85 } 93 }
86 94
95 const std::string& primary_user_hash() const { return primary_user_hash_; }
96
87 private: 97 private:
88 LoginState(); 98 LoginState();
89 virtual ~LoginState(); 99 virtual ~LoginState();
90 100
91 void NotifyObservers(); 101 void NotifyObservers();
92 102
93 LoggedInState logged_in_state_; 103 LoggedInState logged_in_state_;
94 LoggedInUserType logged_in_user_type_; 104 LoggedInUserType logged_in_user_type_;
105 std::string primary_user_hash_;
95 ObserverList<Observer> observer_list_; 106 ObserverList<Observer> observer_list_;
96 107
97 // If true, it always thinks the current status as logged in. Set to true by 108 // If true, it always thinks the current status as logged in. Set to true by
98 // default running on a Linux desktop without flags and test cases. To test 109 // default running on a Linux desktop without flags and test cases. To test
99 // behaviors with a specific login state, call set_always_logged_in(false). 110 // behaviors with a specific login state, call set_always_logged_in(false).
100 bool always_logged_in_; 111 bool always_logged_in_;
101 112
102 DISALLOW_COPY_AND_ASSIGN(LoginState); 113 DISALLOW_COPY_AND_ASSIGN(LoginState);
103 }; 114 };
104 115
105 } // namespace chromeos 116 } // namespace chromeos
106 117
107 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ 118 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698