OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/chromeos/login/auth/extended_authenticator.h" | 5 #include "chromeos/login/auth/extended_authenticator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/chromeos/boot_times_loader.h" | |
11 #include "chromeos/cryptohome/async_method_caller.h" | 10 #include "chromeos/cryptohome/async_method_caller.h" |
12 #include "chromeos/cryptohome/cryptohome_parameters.h" | 11 #include "chromeos/cryptohome/cryptohome_parameters.h" |
13 #include "chromeos/cryptohome/homedir_methods.h" | 12 #include "chromeos/cryptohome/homedir_methods.h" |
14 #include "chromeos/cryptohome/system_salt_getter.h" | 13 #include "chromeos/cryptohome/system_salt_getter.h" |
15 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "chromeos/login/auth/auth_status_consumer.h" | 16 #include "chromeos/login/auth/auth_status_consumer.h" |
18 #include "chromeos/login/auth/key.h" | 17 #include "chromeos/login/auth/key.h" |
19 #include "chromeos/login/auth/user_context.h" | 18 #include "chromeos/login/auth/user_context.h" |
20 #include "content/public/browser/browser_thread.h" | 19 #include "chromeos/login_event_recorder.h" |
21 #include "crypto/sha2.h" | 20 #include "crypto/sha2.h" |
22 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
24 | 23 |
25 using content::BrowserThread; | |
26 | |
27 namespace chromeos { | 24 namespace chromeos { |
28 | 25 |
29 namespace { | 26 namespace { |
30 | 27 |
31 void RecordStartMarker(const std::string& marker) { | 28 void RecordStartMarker(const std::string& marker) { |
32 std::string full_marker = "Cryptohome-"; | 29 std::string full_marker = "Cryptohome-"; |
33 full_marker.append(marker); | 30 full_marker.append(marker); |
34 full_marker.append("-Start"); | 31 full_marker.append("-Start"); |
35 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(full_marker, false); | 32 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker(full_marker, false); |
36 } | 33 } |
37 | 34 |
38 void RecordEndMarker(const std::string& marker) { | 35 void RecordEndMarker(const std::string& marker) { |
39 std::string full_marker = "Cryptohome-"; | 36 std::string full_marker = "Cryptohome-"; |
40 full_marker.append(marker); | 37 full_marker.append(marker); |
41 full_marker.append("-End"); | 38 full_marker.append("-End"); |
42 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(full_marker, false); | 39 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker(full_marker, false); |
43 } | 40 } |
44 | 41 |
45 } // namespace | 42 } // namespace |
46 | 43 |
47 ExtendedAuthenticator::ExtendedAuthenticator(NewAuthStatusConsumer* consumer) | 44 ExtendedAuthenticator::ExtendedAuthenticator(NewAuthStatusConsumer* consumer) |
48 : salt_obtained_(false), consumer_(consumer), old_consumer_(NULL) { | 45 : salt_obtained_(false), consumer_(consumer), old_consumer_(NULL) { |
49 SystemSaltGetter::Get()->GetSystemSalt( | 46 SystemSaltGetter::Get()->GetSystemSalt( |
50 base::Bind(&ExtendedAuthenticator::OnSaltObtained, this)); | 47 base::Bind(&ExtendedAuthenticator::OnSaltObtained, this)); |
51 } | 48 } |
52 | 49 |
53 ExtendedAuthenticator::ExtendedAuthenticator(AuthStatusConsumer* consumer) | 50 ExtendedAuthenticator::ExtendedAuthenticator(AuthStatusConsumer* consumer) |
54 : salt_obtained_(false), consumer_(NULL), old_consumer_(consumer) { | 51 : salt_obtained_(false), consumer_(NULL), old_consumer_(consumer) { |
55 SystemSaltGetter::Get()->GetSystemSalt( | 52 SystemSaltGetter::Get()->GetSystemSalt( |
56 base::Bind(&ExtendedAuthenticator::OnSaltObtained, this)); | 53 base::Bind(&ExtendedAuthenticator::OnSaltObtained, this)); |
57 } | 54 } |
58 | 55 |
59 void ExtendedAuthenticator::SetConsumer(AuthStatusConsumer* consumer) { | 56 void ExtendedAuthenticator::SetConsumer(AuthStatusConsumer* consumer) { |
60 old_consumer_ = consumer; | 57 old_consumer_ = consumer; |
61 } | 58 } |
62 | 59 |
63 void ExtendedAuthenticator::AuthenticateToMount( | 60 void ExtendedAuthenticator::AuthenticateToMount( |
64 const UserContext& context, | 61 const UserContext& context, |
65 const ResultCallback& success_callback) { | 62 const ResultCallback& success_callback) { |
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
67 TransformKeyIfNeeded(context, | 63 TransformKeyIfNeeded(context, |
68 base::Bind(&ExtendedAuthenticator::DoAuthenticateToMount, | 64 base::Bind(&ExtendedAuthenticator::DoAuthenticateToMount, |
69 this, | 65 this, |
70 success_callback)); | 66 success_callback)); |
71 } | 67 } |
72 | 68 |
73 void ExtendedAuthenticator::AuthenticateToCheck( | 69 void ExtendedAuthenticator::AuthenticateToCheck( |
74 const UserContext& context, | 70 const UserContext& context, |
75 const base::Closure& success_callback) { | 71 const base::Closure& success_callback) { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
77 TransformKeyIfNeeded(context, | 72 TransformKeyIfNeeded(context, |
78 base::Bind(&ExtendedAuthenticator::DoAuthenticateToCheck, | 73 base::Bind(&ExtendedAuthenticator::DoAuthenticateToCheck, |
79 this, | 74 this, |
80 success_callback)); | 75 success_callback)); |
81 } | 76 } |
82 | 77 |
83 void ExtendedAuthenticator::CreateMount( | 78 void ExtendedAuthenticator::CreateMount( |
84 const std::string& user_id, | 79 const std::string& user_id, |
85 const std::vector<cryptohome::KeyDefinition>& keys, | 80 const std::vector<cryptohome::KeyDefinition>& keys, |
86 const ResultCallback& success_callback) { | 81 const ResultCallback& success_callback) { |
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
88 | |
89 RecordStartMarker("MountEx"); | 82 RecordStartMarker("MountEx"); |
90 | 83 |
91 std::string canonicalized = gaia::CanonicalizeEmail(user_id); | 84 std::string canonicalized = gaia::CanonicalizeEmail(user_id); |
92 cryptohome::Identification id(canonicalized); | 85 cryptohome::Identification id(canonicalized); |
93 cryptohome::Authorization auth(keys.front()); | 86 cryptohome::Authorization auth(keys.front()); |
94 cryptohome::MountParameters mount(false); | 87 cryptohome::MountParameters mount(false); |
95 for (size_t i = 0; i < keys.size(); i++) { | 88 for (size_t i = 0; i < keys.size(); i++) { |
96 mount.create_keys.push_back(keys[i]); | 89 mount.create_keys.push_back(keys[i]); |
97 } | 90 } |
98 UserContext context(user_id); | 91 UserContext context(user_id); |
99 Key key(keys.front().key); | 92 Key key(keys.front().key); |
100 key.SetLabel(keys.front().label); | 93 key.SetLabel(keys.front().label); |
101 context.SetKey(key); | 94 context.SetKey(key); |
102 | 95 |
103 cryptohome::HomedirMethods::GetInstance()->MountEx( | 96 cryptohome::HomedirMethods::GetInstance()->MountEx( |
104 id, | 97 id, |
105 auth, | 98 auth, |
106 mount, | 99 mount, |
107 base::Bind(&ExtendedAuthenticator::OnMountComplete, | 100 base::Bind(&ExtendedAuthenticator::OnMountComplete, |
108 this, | 101 this, |
109 "MountEx", | 102 "MountEx", |
110 context, | 103 context, |
111 success_callback)); | 104 success_callback)); |
112 } | 105 } |
113 | 106 |
114 void ExtendedAuthenticator::AddKey(const UserContext& context, | 107 void ExtendedAuthenticator::AddKey(const UserContext& context, |
115 const cryptohome::KeyDefinition& key, | 108 const cryptohome::KeyDefinition& key, |
116 bool replace_existing, | 109 bool replace_existing, |
117 const base::Closure& success_callback) { | 110 const base::Closure& success_callback) { |
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
119 TransformKeyIfNeeded(context, | 111 TransformKeyIfNeeded(context, |
120 base::Bind(&ExtendedAuthenticator::DoAddKey, | 112 base::Bind(&ExtendedAuthenticator::DoAddKey, |
121 this, | 113 this, |
122 key, | 114 key, |
123 replace_existing, | 115 replace_existing, |
124 success_callback)); | 116 success_callback)); |
125 } | 117 } |
126 | 118 |
127 void ExtendedAuthenticator::UpdateKeyAuthorized( | 119 void ExtendedAuthenticator::UpdateKeyAuthorized( |
128 const UserContext& context, | 120 const UserContext& context, |
129 const cryptohome::KeyDefinition& key, | 121 const cryptohome::KeyDefinition& key, |
130 const std::string& signature, | 122 const std::string& signature, |
131 const base::Closure& success_callback) { | 123 const base::Closure& success_callback) { |
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
133 TransformKeyIfNeeded(context, | 124 TransformKeyIfNeeded(context, |
134 base::Bind(&ExtendedAuthenticator::DoUpdateKeyAuthorized, | 125 base::Bind(&ExtendedAuthenticator::DoUpdateKeyAuthorized, |
135 this, | 126 this, |
136 key, | 127 key, |
137 signature, | 128 signature, |
138 success_callback)); | 129 success_callback)); |
139 } | 130 } |
140 | 131 |
141 void ExtendedAuthenticator::RemoveKey(const UserContext& context, | 132 void ExtendedAuthenticator::RemoveKey(const UserContext& context, |
142 const std::string& key_to_remove, | 133 const std::string& key_to_remove, |
143 const base::Closure& success_callback) { | 134 const base::Closure& success_callback) { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
145 TransformKeyIfNeeded(context, | 135 TransformKeyIfNeeded(context, |
146 base::Bind(&ExtendedAuthenticator::DoRemoveKey, | 136 base::Bind(&ExtendedAuthenticator::DoRemoveKey, |
147 this, | 137 this, |
148 key_to_remove, | 138 key_to_remove, |
149 success_callback)); | 139 success_callback)); |
150 } | 140 } |
151 | 141 |
152 void ExtendedAuthenticator::TransformKeyIfNeeded( | 142 void ExtendedAuthenticator::TransformKeyIfNeeded( |
153 const UserContext& user_context, | 143 const UserContext& user_context, |
154 const ContextCallback& callback) { | 144 const ContextCallback& callback) { |
155 if (user_context.GetKey()->GetKeyType() != Key::KEY_TYPE_PASSWORD_PLAIN) { | 145 if (user_context.GetKey()->GetKeyType() != Key::KEY_TYPE_PASSWORD_PLAIN) { |
156 callback.Run(user_context); | 146 callback.Run(user_context); |
157 return; | 147 return; |
158 } | 148 } |
159 | 149 |
160 if (!salt_obtained_) { | 150 if (!salt_obtained_) { |
161 system_salt_callbacks_.push_back(base::Bind( | 151 system_salt_callbacks_.push_back( |
162 &ExtendedAuthenticator::TransformKeyIfNeeded, | 152 base::Bind(&ExtendedAuthenticator::TransformKeyIfNeeded, |
163 this, | 153 this, |
164 user_context, | 154 user_context, |
165 callback)); | 155 callback)); |
166 return; | 156 return; |
167 } | 157 } |
168 | 158 |
169 UserContext transformed_context = user_context; | 159 UserContext transformed_context = user_context; |
170 transformed_context.GetKey()->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 160 transformed_context.GetKey()->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
171 system_salt_); | 161 system_salt_); |
172 callback.Run(transformed_context); | 162 callback.Run(transformed_context); |
173 } | 163 } |
174 | 164 |
175 ExtendedAuthenticator::~ExtendedAuthenticator() { | 165 ExtendedAuthenticator::~ExtendedAuthenticator() { |
176 } | 166 } |
177 | 167 |
178 void ExtendedAuthenticator::OnSaltObtained(const std::string& system_salt) { | 168 void ExtendedAuthenticator::OnSaltObtained(const std::string& system_salt) { |
179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
180 | |
181 salt_obtained_ = true; | 169 salt_obtained_ = true; |
182 system_salt_ = system_salt; | 170 system_salt_ = system_salt; |
183 for (std::vector<base::Closure>::const_iterator it = | 171 for (std::vector<base::Closure>::const_iterator it = |
184 system_salt_callbacks_.begin(); | 172 system_salt_callbacks_.begin(); |
185 it != system_salt_callbacks_.end(); ++it) { | 173 it != system_salt_callbacks_.end(); |
| 174 ++it) { |
186 it->Run(); | 175 it->Run(); |
187 } | 176 } |
188 system_salt_callbacks_.clear(); | 177 system_salt_callbacks_.clear(); |
189 } | 178 } |
190 | 179 |
191 void ExtendedAuthenticator::DoAuthenticateToMount( | 180 void ExtendedAuthenticator::DoAuthenticateToMount( |
192 const ResultCallback& success_callback, | 181 const ResultCallback& success_callback, |
193 const UserContext& user_context) { | 182 const UserContext& user_context) { |
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
195 | |
196 RecordStartMarker("MountEx"); | 183 RecordStartMarker("MountEx"); |
197 | 184 |
198 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); | 185 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); |
199 cryptohome::Identification id(canonicalized); | 186 cryptohome::Identification id(canonicalized); |
200 const Key* const key = user_context.GetKey(); | 187 const Key* const key = user_context.GetKey(); |
201 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); | 188 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); |
202 cryptohome::MountParameters mount(false); | 189 cryptohome::MountParameters mount(false); |
203 | 190 |
204 cryptohome::HomedirMethods::GetInstance()->MountEx( | 191 cryptohome::HomedirMethods::GetInstance()->MountEx( |
205 id, | 192 id, |
206 auth, | 193 auth, |
207 mount, | 194 mount, |
208 base::Bind(&ExtendedAuthenticator::OnMountComplete, | 195 base::Bind(&ExtendedAuthenticator::OnMountComplete, |
209 this, | 196 this, |
210 "MountEx", | 197 "MountEx", |
211 user_context, | 198 user_context, |
212 success_callback)); | 199 success_callback)); |
213 } | 200 } |
214 | 201 |
215 void ExtendedAuthenticator::DoAuthenticateToCheck( | 202 void ExtendedAuthenticator::DoAuthenticateToCheck( |
216 const base::Closure& success_callback, | 203 const base::Closure& success_callback, |
217 const UserContext& user_context) { | 204 const UserContext& user_context) { |
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
219 | |
220 RecordStartMarker("CheckKeyEx"); | 205 RecordStartMarker("CheckKeyEx"); |
221 | 206 |
222 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); | 207 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); |
223 cryptohome::Identification id(canonicalized); | 208 cryptohome::Identification id(canonicalized); |
224 const Key* const key = user_context.GetKey(); | 209 const Key* const key = user_context.GetKey(); |
225 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); | 210 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); |
226 | 211 |
227 cryptohome::HomedirMethods::GetInstance()->CheckKeyEx( | 212 cryptohome::HomedirMethods::GetInstance()->CheckKeyEx( |
228 id, | 213 id, |
229 auth, | 214 auth, |
230 base::Bind(&ExtendedAuthenticator::OnOperationComplete, | 215 base::Bind(&ExtendedAuthenticator::OnOperationComplete, |
231 this, | 216 this, |
232 "CheckKeyEx", | 217 "CheckKeyEx", |
233 user_context, | 218 user_context, |
234 success_callback)); | 219 success_callback)); |
235 } | 220 } |
236 | 221 |
237 void ExtendedAuthenticator::DoAddKey(const cryptohome::KeyDefinition& key, | 222 void ExtendedAuthenticator::DoAddKey(const cryptohome::KeyDefinition& key, |
238 bool replace_existing, | 223 bool replace_existing, |
239 const base::Closure& success_callback, | 224 const base::Closure& success_callback, |
240 const UserContext& user_context) { | 225 const UserContext& user_context) { |
241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
242 | |
243 RecordStartMarker("AddKeyEx"); | 226 RecordStartMarker("AddKeyEx"); |
244 | 227 |
245 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); | 228 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); |
246 cryptohome::Identification id(canonicalized); | 229 cryptohome::Identification id(canonicalized); |
247 const Key* const auth_key = user_context.GetKey(); | 230 const Key* const auth_key = user_context.GetKey(); |
248 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); | 231 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); |
249 | 232 |
250 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( | 233 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( |
251 id, | 234 id, |
252 auth, | 235 auth, |
253 key, | 236 key, |
254 replace_existing, | 237 replace_existing, |
255 base::Bind(&ExtendedAuthenticator::OnOperationComplete, | 238 base::Bind(&ExtendedAuthenticator::OnOperationComplete, |
256 this, | 239 this, |
257 "AddKeyEx", | 240 "AddKeyEx", |
258 user_context, | 241 user_context, |
259 success_callback)); | 242 success_callback)); |
260 } | 243 } |
261 | 244 |
262 void ExtendedAuthenticator::DoUpdateKeyAuthorized( | 245 void ExtendedAuthenticator::DoUpdateKeyAuthorized( |
263 const cryptohome::KeyDefinition& key, | 246 const cryptohome::KeyDefinition& key, |
264 const std::string& signature, | 247 const std::string& signature, |
265 const base::Closure& success_callback, | 248 const base::Closure& success_callback, |
266 const UserContext& user_context) { | 249 const UserContext& user_context) { |
267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
268 RecordStartMarker("UpdateKeyAuthorized"); | 250 RecordStartMarker("UpdateKeyAuthorized"); |
269 | 251 |
270 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); | 252 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); |
271 cryptohome::Identification id(canonicalized); | 253 cryptohome::Identification id(canonicalized); |
272 const Key* const auth_key = user_context.GetKey(); | 254 const Key* const auth_key = user_context.GetKey(); |
273 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); | 255 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); |
274 | 256 |
275 cryptohome::HomedirMethods::GetInstance()->UpdateKeyEx( | 257 cryptohome::HomedirMethods::GetInstance()->UpdateKeyEx( |
276 id, | 258 id, |
277 auth, | 259 auth, |
278 key, | 260 key, |
279 signature, | 261 signature, |
280 base::Bind(&ExtendedAuthenticator::OnOperationComplete, | 262 base::Bind(&ExtendedAuthenticator::OnOperationComplete, |
281 this, | 263 this, |
282 "UpdateKeyAuthorized", | 264 "UpdateKeyAuthorized", |
283 user_context, | 265 user_context, |
284 success_callback)); | 266 success_callback)); |
285 } | 267 } |
286 | 268 |
287 void ExtendedAuthenticator::DoRemoveKey(const std::string& key_to_remove, | 269 void ExtendedAuthenticator::DoRemoveKey(const std::string& key_to_remove, |
288 const base::Closure& success_callback, | 270 const base::Closure& success_callback, |
289 const UserContext& user_context) { | 271 const UserContext& user_context) { |
290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
291 | |
292 RecordStartMarker("RemoveKeyEx"); | 272 RecordStartMarker("RemoveKeyEx"); |
293 | 273 |
294 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); | 274 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); |
295 cryptohome::Identification id(canonicalized); | 275 cryptohome::Identification id(canonicalized); |
296 const Key* const auth_key = user_context.GetKey(); | 276 const Key* const auth_key = user_context.GetKey(); |
297 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); | 277 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); |
298 | 278 |
299 cryptohome::HomedirMethods::GetInstance()->RemoveKeyEx( | 279 cryptohome::HomedirMethods::GetInstance()->RemoveKeyEx( |
300 id, | 280 id, |
301 auth, | 281 auth, |
302 key_to_remove, | 282 key_to_remove, |
303 base::Bind(&ExtendedAuthenticator::OnOperationComplete, | 283 base::Bind(&ExtendedAuthenticator::OnOperationComplete, |
304 this, | 284 this, |
305 "RemoveKeyEx", | 285 "RemoveKeyEx", |
306 user_context, | 286 user_context, |
307 success_callback)); | 287 success_callback)); |
308 } | 288 } |
309 | 289 |
310 void ExtendedAuthenticator::OnMountComplete( | 290 void ExtendedAuthenticator::OnMountComplete( |
311 const std::string& time_marker, | 291 const std::string& time_marker, |
312 const UserContext& user_context, | 292 const UserContext& user_context, |
313 const ResultCallback& success_callback, | 293 const ResultCallback& success_callback, |
314 bool success, | 294 bool success, |
315 cryptohome::MountError return_code, | 295 cryptohome::MountError return_code, |
316 const std::string& mount_hash) { | 296 const std::string& mount_hash) { |
317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
318 | |
319 RecordEndMarker(time_marker); | 297 RecordEndMarker(time_marker); |
320 UserContext copy = user_context; | 298 UserContext copy = user_context; |
321 copy.SetUserIDHash(mount_hash); | 299 copy.SetUserIDHash(mount_hash); |
322 if (return_code == cryptohome::MOUNT_ERROR_NONE) { | 300 if (return_code == cryptohome::MOUNT_ERROR_NONE) { |
323 if (!success_callback.is_null()) | 301 if (!success_callback.is_null()) |
324 success_callback.Run(mount_hash); | 302 success_callback.Run(mount_hash); |
325 if (old_consumer_) | 303 if (old_consumer_) |
326 old_consumer_->OnAuthSuccess(copy); | 304 old_consumer_->OnAuthSuccess(copy); |
327 return; | 305 return; |
328 } | 306 } |
(...skipping 13 matching lines...) Expand all Loading... |
342 old_consumer_->OnAuthFailure(failure); | 320 old_consumer_->OnAuthFailure(failure); |
343 } | 321 } |
344 } | 322 } |
345 | 323 |
346 void ExtendedAuthenticator::OnOperationComplete( | 324 void ExtendedAuthenticator::OnOperationComplete( |
347 const std::string& time_marker, | 325 const std::string& time_marker, |
348 const UserContext& user_context, | 326 const UserContext& user_context, |
349 const base::Closure& success_callback, | 327 const base::Closure& success_callback, |
350 bool success, | 328 bool success, |
351 cryptohome::MountError return_code) { | 329 cryptohome::MountError return_code) { |
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
353 | |
354 RecordEndMarker(time_marker); | 330 RecordEndMarker(time_marker); |
355 if (return_code == cryptohome::MOUNT_ERROR_NONE) { | 331 if (return_code == cryptohome::MOUNT_ERROR_NONE) { |
356 if (!success_callback.is_null()) | 332 if (!success_callback.is_null()) |
357 success_callback.Run(); | 333 success_callback.Run(); |
358 if (old_consumer_) | 334 if (old_consumer_) |
359 old_consumer_->OnAuthSuccess(user_context); | 335 old_consumer_->OnAuthSuccess(user_context); |
360 return; | 336 return; |
361 } | 337 } |
362 | 338 |
363 AuthState state = FAILED_MOUNT; | 339 AuthState state = FAILED_MOUNT; |
(...skipping 10 matching lines...) Expand all Loading... |
374 if (consumer_) | 350 if (consumer_) |
375 consumer_->OnAuthenticationFailure(state); | 351 consumer_->OnAuthenticationFailure(state); |
376 | 352 |
377 if (old_consumer_) { | 353 if (old_consumer_) { |
378 AuthFailure failure(AuthFailure::UNLOCK_FAILED); | 354 AuthFailure failure(AuthFailure::UNLOCK_FAILED); |
379 old_consumer_->OnAuthFailure(failure); | 355 old_consumer_->OnAuthFailure(failure); |
380 } | 356 } |
381 } | 357 } |
382 | 358 |
383 } // namespace chromeos | 359 } // namespace chromeos |
OLD | NEW |