| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/sha2.h" | 14 #include "base/sha2.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/third_party/nss/blapi.h" | 16 #include "base/third_party/nss/blapi.h" |
| 17 #include "base/third_party/nss/sha256.h" | 17 #include "base/third_party/nss/sha256.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chrome_thread.h" | 19 #include "chrome/browser/chrome_thread.h" |
| 20 #include "chrome/browser/chromeos/browser_notification_observers.h" |
| 20 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 21 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 21 #include "chrome/browser/chromeos/login/auth_response_handler.h" | 22 #include "chrome/browser/chromeos/login/auth_response_handler.h" |
| 22 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 23 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
| 23 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 24 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
| 24 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
| 25 #include "chrome/browser/profile_manager.h" | 26 #include "chrome/browser/profile_manager.h" |
| 26 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/net/gaia/gaia_authenticator2.h" | 28 #include "chrome/common/net/gaia/gaia_authenticator2.h" |
| 28 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
| 29 #include "net/base/load_flags.h" | 30 #include "net/base/load_flags.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 47 const int GoogleAuthenticator::kClientLoginTimeoutMs = 5000; | 48 const int GoogleAuthenticator::kClientLoginTimeoutMs = 5000; |
| 48 | 49 |
| 49 const int kPassHashLen = 32; | 50 const int kPassHashLen = 32; |
| 50 | 51 |
| 51 GoogleAuthenticator::GoogleAuthenticator(LoginStatusConsumer* consumer) | 52 GoogleAuthenticator::GoogleAuthenticator(LoginStatusConsumer* consumer) |
| 52 : Authenticator(consumer), | 53 : Authenticator(consumer), |
| 53 checked_for_localaccount_(false), | 54 checked_for_localaccount_(false), |
| 54 unlock_(false), | 55 unlock_(false), |
| 55 try_again_(true) { | 56 try_again_(true) { |
| 56 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); | 57 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); |
| 58 |
| 59 // This forces the creation of the login notification observer |
| 60 // singleton. It must be created to record login time. |
| 61 chromeos::LogLoginSuccessObserver::Get(); |
| 57 } | 62 } |
| 58 | 63 |
| 59 GoogleAuthenticator::~GoogleAuthenticator() {} | 64 GoogleAuthenticator::~GoogleAuthenticator() {} |
| 60 | 65 |
| 61 void GoogleAuthenticator::CancelClientLogin() { | 66 void GoogleAuthenticator::CancelClientLogin() { |
| 62 if (gaia_authenticator_->HasPendingFetch()) { | 67 if (gaia_authenticator_->HasPendingFetch()) { |
| 63 gaia_authenticator_->CancelRequest(); | 68 gaia_authenticator_->CancelRequest(); |
| 64 OnLoginFailure("Login has timed out; please try again!"); | 69 OnLoginFailure("Login has timed out; please try again!"); |
| 65 } | 70 } |
| 66 } | 71 } |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; | 381 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; |
| 377 RemoveChars(parts[0], ".", &parts[0]); | 382 RemoveChars(parts[0], ".", &parts[0]); |
| 378 if (parts[0].find('+') != std::string::npos) | 383 if (parts[0].find('+') != std::string::npos) |
| 379 parts[0].erase(parts[0].find('+')); | 384 parts[0].erase(parts[0].find('+')); |
| 380 std::string new_email = StringToLowerASCII(JoinString(parts, at)); | 385 std::string new_email = StringToLowerASCII(JoinString(parts, at)); |
| 381 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; | 386 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; |
| 382 return new_email; | 387 return new_email; |
| 383 } | 388 } |
| 384 | 389 |
| 385 } // namespace chromeos | 390 } // namespace chromeos |
| OLD | NEW |