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

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: Fix test 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 when the
55 // primary user initialy logs in. Also notifies 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 (e.g. from the
63 // login screen).
55 void SetLoggedInState(LoggedInState state, LoggedInUserType type); 64 void SetLoggedInState(LoggedInState state, LoggedInUserType type);
56 65
57 // Get the logged in user type. 66 // Gets the logged in user type.
58 LoggedInUserType GetLoggedInUserType() const; 67 LoggedInUserType GetLoggedInUserType() const;
59 68
60 // Returns true if a user is considered to be logged in. 69 // Returns true if a user is considered to be logged in.
61 bool IsUserLoggedIn() const; 70 bool IsUserLoggedIn() const;
62 71
63 // Returns true if |logged_in_state_| is safe mode (i.e. the user is not yet 72 // 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). 73 // logged in, and only the owner will be allowed to log in).
65 bool IsInSafeMode() const; 74 bool IsInSafeMode() const;
66 75
67 // Returns true if logged in and is a guest, retail, or public user. 76 // Returns true if logged in and is a guest, retail, or public user.
68 bool IsGuestUser() const; 77 bool IsGuestUser() const;
69 78
70 // Returns true if logged in as a kiosk app. 79 // Returns true if logged in as a kiosk app.
71 bool IsKioskApp() const; 80 bool IsKioskApp() const;
72 81
73 // Whether a network profile is created for the user. 82 // Whether a network profile is created for the user.
74 bool UserHasNetworkProfile() const; 83 bool UserHasNetworkProfile() const;
75 84
76 // Returns true if the user is an authenticated user (i.e. non public account) 85 // Returns true if the user is an authenticated user (i.e. non public account)
77 bool IsUserAuthenticated() const; 86 bool IsUserAuthenticated() const;
78 87
79 // Returns true if the user is authenticated by logging into Google account 88 // Returns true if the user is authenticated by logging into Google account
80 // (i.e., non public nor locally managed account). 89 // (i.e., non public nor locally managed account).
81 bool IsUserGaiaAuthenticated() const; 90 bool IsUserGaiaAuthenticated() const;
82 91
83 void set_always_logged_in(bool always_logged_in) { 92 void set_always_logged_in(bool always_logged_in) {
84 always_logged_in_ = always_logged_in; 93 always_logged_in_ = always_logged_in;
85 } 94 }
86 95
96 const std::string& primary_user_hash() const { return primary_user_hash_; }
97
87 private: 98 private:
88 LoginState(); 99 LoginState();
89 virtual ~LoginState(); 100 virtual ~LoginState();
90 101
91 void NotifyObservers(); 102 void NotifyObservers();
92 103
93 LoggedInState logged_in_state_; 104 LoggedInState logged_in_state_;
94 LoggedInUserType logged_in_user_type_; 105 LoggedInUserType logged_in_user_type_;
106 std::string primary_user_hash_;
95 ObserverList<Observer> observer_list_; 107 ObserverList<Observer> observer_list_;
96 108
97 // If true, it always thinks the current status as logged in. Set to true by 109 // 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 110 // 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). 111 // behaviors with a specific login state, call set_always_logged_in(false).
100 bool always_logged_in_; 112 bool always_logged_in_;
101 113
102 DISALLOW_COPY_AND_ASSIGN(LoginState); 114 DISALLOW_COPY_AND_ASSIGN(LoginState);
103 }; 115 };
104 116
105 } // namespace chromeos 117 } // namespace chromeos
106 118
107 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_ 119 #endif // CHROMEOS_LOGIN_LOGIN_STATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc ('k') | chromeos/login/login_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698