| OLD | NEW |
| 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 #include "chrome/browser/chromeos/login/user_manager.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 RealTPMTokenInfoDelegate::RealTPMTokenInfoDelegate() : token_ready_(false) {} | 232 RealTPMTokenInfoDelegate::RealTPMTokenInfoDelegate() : token_ready_(false) {} |
| 233 RealTPMTokenInfoDelegate::~RealTPMTokenInfoDelegate() {} | 233 RealTPMTokenInfoDelegate::~RealTPMTokenInfoDelegate() {} |
| 234 | 234 |
| 235 bool RealTPMTokenInfoDelegate::IsTokenAvailable() const { | 235 bool RealTPMTokenInfoDelegate::IsTokenAvailable() const { |
| 236 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 236 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 237 return CrosLibrary::Get()->GetCryptohomeLibrary()->TpmIsEnabled(); | 237 return CrosLibrary::Get()->GetCryptohomeLibrary()->TpmIsEnabled(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool RealTPMTokenInfoDelegate::IsTokenReady() const { | 240 bool RealTPMTokenInfoDelegate::IsTokenReady() const { |
| 241 if (token_ready_) |
| 242 return true; |
| 241 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 243 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 242 if (!token_ready_) { | 244 // Retrieve token_name_ and user_pin_ here since they will never change |
| 243 // Retrieve token_name_ and user_pin_ here since they will never change | 245 // and CryptohomeLibrary calls are not thread safe. |
| 244 // and CryptohomeLibrary calls are not thread safe. | 246 if (CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11IsTpmTokenReady()) { |
| 245 if (CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11IsTpmTokenReady()) { | 247 CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11GetTpmTokenInfo( |
| 246 CrosLibrary::Get()->GetCryptohomeLibrary()->Pkcs11GetTpmTokenInfo( | 248 &token_name_, &user_pin_); |
| 247 &token_name_, &user_pin_); | 249 token_ready_ = true; |
| 248 token_ready_ = true; | |
| 249 } | |
| 250 } | 250 } |
| 251 return token_ready_; | 251 return token_ready_; |
| 252 } | 252 } |
| 253 | 253 |
| 254 void RealTPMTokenInfoDelegate::GetTokenInfo(std::string* token_name, | 254 void RealTPMTokenInfoDelegate::GetTokenInfo(std::string* token_name, |
| 255 std::string* user_pin) const { | 255 std::string* user_pin) const { |
| 256 // May be called from a non UI thread, but must only be called after | 256 // May be called from a non UI thread, but must only be called after |
| 257 // IsTokenReady() returns true. | 257 // IsTokenReady() returns true. |
| 258 CHECK(token_ready_); | 258 CHECK(token_ready_); |
| 259 if (token_name) | 259 if (token_name) |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 | 995 |
| 996 User* UserManager::CreateUser(const std::string& email) const { | 996 User* UserManager::CreateUser(const std::string& email) const { |
| 997 User* user = new User(email, email == kGuestUser); | 997 User* user = new User(email, email == kGuestUser); |
| 998 user->set_oauth_token_status(LoadUserOAuthStatus(email)); | 998 user->set_oauth_token_status(LoadUserOAuthStatus(email)); |
| 999 // Used to determine whether user's display name is unique. | 999 // Used to determine whether user's display name is unique. |
| 1000 ++display_name_count_[user->GetDisplayName()]; | 1000 ++display_name_count_[user->GetDisplayName()]; |
| 1001 return user; | 1001 return user; |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 } // namespace chromeos | 1004 } // namespace chromeos |
| OLD | NEW |