OLD | NEW |
---|---|
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> |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 namespace cryptohome { | 22 namespace cryptohome { |
23 class Identification; | 23 class Identification; |
24 } | 24 } |
25 | 25 |
26 namespace chromeos { | 26 namespace chromeos { |
27 | 27 |
28 // SessionManagerClient is used to communicate with the session manager. | 28 // SessionManagerClient is used to communicate with the session manager. |
29 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { | 29 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { |
30 public: | 30 public: |
31 // The result type received from session manager on request to retrieve the | |
32 // policy. Used to define the buckets for an enumerated UMA histogram. | |
33 // Hence, | |
34 // (a) existing enumerated constants should never be deleted or reordered. | |
35 // (b) new constants should only be appended at the end of the enumeration. | |
Daniel Erat
2017/04/24 19:50:13
nit: "new constants should be inserted immediately
igorcov
2017/04/25 09:18:42
Done.
| |
36 enum class RetrievePolicyResponseType { | |
37 OTHER_ERROR = 0, // Other type of error while retrieving policy | |
38 // data (e.g. D-Bus timeout). | |
39 SUCCESS = 1, // The policy was retrieved successfully. | |
40 SESSION_DOES_NOT_EXIST = 2, // Retrieve policy request issued before | |
41 // session started. | |
42 POLICY_ENCODE_ERROR = 3, // Session manager failed to encode the policy | |
43 // data. | |
44 COUNT // Has to be the last value of enumeration. | |
45 // Used for UMA. | |
46 }; | |
47 | |
31 // Interface for observing changes from the session manager. | 48 // Interface for observing changes from the session manager. |
32 class Observer { | 49 class Observer { |
33 public: | 50 public: |
34 virtual ~Observer() {} | 51 virtual ~Observer() {} |
35 | 52 |
36 // Called when the owner key is set. | 53 // Called when the owner key is set. |
37 virtual void OwnerKeySet(bool success) {} | 54 virtual void OwnerKeySet(bool success) {} |
38 | 55 |
39 // Called when the property change is complete. | 56 // Called when the property change is complete. |
40 virtual void PropertyChangeComplete(bool success) {} | 57 virtual void PropertyChangeComplete(bool success) {} |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 // Enumerates active user sessions. Usually Chrome naturally keeps track of | 153 // Enumerates active user sessions. Usually Chrome naturally keeps track of |
137 // active users when they are added into current session. When Chrome is | 154 // active users when they are added into current session. When Chrome is |
138 // restarted after crash by session_manager it only receives cryptohome id and | 155 // restarted after crash by session_manager it only receives cryptohome id and |
139 // user_id_hash for one user. This method is used to retrieve list of all | 156 // user_id_hash for one user. This method is used to retrieve list of all |
140 // active users. | 157 // active users. |
141 virtual void RetrieveActiveSessions( | 158 virtual void RetrieveActiveSessions( |
142 const ActiveSessionsCallback& callback) = 0; | 159 const ActiveSessionsCallback& callback) = 0; |
143 | 160 |
144 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and | 161 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and |
145 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as | 162 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as |
146 // string. Upon success, we will pass a protobuf to the callback. On | 163 // string. Upon success, we will pass a protobuf and SUCCESS |response_type| |
147 // failure, we will pass "". | 164 // to the callback. On failure, we will pass "" and the details of error type |
165 // in |response_type|. | |
148 using RetrievePolicyCallback = | 166 using RetrievePolicyCallback = |
149 base::Callback<void(const std::string& protobuf)>; | 167 base::Callback<void(const std::string& protobuf, |
168 RetrievePolicyResponseType response_type)>; | |
150 | 169 |
151 // Fetches the device policy blob stored by the session manager. Upon | 170 // Fetches the device policy blob stored by the session manager. Upon |
152 // completion of the retrieve attempt, we will call the provided callback. | 171 // completion of the retrieve attempt, we will call the provided callback. |
153 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; | 172 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; |
154 | 173 |
155 // Same as RetrieveDevicePolicy() but blocks until a reply is received, and | 174 // Same as RetrieveDevicePolicy() but blocks until a reply is received, and |
156 // returns the policy synchronously. Returns an empty string if the method | 175 // populates the policy synchronously. Returns SUCCESS when successful, or |
157 // call fails. | 176 // the corresponding error from enum in case of a failure. |
158 // This may only be called in situations where blocking the UI thread is | 177 // This may only be called in situations where blocking the UI thread is |
159 // considered acceptable (e.g. restarting the browser after a crash or after | 178 // considered acceptable (e.g. restarting the browser after a crash or after |
160 // a flag change). | 179 // a flag change). |
161 // TODO: Get rid of blocking calls (crbug.com/160522). | 180 // TODO: Get rid of blocking calls (crbug.com/160522). |
162 virtual std::string BlockingRetrieveDevicePolicy() = 0; | 181 virtual RetrievePolicyResponseType BlockingRetrieveDevicePolicy( |
182 std::string* policy) = 0; | |
Daniel Erat
2017/04/24 19:50:13
policy_out
igorcov
2017/04/25 09:18:42
Done.
| |
163 | 183 |
164 // Fetches the user policy blob stored by the session manager for the given | 184 // Fetches the user policy blob stored by the session manager for the given |
165 // |cryptohome_id|. Upon completion of the retrieve attempt, we will call the | 185 // |cryptohome_id|. Upon completion of the retrieve attempt, we will call the |
166 // provided callback. | 186 // provided callback. |
167 virtual void RetrievePolicyForUser( | 187 virtual void RetrievePolicyForUser( |
168 const cryptohome::Identification& cryptohome_id, | 188 const cryptohome::Identification& cryptohome_id, |
169 const RetrievePolicyCallback& callback) = 0; | 189 const RetrievePolicyCallback& callback) = 0; |
170 | 190 |
171 // Same as RetrievePolicyForUser() but blocks until a reply is received, and | 191 // Same as RetrievePolicyForUser() but blocks until a reply is received, and |
172 // returns the policy synchronously. Returns an empty string if the method | 192 // populates the policy synchronously. Returns SUCCESS when successful, or |
173 // call fails. | 193 // the corresponding error from enum in case of a failure. |
174 // This may only be called in situations where blocking the UI thread is | 194 // This may only be called in situations where blocking the UI thread is |
175 // considered acceptable (e.g. restarting the browser after a crash or after | 195 // considered acceptable (e.g. restarting the browser after a crash or after |
176 // a flag change). | 196 // a flag change). |
177 // TODO: Get rid of blocking calls (crbug.com/160522). | 197 // TODO: Get rid of blocking calls (crbug.com/160522). |
178 virtual std::string BlockingRetrievePolicyForUser( | 198 virtual RetrievePolicyResponseType BlockingRetrievePolicyForUser( |
179 const cryptohome::Identification& cryptohome_id) = 0; | 199 const cryptohome::Identification& cryptohome_id, |
200 std::string* policy) = 0; | |
Daniel Erat
2017/04/24 19:50:13
policy_out
igorcov
2017/04/25 09:18:42
Done.
| |
180 | 201 |
181 // Fetches the policy blob associated with the specified device-local account | 202 // Fetches the policy blob associated with the specified device-local account |
182 // from session manager. |callback| is invoked up on completion. | 203 // from session manager. |callback| is invoked up on completion. |
183 virtual void RetrieveDeviceLocalAccountPolicy( | 204 virtual void RetrieveDeviceLocalAccountPolicy( |
184 const std::string& account_id, | 205 const std::string& account_id, |
185 const RetrievePolicyCallback& callback) = 0; | 206 const RetrievePolicyCallback& callback) = 0; |
186 | 207 |
187 // Same as RetrieveDeviceLocalAccountPolicy() but blocks until a reply is | 208 // Same as RetrieveDeviceLocalAccountPolicy() but blocks until a reply is |
188 // received, and returns the policy synchronously. | 209 // received, and populates the policy synchronously. Returns SUCCESS when |
189 // Returns an empty string if the method call fails. | 210 // successful, or the corresponding error from enum in case of a failure. |
190 // This may only be called in situations where blocking the UI thread is | 211 // This may only be called in situations where blocking the UI thread is |
191 // considered acceptable (e.g. restarting the browser after a crash or after | 212 // considered acceptable (e.g. restarting the browser after a crash or after |
192 // a flag change). | 213 // a flag change). |
193 // TODO: Get rid of blocking calls (crbug.com/160522). | 214 // TODO: Get rid of blocking calls (crbug.com/160522). |
194 virtual std::string BlockingRetrieveDeviceLocalAccountPolicy( | 215 virtual RetrievePolicyResponseType BlockingRetrieveDeviceLocalAccountPolicy( |
195 const std::string& account_id) = 0; | 216 const std::string& account_id, |
217 std::string* policy) = 0; | |
Daniel Erat
2017/04/24 19:50:13
policy_out
igorcov
2017/04/25 09:18:42
Done.
| |
196 | 218 |
197 // Used for StoreDevicePolicy, StorePolicyForUser and | 219 // Used for StoreDevicePolicy, StorePolicyForUser and |
198 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the | 220 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the |
199 // operation was successful or not. | 221 // operation was successful or not. |
200 using StorePolicyCallback = base::Callback<void(bool success)>; | 222 using StorePolicyCallback = base::Callback<void(bool success)>; |
201 | 223 |
202 // Attempts to asynchronously store |policy_blob| as device policy. Upon | 224 // Attempts to asynchronously store |policy_blob| as device policy. Upon |
203 // completion of the store attempt, we will call callback. | 225 // completion of the store attempt, we will call callback. |
204 virtual void StoreDevicePolicy(const std::string& policy_blob, | 226 virtual void StoreDevicePolicy(const std::string& policy_blob, |
205 const StorePolicyCallback& callback) = 0; | 227 const StorePolicyCallback& callback) = 0; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 // Create() should be used instead. | 336 // Create() should be used instead. |
315 SessionManagerClient(); | 337 SessionManagerClient(); |
316 | 338 |
317 private: | 339 private: |
318 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); | 340 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); |
319 }; | 341 }; |
320 | 342 |
321 } // namespace chromeos | 343 } // namespace chromeos |
322 | 344 |
323 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ | 345 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ |
OLD | NEW |