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

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

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

Powered by Google App Engine
This is Rietveld 408576698