Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
| 16 #include "chromeos/dbus/dbus_client.h" | 16 #include "chromeos/dbus/dbus_client.h" |
| 17 #include "chromeos/dbus/dbus_client_implementation_type.h" | 17 #include "chromeos/dbus/dbus_client_implementation_type.h" |
| 18 #include "chromeos/dbus/dbus_method_call_status.h" | 18 #include "chromeos/dbus/dbus_method_call_status.h" |
| 19 #include "third_party/cros_system_api/dbus/login_manager/dbus-constants.h" | 19 #include "third_party/cros_system_api/dbus/login_manager/dbus-constants.h" |
| 20 | 20 |
| 21 namespace cryptohome { | 21 namespace cryptohome { |
| 22 class Identification; | 22 class Identification; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace chromeos { | 25 namespace chromeos { |
| 26 | 26 |
| 27 // SessionManagerClient is used to communicate with the session manager. | 27 // SessionManagerClient is used to communicate with the session manager. |
| 28 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { | 28 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { |
| 29 public: | 29 public: |
| 30 // The result type received from session manager on request to retrieve the | |
| 31 // policy. | |
|
emaxx
2017/04/18 15:03:17
Please explain in the comment the restriction that
igorcov
2017/04/20 14:52:29
Done.
| |
| 32 enum RetrievePolicyResponseType { | |
| 33 SUCCESS, // The policy retrieved successfully. | |
| 34 SESSION_DOES_NOT_EXIST, // Retrieve policy request issued | |
| 35 // before session started. | |
| 36 OTHER_ERROR, // Other type of error while retrieving | |
| 37 // policy. | |
| 38 RETRIEVE_POLICY_RESPONSE_TYPE_COUNT // Has to be the last value of | |
| 39 // enumeration. Used for UMA. | |
| 40 }; | |
| 41 | |
| 30 // Interface for observing changes from the session manager. | 42 // Interface for observing changes from the session manager. |
| 31 class Observer { | 43 class Observer { |
| 32 public: | 44 public: |
| 33 virtual ~Observer() {} | 45 virtual ~Observer() {} |
| 34 | 46 |
| 35 // Called when the owner key is set. | 47 // Called when the owner key is set. |
| 36 virtual void OwnerKeySet(bool success) {} | 48 virtual void OwnerKeySet(bool success) {} |
| 37 | 49 |
| 38 // Called when the property change is complete. | 50 // Called when the property change is complete. |
| 39 virtual void PropertyChangeComplete(bool success) {} | 51 virtual void PropertyChangeComplete(bool success) {} |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 // Enumerates active user sessions. Usually Chrome naturally keeps track of | 147 // Enumerates active user sessions. Usually Chrome naturally keeps track of |
| 136 // active users when they are added into current session. When Chrome is | 148 // active users when they are added into current session. When Chrome is |
| 137 // restarted after crash by session_manager it only receives cryptohome id and | 149 // restarted after crash by session_manager it only receives cryptohome id and |
| 138 // user_id_hash for one user. This method is used to retrieve list of all | 150 // user_id_hash for one user. This method is used to retrieve list of all |
| 139 // active users. | 151 // active users. |
| 140 virtual void RetrieveActiveSessions( | 152 virtual void RetrieveActiveSessions( |
| 141 const ActiveSessionsCallback& callback) = 0; | 153 const ActiveSessionsCallback& callback) = 0; |
| 142 | 154 |
| 143 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and | 155 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and |
| 144 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as | 156 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as |
| 145 // string. Upon success, we will pass a protobuf to the callback. On | 157 // string. Upon success, we will pass a protobuf and SUCCESS |response_type| |
| 146 // failure, we will pass "". | 158 // to the callback. On failure, we will pass "" and the details of error type |
| 159 // in |response_type|. | |
| 147 using RetrievePolicyCallback = | 160 using RetrievePolicyCallback = |
| 148 base::Callback<void(const std::string& protobuf)>; | 161 base::Callback<void(const std::string& protobuf, |
| 162 const RetrievePolicyResponseType& response_type)>; | |
| 149 | 163 |
| 150 // Fetches the device policy blob stored by the session manager. Upon | 164 // Fetches the device policy blob stored by the session manager. Upon |
| 151 // completion of the retrieve attempt, we will call the provided callback. | 165 // completion of the retrieve attempt, we will call the provided callback. |
| 152 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; | 166 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; |
| 153 | 167 |
| 154 // Same as RetrieveDevicePolicy() but blocks until a reply is received, and | 168 // Same as RetrieveDevicePolicy() but blocks until a reply is received, and |
| 155 // returns the policy synchronously. Returns an empty string if the method | 169 // returns the policy synchronously. Returns an empty string if the method |
| 156 // call fails. | 170 // call fails. |
| 157 // This may only be called in situations where blocking the UI thread is | 171 // This may only be called in situations where blocking the UI thread is |
| 158 // considered acceptable (e.g. restarting the browser after a crash or after | 172 // considered acceptable (e.g. restarting the browser after a crash or after |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 // Create() should be used instead. | 327 // Create() should be used instead. |
| 314 SessionManagerClient(); | 328 SessionManagerClient(); |
| 315 | 329 |
| 316 private: | 330 private: |
| 317 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); | 331 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); |
| 318 }; | 332 }; |
| 319 | 333 |
| 320 } // namespace chromeos | 334 } // namespace chromeos |
| 321 | 335 |
| 322 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ | 336 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ |
| OLD | NEW |