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