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 | 18 |
| 19 namespace cryptohome { |
| 20 class Identification; |
| 21 } |
| 22 |
19 namespace chromeos { | 23 namespace chromeos { |
20 | 24 |
21 // SessionManagerClient is used to communicate with the session manager. | 25 // SessionManagerClient is used to communicate with the session manager. |
22 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { | 26 class CHROMEOS_EXPORT SessionManagerClient : public DBusClient { |
23 public: | 27 public: |
24 // Interface for observing changes from the session manager. | 28 // Interface for observing changes from the session manager. |
25 class Observer { | 29 class Observer { |
26 public: | 30 public: |
27 virtual ~Observer() {} | 31 virtual ~Observer() {} |
28 | 32 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // call. | 75 // call. |
72 virtual bool IsScreenLocked() const = 0; | 76 virtual bool IsScreenLocked() const = 0; |
73 | 77 |
74 // Kicks off an attempt to emit the "login-prompt-visible" upstart signal. | 78 // Kicks off an attempt to emit the "login-prompt-visible" upstart signal. |
75 virtual void EmitLoginPromptVisible() = 0; | 79 virtual void EmitLoginPromptVisible() = 0; |
76 | 80 |
77 // Restarts the browser job, passing |argv| as the updated command line. | 81 // Restarts the browser job, passing |argv| as the updated command line. |
78 virtual void RestartJob(const std::vector<std::string>& argv) = 0; | 82 virtual void RestartJob(const std::vector<std::string>& argv) = 0; |
79 | 83 |
80 // Starts the session for the user. | 84 // Starts the session for the user. |
81 virtual void StartSession(const std::string& user_email) = 0; | 85 virtual void StartSession( |
| 86 const cryptohome::Identification& cryptohome_id) = 0; |
82 | 87 |
83 // Stops the current session. | 88 // Stops the current session. |
84 virtual void StopSession() = 0; | 89 virtual void StopSession() = 0; |
85 | 90 |
86 // Starts the factory reset. | 91 // Starts the factory reset. |
87 virtual void StartDeviceWipe() = 0; | 92 virtual void StartDeviceWipe() = 0; |
88 | 93 |
89 // Locks the screen. | 94 // Locks the screen. |
90 virtual void RequestLockScreen() = 0; | 95 virtual void RequestLockScreen() = 0; |
91 | 96 |
92 // Notifies that the lock screen is shown. | 97 // Notifies that the lock screen is shown. |
93 virtual void NotifyLockScreenShown() = 0; | 98 virtual void NotifyLockScreenShown() = 0; |
94 | 99 |
95 // Notifies that the lock screen is dismissed. | 100 // Notifies that the lock screen is dismissed. |
96 virtual void NotifyLockScreenDismissed() = 0; | 101 virtual void NotifyLockScreenDismissed() = 0; |
97 | 102 |
98 // Notifies that supervised user creation have started. | 103 // Notifies that supervised user creation have started. |
99 virtual void NotifySupervisedUserCreationStarted() = 0; | 104 virtual void NotifySupervisedUserCreationStarted() = 0; |
100 | 105 |
101 // Notifies that supervised user creation have finished. | 106 // Notifies that supervised user creation have finished. |
102 virtual void NotifySupervisedUserCreationFinished() = 0; | 107 virtual void NotifySupervisedUserCreationFinished() = 0; |
103 | 108 |
104 // Map that is used to describe the set of active user sessions where |key| | 109 // Map that is used to describe the set of active user sessions where |key| |
105 // is user_id and |value| is user_id_hash. | 110 // is cryptohome id and |value| is user_id_hash. |
106 typedef std::map<std::string, std::string> ActiveSessionsMap; | 111 using ActiveSessionsMap = std::map<cryptohome::Identification, std::string>; |
107 | 112 |
108 // The ActiveSessionsCallback is used for the RetrieveActiveSessions() | 113 // The ActiveSessionsCallback is used for the RetrieveActiveSessions() |
109 // method. It receives |sessions| argument where the keys are user_ids for | 114 // method. It receives |sessions| argument where the keys are cryptohome_ids |
110 // all users that are currently active and |success| argument which indicates | 115 // for all users that are currently active and |success| argument which |
111 // whether or not the request succeded. | 116 // indicates whether or not the request succeded. |
112 typedef base::Callback<void(const ActiveSessionsMap& sessions, | 117 typedef base::Callback<void(const ActiveSessionsMap& sessions, |
113 bool success)> ActiveSessionsCallback; | 118 bool success)> ActiveSessionsCallback; |
114 | 119 |
115 // Enumerates active user sessions. Usually Chrome naturally keeps track of | 120 // Enumerates active user sessions. Usually Chrome naturally keeps track of |
116 // active users when they are added into current session. When Chrome is | 121 // active users when they are added into current session. When Chrome is |
117 // restarted after crash by session_manager it only receives user_id and | 122 // restarted after crash by session_manager it only receives cryptohome id and |
118 // user_id_hash for one user. This method is used to retrieve list of all | 123 // user_id_hash for one user. This method is used to retrieve list of all |
119 // active users. | 124 // active users. |
120 virtual void RetrieveActiveSessions( | 125 virtual void RetrieveActiveSessions( |
121 const ActiveSessionsCallback& callback) = 0; | 126 const ActiveSessionsCallback& callback) = 0; |
122 | 127 |
123 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and | 128 // Used for RetrieveDevicePolicy, RetrievePolicyForUser and |
124 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as | 129 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as |
125 // string. Upon success, we will pass a protobuf to the callback. On | 130 // string. Upon success, we will pass a protobuf to the callback. On |
126 // failure, we will pass "". | 131 // failure, we will pass "". |
127 typedef base::Callback<void(const std::string&)> RetrievePolicyCallback; | 132 typedef base::Callback<void(const std::string&)> RetrievePolicyCallback; |
128 | 133 |
129 // Fetches the device policy blob stored by the session manager. Upon | 134 // Fetches the device policy blob stored by the session manager. Upon |
130 // completion of the retrieve attempt, we will call the provided callback. | 135 // completion of the retrieve attempt, we will call the provided callback. |
131 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; | 136 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0; |
132 | 137 |
133 // Fetches the user policy blob stored by the session manager for the given | 138 // Fetches the user policy blob stored by the session manager for the given |
134 // |username|. Upon completion of the retrieve attempt, we will call the | 139 // |cryptohome_id|. Upon completion of the retrieve attempt, we will call the |
135 // provided callback. | 140 // provided callback. |
136 virtual void RetrievePolicyForUser( | 141 virtual void RetrievePolicyForUser( |
137 const std::string& username, | 142 const cryptohome::Identification& cryptohome_id, |
138 const RetrievePolicyCallback& callback) = 0; | 143 const RetrievePolicyCallback& callback) = 0; |
139 | 144 |
140 // Same as RetrievePolicyForUser() but blocks until a reply is received, and | 145 // Same as RetrievePolicyForUser() but blocks until a reply is received, and |
141 // returns the policy synchronously. Returns an empty string if the method | 146 // returns the policy synchronously. Returns an empty string if the method |
142 // call fails. | 147 // call fails. |
143 // This may only be called in situations where blocking the UI thread is | 148 // This may only be called in situations where blocking the UI thread is |
144 // considered acceptable (e.g. restarting the browser after a crash or after | 149 // considered acceptable (e.g. restarting the browser after a crash or after |
145 // a flag change). | 150 // a flag change). |
146 virtual std::string BlockingRetrievePolicyForUser( | 151 virtual std::string BlockingRetrievePolicyForUser( |
147 const std::string& username) = 0; | 152 const cryptohome::Identification& cryptohome_id) = 0; |
148 | 153 |
149 // Fetches the policy blob associated with the specified device-local account | 154 // Fetches the policy blob associated with the specified device-local account |
150 // from session manager. |callback| is invoked up on completion. | 155 // from session manager. |callback| is invoked up on completion. |
151 virtual void RetrieveDeviceLocalAccountPolicy( | 156 virtual void RetrieveDeviceLocalAccountPolicy( |
152 const std::string& account_id, | 157 const std::string& account_id, |
153 const RetrievePolicyCallback& callback) = 0; | 158 const RetrievePolicyCallback& callback) = 0; |
154 | 159 |
155 // Used for StoreDevicePolicy, StorePolicyForUser and | 160 // Used for StoreDevicePolicy, StorePolicyForUser and |
156 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the | 161 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the |
157 // operation was successful or not. | 162 // operation was successful or not. |
158 typedef base::Callback<void(bool)> StorePolicyCallback; | 163 typedef base::Callback<void(bool)> StorePolicyCallback; |
159 | 164 |
160 // Attempts to asynchronously store |policy_blob| as device policy. Upon | 165 // Attempts to asynchronously store |policy_blob| as device policy. Upon |
161 // completion of the store attempt, we will call callback. | 166 // completion of the store attempt, we will call callback. |
162 virtual void StoreDevicePolicy(const std::string& policy_blob, | 167 virtual void StoreDevicePolicy(const std::string& policy_blob, |
163 const StorePolicyCallback& callback) = 0; | 168 const StorePolicyCallback& callback) = 0; |
164 | 169 |
165 // Attempts to asynchronously store |policy_blob| as user policy for the given | 170 // Attempts to asynchronously store |policy_blob| as user policy for the |
166 // |username|. Upon completion of the store attempt, we will call callback. | 171 // given |cryptohome_id|. Upon completion of the store attempt, we will call |
167 virtual void StorePolicyForUser(const std::string& username, | 172 // callback. |
168 const std::string& policy_blob, | 173 virtual void StorePolicyForUser( |
169 const StorePolicyCallback& callback) = 0; | 174 const cryptohome::Identification& cryptohome_id, |
| 175 const std::string& policy_blob, |
| 176 const StorePolicyCallback& callback) = 0; |
170 | 177 |
171 // Sends a request to store a policy blob for the specified device-local | 178 // Sends a request to store a policy blob for the specified device-local |
172 // account. The result of the operation is reported through |callback|. | 179 // account. The result of the operation is reported through |callback|. |
173 virtual void StoreDeviceLocalAccountPolicy( | 180 virtual void StoreDeviceLocalAccountPolicy( |
174 const std::string& account_id, | 181 const std::string& account_id, |
175 const std::string& policy_blob, | 182 const std::string& policy_blob, |
176 const StorePolicyCallback& callback) = 0; | 183 const StorePolicyCallback& callback) = 0; |
177 | 184 |
178 // Sets the flags to be applied next time by the session manager when Chrome | 185 // Sets the flags to be applied next time by the session manager when Chrome |
179 // is restarted inside an already started session for a particular user. | 186 // is restarted inside an already started session for a particular user. |
180 virtual void SetFlagsForUser(const std::string& username, | 187 virtual void SetFlagsForUser(const cryptohome::Identification& cryptohome_id, |
181 const std::vector<std::string>& flags) = 0; | 188 const std::vector<std::string>& flags) = 0; |
182 | 189 |
183 typedef base::Callback<void(const std::vector<std::string>& state_keys)> | 190 typedef base::Callback<void(const std::vector<std::string>& state_keys)> |
184 StateKeysCallback; | 191 StateKeysCallback; |
185 | 192 |
186 // Get the currently valid server-backed state keys for the device. | 193 // Get the currently valid server-backed state keys for the device. |
187 // Server-backed state keys are opaque, device-unique, time-dependent, | 194 // Server-backed state keys are opaque, device-unique, time-dependent, |
188 // client-determined identifiers that are used for keying state in the cloud | 195 // client-determined identifiers that are used for keying state in the cloud |
189 // for the device to retrieve after a device factory reset. | 196 // for the device to retrieve after a device factory reset. |
190 // | 197 // |
(...skipping 28 matching lines...) Expand all Loading... |
219 // Create() should be used instead. | 226 // Create() should be used instead. |
220 SessionManagerClient(); | 227 SessionManagerClient(); |
221 | 228 |
222 private: | 229 private: |
223 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); | 230 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient); |
224 }; | 231 }; |
225 | 232 |
226 } // namespace chromeos | 233 } // namespace chromeos |
227 | 234 |
228 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ | 235 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_ |
OLD | NEW |