OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/google_authenticator.h" | 5 #include "chrome/browser/chromeos/login/google_authenticator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 LoginFailure(LoginFailure::UNLOCK_FAILED))); | 158 LoginFailure(LoginFailure::UNLOCK_FAILED))); |
159 return true; | 159 return true; |
160 } | 160 } |
161 | 161 |
162 void GoogleAuthenticator::LoginOffTheRecord() { | 162 void GoogleAuthenticator::LoginOffTheRecord() { |
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
164 int mount_error = chromeos::kCryptohomeMountErrorNone; | 164 int mount_error = chromeos::kCryptohomeMountErrorNone; |
165 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { | 165 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { |
166 AuthenticationNotificationDetails details(true); | 166 AuthenticationNotificationDetails details(true); |
167 NotificationService::current()->Notify( | 167 NotificationService::current()->Notify( |
168 NotificationType::LOGIN_AUTHENTICATION, | 168 chrome::LOGIN_AUTHENTICATION, |
169 NotificationService::AllSources(), | 169 NotificationService::AllSources(), |
170 Details<AuthenticationNotificationDetails>(&details)); | 170 Details<AuthenticationNotificationDetails>(&details)); |
171 consumer_->OnOffTheRecordLoginSuccess(); | 171 consumer_->OnOffTheRecordLoginSuccess(); |
172 } else { | 172 } else { |
173 LOG(ERROR) << "Could not mount tmpfs: " << mount_error; | 173 LOG(ERROR) << "Could not mount tmpfs: " << mount_error; |
174 consumer_->OnLoginFailure( | 174 consumer_->OnLoginFailure( |
175 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); | 175 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 &GoogleAuthenticator::CheckLocalaccount, | 268 &GoogleAuthenticator::CheckLocalaccount, |
269 failure_details)); | 269 failure_details)); |
270 } | 270 } |
271 | 271 |
272 void GoogleAuthenticator::OnLoginSuccess( | 272 void GoogleAuthenticator::OnLoginSuccess( |
273 const GaiaAuthConsumer::ClientLoginResult& credentials, | 273 const GaiaAuthConsumer::ClientLoginResult& credentials, |
274 bool request_pending) { | 274 bool request_pending) { |
275 // Send notification of success | 275 // Send notification of success |
276 AuthenticationNotificationDetails details(true); | 276 AuthenticationNotificationDetails details(true); |
277 NotificationService::current()->Notify( | 277 NotificationService::current()->Notify( |
278 NotificationType::LOGIN_AUTHENTICATION, | 278 chrome::LOGIN_AUTHENTICATION, |
279 NotificationService::AllSources(), | 279 NotificationService::AllSources(), |
280 Details<AuthenticationNotificationDetails>(&details)); | 280 Details<AuthenticationNotificationDetails>(&details)); |
281 | 281 |
282 int mount_error = chromeos::kCryptohomeMountErrorNone; | 282 int mount_error = chromeos::kCryptohomeMountErrorNone; |
283 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounting", false); | 283 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounting", false); |
284 if (unlock_ || | 284 if (unlock_ || |
285 (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), | 285 (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), |
286 ascii_hash_.c_str(), | 286 ascii_hash_.c_str(), |
287 &mount_error))) { | 287 &mount_error))) { |
288 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounted", true); | 288 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounted", true); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 } else { | 344 } else { |
345 OnLoginFailure(error); | 345 OnLoginFailure(error); |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 void GoogleAuthenticator::OnLoginFailure(const LoginFailure& error) { | 349 void GoogleAuthenticator::OnLoginFailure(const LoginFailure& error) { |
350 // Send notification of failure | 350 // Send notification of failure |
351 AuthenticationNotificationDetails details(false); | 351 AuthenticationNotificationDetails details(false); |
352 NotificationService::current()->Notify( | 352 NotificationService::current()->Notify( |
353 NotificationType::LOGIN_AUTHENTICATION, | 353 chrome::LOGIN_AUTHENTICATION, |
354 NotificationService::AllSources(), | 354 NotificationService::AllSources(), |
355 Details<AuthenticationNotificationDetails>(&details)); | 355 Details<AuthenticationNotificationDetails>(&details)); |
356 LOG(WARNING) << "Login failed: " << error.GetErrorString(); | 356 LOG(WARNING) << "Login failed: " << error.GetErrorString(); |
357 consumer_->OnLoginFailure(error); | 357 consumer_->OnLoginFailure(error); |
358 } | 358 } |
359 | 359 |
360 void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, | 360 void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, |
361 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 361 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
362 | 362 |
363 std::string old_hash = HashPassword(old_password); | 363 std::string old_hash = HashPassword(old_password); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 const unsigned int len) { | 479 const unsigned int len) { |
480 if (len < 2*binary_len) | 480 if (len < 2*binary_len) |
481 return false; | 481 return false; |
482 memset(hex_string, 0, len); | 482 memset(hex_string, 0, len); |
483 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) | 483 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) |
484 snprintf(hex_string + j, len - j, "%02x", binary[i]); | 484 snprintf(hex_string + j, len - j, "%02x", binary[i]); |
485 return true; | 485 return true; |
486 } | 486 } |
487 | 487 |
488 } // namespace chromeos | 488 } // namespace chromeos |
OLD | NEW |