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

Side by Side Diff: chromeos/dbus/session_manager_client.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_DBUS_SESSION_MANAGER_CLIENT_H_ 5 #ifndef CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ 6 #define CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h" 15 #include "chromeos/dbus/dbus_client.h"
16 #include "chromeos/dbus/dbus_client_implementation_type.h" 16 #include "chromeos/dbus/dbus_client_implementation_type.h"
17 17
18 namespace user_manager {
19 class UserID;
20 }
21
18 namespace chromeos { 22 namespace chromeos {
19 23
20 // SessionManagerClient is used to communicate with the session manager. 24 // SessionManagerClient is used to communicate with the session manager.
21 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { 25 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
22 public: 26 public:
23 // Interface for observing changes from the session manager. 27 // Interface for observing changes from the session manager.
24 class Observer { 28 class Observer {
25 public: 29 public:
26 virtual ~Observer() {} 30 virtual ~Observer() {}
27 31
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // call. 74 // call.
71 virtual bool IsScreenLocked() const = 0; 75 virtual bool IsScreenLocked() const = 0;
72 76
73 // Kicks off an attempt to emit the "login-prompt-visible" upstart signal. 77 // Kicks off an attempt to emit the "login-prompt-visible" upstart signal.
74 virtual void EmitLoginPromptVisible() = 0; 78 virtual void EmitLoginPromptVisible() = 0;
75 79
76 // Restarts a job referenced by |pid| with the provided command line. 80 // Restarts a job referenced by |pid| with the provided command line.
77 virtual void RestartJob(int pid, const std::string& command_line) = 0; 81 virtual void RestartJob(int pid, const std::string& command_line) = 0;
78 82
79 // Starts the session for the user. 83 // Starts the session for the user.
80 virtual void StartSession(const std::string& user_email) = 0; 84 virtual void StartSession(const user_manager::UserID& user_id) = 0;
81 85
82 // Stops the current session. 86 // Stops the current session.
83 virtual void StopSession() = 0; 87 virtual void StopSession() = 0;
84 88
85 // Starts the factory reset. 89 // Starts the factory reset.
86 virtual void StartDeviceWipe() = 0; 90 virtual void StartDeviceWipe() = 0;
87 91
88 // Locks the screen. 92 // Locks the screen.
89 virtual void RequestLockScreen() = 0; 93 virtual void RequestLockScreen() = 0;
90 94
91 // Notifies that the lock screen is shown. 95 // Notifies that the lock screen is shown.
92 virtual void NotifyLockScreenShown() = 0; 96 virtual void NotifyLockScreenShown() = 0;
93 97
94 // Notifies that the lock screen is dismissed. 98 // Notifies that the lock screen is dismissed.
95 virtual void NotifyLockScreenDismissed() = 0; 99 virtual void NotifyLockScreenDismissed() = 0;
96 100
97 // Notifies that supervised user creation have started. 101 // Notifies that supervised user creation have started.
98 virtual void NotifySupervisedUserCreationStarted() = 0; 102 virtual void NotifySupervisedUserCreationStarted() = 0;
99 103
100 // Notifies that supervised user creation have finished. 104 // Notifies that supervised user creation have finished.
101 virtual void NotifySupervisedUserCreationFinished() = 0; 105 virtual void NotifySupervisedUserCreationFinished() = 0;
102 106
103 // Map that is used to describe the set of active user sessions where |key| 107 // Map that is used to describe the set of active user sessions where |key|
104 // is user_id and |value| is user_id_hash. 108 // is user_id and |value| is user_id_hash.
105 typedef std::map<std::string, std::string> ActiveSessionsMap; 109 typedef std::map<user_manager::UserID, std::string> ActiveSessionsMap;
106 110
107 // The ActiveSessionsCallback is used for the RetrieveActiveSessions() 111 // The ActiveSessionsCallback is used for the RetrieveActiveSessions()
108 // method. It receives |sessions| argument where the keys are user_ids for 112 // method. It receives |sessions| argument where the keys are user_ids for
109 // all users that are currently active and |success| argument which indicates 113 // all users that are currently active and |success| argument which indicates
110 // whether or not the request succeded. 114 // whether or not the request succeded.
111 typedef base::Callback<void(const ActiveSessionsMap& sessions, 115 typedef base::Callback<void(const ActiveSessionsMap& sessions,
112 bool success)> ActiveSessionsCallback; 116 bool success)> ActiveSessionsCallback;
113 117
114 // Enumerates active user sessions. Usually Chrome naturally keeps track of 118 // Enumerates active user sessions. Usually Chrome naturally keeps track of
115 // active users when they are added into current session. When Chrome is 119 // active users when they are added into current session. When Chrome is
116 // restarted after crash by session_manager it only receives user_id and 120 // restarted after crash by session_manager it only receives user_id and
117 // user_id_hash for one user. This method is used to retrieve list of all 121 // user_id_hash for one user. This method is used to retrieve list of all
118 // active users. 122 // active users.
119 virtual void RetrieveActiveSessions( 123 virtual void RetrieveActiveSessions(
120 const ActiveSessionsCallback& callback) = 0; 124 const ActiveSessionsCallback& callback) = 0;
121 125
122 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and 126 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and
123 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as 127 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as
124 // string. Upon success, we will pass a protobuf to the callback. On 128 // string. Upon success, we will pass a protobuf to the callback. On
125 // failure, we will pass "". 129 // failure, we will pass "".
126 typedef base::Callback<void(const std::string&)> RetrievePolicyCallback; 130 typedef base::Callback<void(const std::string&)> RetrievePolicyCallback;
127 131
128 // Fetches the device policy blob stored by the session manager. Upon 132 // Fetches the device policy blob stored by the session manager. Upon
129 // completion of the retrieve attempt, we will call the provided callback. 133 // completion of the retrieve attempt, we will call the provided callback.
130 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; 134 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0;
131 135
132 // Fetches the user policy blob stored by the session manager for the given 136 // Fetches the user policy blob stored by the session manager for the given
133 // |username|. Upon completion of the retrieve attempt, we will call the 137 // |user_id|. Upon completion of the retrieve attempt, we will call the
134 // provided callback. 138 // provided callback.
135 virtual void RetrievePolicyForUser( 139 virtual void RetrievePolicyForUser(
136 const std::string& username, 140 const user_manager::UserID& user_id,
137 const RetrievePolicyCallback& callback) = 0; 141 const RetrievePolicyCallback& callback) = 0;
138 142
139 // Same as RetrievePolicyForUser() but blocks until a reply is received, and 143 // Same as RetrievePolicyForUser() but blocks until a reply is received, and
140 // returns the policy synchronously. Returns an empty string if the method 144 // returns the policy synchronously. Returns an empty string if the method
141 // call fails. 145 // call fails.
142 // This may only be called in situations where blocking the UI thread is 146 // This may only be called in situations where blocking the UI thread is
143 // considered acceptable (e.g. restarting the browser after a crash or after 147 // considered acceptable (e.g. restarting the browser after a crash or after
144 // a flag change). 148 // a flag change).
145 virtual std::string BlockingRetrievePolicyForUser( 149 virtual std::string BlockingRetrievePolicyForUser(
146 const std::string& username) = 0; 150 const user_manager::UserID& user_id) = 0;
147 151
148 // Fetches the policy blob associated with the specified device-local account 152 // Fetches the policy blob associated with the specified device-local account
149 // from session manager. |callback| is invoked up on completion. 153 // from session manager. |callback| is invoked up on completion.
150 virtual void RetrieveDeviceLocalAccountPolicy( 154 virtual void RetrieveDeviceLocalAccountPolicy(
151 const std::string& account_id, 155 const std::string& account_id,
152 const RetrievePolicyCallback& callback) = 0; 156 const RetrievePolicyCallback& callback) = 0;
153 157
154 // Used for StoreDevicePolicy, StorePolicyForUser and 158 // Used for StoreDevicePolicy, StorePolicyForUser and
155 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the 159 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the
156 // operation was successful or not. 160 // operation was successful or not.
157 typedef base::Callback<void(bool)> StorePolicyCallback; 161 typedef base::Callback<void(bool)> StorePolicyCallback;
158 162
159 // Attempts to asynchronously store |policy_blob| as device policy. Upon 163 // Attempts to asynchronously store |policy_blob| as device policy. Upon
160 // completion of the store attempt, we will call callback. 164 // completion of the store attempt, we will call callback.
161 virtual void StoreDevicePolicy(const std::string& policy_blob, 165 virtual void StoreDevicePolicy(const std::string& policy_blob,
162 const StorePolicyCallback& callback) = 0; 166 const StorePolicyCallback& callback) = 0;
163 167
164 // Attempts to asynchronously store |policy_blob| as user policy for the given 168 // Attempts to asynchronously store |policy_blob| as user policy for the given
165 // |username|. Upon completion of the store attempt, we will call callback. 169 // |user_id|. Upon completion of the store attempt, we will call callback.
166 virtual void StorePolicyForUser(const std::string& username, 170 virtual void StorePolicyForUser(const user_manager::UserID& user_id,
167 const std::string& policy_blob, 171 const std::string& policy_blob,
168 const StorePolicyCallback& callback) = 0; 172 const StorePolicyCallback& callback) = 0;
169 173
170 // Sends a request to store a policy blob for the specified device-local 174 // Sends a request to store a policy blob for the specified device-local
171 // account. The result of the operation is reported through |callback|. 175 // account. The result of the operation is reported through |callback|.
172 virtual void StoreDeviceLocalAccountPolicy( 176 virtual void StoreDeviceLocalAccountPolicy(
173 const std::string& account_id, 177 const std::string& account_id,
174 const std::string& policy_blob, 178 const std::string& policy_blob,
175 const StorePolicyCallback& callback) = 0; 179 const StorePolicyCallback& callback) = 0;
176 180
177 // Sets the flags to be applied next time by the session manager when Chrome 181 // Sets the flags to be applied next time by the session manager when Chrome
178 // is restarted inside an already started session for a particular user. 182 // is restarted inside an already started session for a particular user.
179 virtual void SetFlagsForUser(const std::string& username, 183 virtual void SetFlagsForUser(const user_manager::UserID& user_id,
180 const std::vector<std::string>& flags) = 0; 184 const std::vector<std::string>& flags) = 0;
181 185
182 typedef base::Callback<void(const std::vector<std::string>& state_keys)> 186 typedef base::Callback<void(const std::vector<std::string>& state_keys)>
183 StateKeysCallback; 187 StateKeysCallback;
184 188
185 // Get the currently valid server-backed state keys for the device. 189 // Get the currently valid server-backed state keys for the device.
186 // Server-backed state keys are opaque, device-unique, time-dependent, 190 // Server-backed state keys are opaque, device-unique, time-dependent,
187 // client-determined identifiers that are used for keying state in the cloud 191 // client-determined identifiers that are used for keying state in the cloud
188 // for the device to retrieve after a device factory reset. 192 // for the device to retrieve after a device factory reset.
189 // 193 //
(...skipping 10 matching lines...) Expand all
200 // Create() should be used instead. 204 // Create() should be used instead.
201 SessionManagerClient(); 205 SessionManagerClient();
202 206
203 private: 207 private:
204 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); 208 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient);
205 }; 209 };
206 210
207 } // namespace chromeos 211 } // namespace chromeos
208 212
209 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ 213 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698