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/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 22 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
23 #include "chrome/browser/chromeos/login/ownership_service.h" | 23 #include "chrome/browser/chromeos/login/ownership_service.h" |
24 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 29 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
30 #include "chrome/common/net/gaia/gaia_constants.h" | 30 #include "chrome/common/net/gaia/gaia_constants.h" |
31 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
32 #include "content/common/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
33 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
34 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
35 #include "net/url_request/url_request_status.h" | 35 #include "net/url_request/url_request_status.h" |
36 #include "third_party/libjingle/source/talk/base/urlencode.h" | 36 #include "third_party/libjingle/source/talk/base/urlencode.h" |
37 | 37 |
38 using base::Time; | 38 using base::Time; |
39 using base::TimeDelta; | 39 using base::TimeDelta; |
40 using file_util::GetFileSize; | 40 using file_util::GetFileSize; |
41 using file_util::PathExists; | 41 using file_util::PathExists; |
42 using file_util::ReadFile; | 42 using file_util::ReadFile; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 BrowserThread::UI, FROM_HERE, | 166 BrowserThread::UI, FROM_HERE, |
167 base::Bind(&GoogleAuthenticator::CheckOffline, this, | 167 base::Bind(&GoogleAuthenticator::CheckOffline, this, |
168 LoginFailure(LoginFailure::UNLOCK_FAILED))); | 168 LoginFailure(LoginFailure::UNLOCK_FAILED))); |
169 } | 169 } |
170 | 170 |
171 void GoogleAuthenticator::LoginOffTheRecord() { | 171 void GoogleAuthenticator::LoginOffTheRecord() { |
172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
173 int mount_error = chromeos::kCryptohomeMountErrorNone; | 173 int mount_error = chromeos::kCryptohomeMountErrorNone; |
174 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { | 174 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { |
175 AuthenticationNotificationDetails details(true); | 175 AuthenticationNotificationDetails details(true); |
176 NotificationService::current()->Notify( | 176 content::NotificationService::current()->Notify( |
177 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 177 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
178 NotificationService::AllSources(), | 178 content::NotificationService::AllSources(), |
179 content::Details<AuthenticationNotificationDetails>(&details)); | 179 content::Details<AuthenticationNotificationDetails>(&details)); |
180 consumer_->OnOffTheRecordLoginSuccess(); | 180 consumer_->OnOffTheRecordLoginSuccess(); |
181 } else { | 181 } else { |
182 LOG(ERROR) << "Could not mount tmpfs: " << mount_error; | 182 LOG(ERROR) << "Could not mount tmpfs: " << mount_error; |
183 consumer_->OnLoginFailure( | 183 consumer_->OnLoginFailure( |
184 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); | 184 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 void GoogleAuthenticator::OnClientLoginSuccess( | 188 void GoogleAuthenticator::OnClientLoginSuccess( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 BrowserThread::UI, FROM_HERE, | 271 BrowserThread::UI, FROM_HERE, |
272 base::Bind(&GoogleAuthenticator::CheckLocalaccount, this, | 272 base::Bind(&GoogleAuthenticator::CheckLocalaccount, this, |
273 failure_details)); | 273 failure_details)); |
274 } | 274 } |
275 | 275 |
276 void GoogleAuthenticator::OnLoginSuccess( | 276 void GoogleAuthenticator::OnLoginSuccess( |
277 const GaiaAuthConsumer::ClientLoginResult& credentials, | 277 const GaiaAuthConsumer::ClientLoginResult& credentials, |
278 bool request_pending) { | 278 bool request_pending) { |
279 // Send notification of success | 279 // Send notification of success |
280 AuthenticationNotificationDetails details(true); | 280 AuthenticationNotificationDetails details(true); |
281 NotificationService::current()->Notify( | 281 content::NotificationService::current()->Notify( |
282 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 282 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
283 NotificationService::AllSources(), | 283 content::NotificationService::AllSources(), |
284 content::Details<AuthenticationNotificationDetails>(&details)); | 284 content::Details<AuthenticationNotificationDetails>(&details)); |
285 | 285 |
286 int mount_error = chromeos::kCryptohomeMountErrorNone; | 286 int mount_error = chromeos::kCryptohomeMountErrorNone; |
287 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounting", false); | 287 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounting", false); |
288 if (unlock_ || | 288 if (unlock_ || |
289 (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), | 289 (CrosLibrary::Get()->GetCryptohomeLibrary()->Mount(username_.c_str(), |
290 ascii_hash_.c_str(), | 290 ascii_hash_.c_str(), |
291 &mount_error))) { | 291 &mount_error))) { |
292 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounted", true); | 292 BootTimesLoader::Get()->AddLoginTimeMarker("CryptohomeMounted", true); |
293 consumer_->OnLoginSuccess(username_, | 293 consumer_->OnLoginSuccess(username_, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); | 346 LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)); |
347 } | 347 } |
348 } else { | 348 } else { |
349 OnLoginFailure(error); | 349 OnLoginFailure(error); |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 void GoogleAuthenticator::OnLoginFailure(const LoginFailure& error) { | 353 void GoogleAuthenticator::OnLoginFailure(const LoginFailure& error) { |
354 // Send notification of failure | 354 // Send notification of failure |
355 AuthenticationNotificationDetails details(false); | 355 AuthenticationNotificationDetails details(false); |
356 NotificationService::current()->Notify( | 356 content::NotificationService::current()->Notify( |
357 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 357 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
358 NotificationService::AllSources(), | 358 content::NotificationService::AllSources(), |
359 content::Details<AuthenticationNotificationDetails>(&details)); | 359 content::Details<AuthenticationNotificationDetails>(&details)); |
360 LOG(WARNING) << "Login failed: " << error.GetErrorString(); | 360 LOG(WARNING) << "Login failed: " << error.GetErrorString(); |
361 consumer_->OnLoginFailure(error); | 361 consumer_->OnLoginFailure(error); |
362 } | 362 } |
363 | 363 |
364 void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, | 364 void GoogleAuthenticator::RecoverEncryptedData(const std::string& old_password, |
365 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 365 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
366 | 366 |
367 std::string old_hash = HashPassword(old_password); | 367 std::string old_hash = HashPassword(old_password); |
368 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MigrateKey(username_, | 368 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MigrateKey(username_, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const unsigned int len) { | 494 const unsigned int len) { |
495 if (len < 2*binary_len) | 495 if (len < 2*binary_len) |
496 return false; | 496 return false; |
497 memset(hex_string, 0, len); | 497 memset(hex_string, 0, len); |
498 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) | 498 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) |
499 snprintf(hex_string + j, len - j, "%02x", binary[i]); | 499 snprintf(hex_string + j, len - j, "%02x", binary[i]); |
500 return true; | 500 return true; |
501 } | 501 } |
502 | 502 |
503 } // namespace chromeos | 503 } // namespace chromeos |
OLD | NEW |