| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/cert_loader.h" | 5 #include "chromeos/cert_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
| 15 #include "crypto/nss_util.h" | 15 #include "crypto/nss_util.h" |
| 16 #include "crypto/scoped_nss_types.h" |
| 16 #include "net/cert/nss_cert_database.h" | 17 #include "net/cert/nss_cert_database.h" |
| 17 #include "net/cert/nss_cert_database_chromeos.h" | 18 #include "net/cert/nss_cert_database_chromeos.h" |
| 18 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 static CertLoader* g_cert_loader = NULL; | 23 static CertLoader* g_cert_loader = NULL; |
| 23 | 24 |
| 24 // static | 25 // static |
| 25 void CertLoader::Initialize() { | 26 void CertLoader::Initialize() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 observers_.AddObserver(observer); | 80 observers_.AddObserver(observer); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void CertLoader::RemoveObserver(CertLoader::Observer* observer) { | 83 void CertLoader::RemoveObserver(CertLoader::Observer* observer) { |
| 83 observers_.RemoveObserver(observer); | 84 observers_.RemoveObserver(observer); |
| 84 } | 85 } |
| 85 | 86 |
| 86 int CertLoader::TPMTokenSlotID() const { | 87 int CertLoader::TPMTokenSlotID() const { |
| 87 if (!database_) | 88 if (!database_) |
| 88 return -1; | 89 return -1; |
| 89 return static_cast<int>(PK11_GetSlotID(database_->GetPrivateSlot().get())); | 90 crypto::ScopedPK11Slot slot(database_->GetPrivateSlot()); |
| 91 if (!slot) |
| 92 return -1; |
| 93 return static_cast<int>(PK11_GetSlotID(slot.get())); |
| 90 } | 94 } |
| 91 | 95 |
| 92 bool CertLoader::IsHardwareBacked() const { | 96 bool CertLoader::IsHardwareBacked() const { |
| 93 return force_hardware_backed_for_test_ || | 97 if (force_hardware_backed_for_test_) |
| 94 (database_ && PK11_IsHW(database_->GetPrivateSlot().get())); | 98 return true; |
| 99 if (!database_) |
| 100 return false; |
| 101 crypto::ScopedPK11Slot slot(database_->GetPrivateSlot()); |
| 102 if (!slot) |
| 103 return false; |
| 104 return PK11_IsHW(slot.get()); |
| 95 } | 105 } |
| 96 | 106 |
| 97 bool CertLoader::IsCertificateHardwareBacked( | 107 bool CertLoader::IsCertificateHardwareBacked( |
| 98 const net::X509Certificate* cert) const { | 108 const net::X509Certificate* cert) const { |
| 99 if (!database_) | 109 if (!database_) |
| 100 return false; | 110 return false; |
| 101 return database_->IsHardwareBacked(cert); | 111 return database_->IsHardwareBacked(cert); |
| 102 } | 112 } |
| 103 | 113 |
| 104 bool CertLoader::CertificatesLoading() const { | 114 bool CertLoader::CertificatesLoading() const { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 VLOG(1) << "OnCertAdded"; | 194 VLOG(1) << "OnCertAdded"; |
| 185 LoadCertificates(); | 195 LoadCertificates(); |
| 186 } | 196 } |
| 187 | 197 |
| 188 void CertLoader::OnCertRemoved(const net::X509Certificate* cert) { | 198 void CertLoader::OnCertRemoved(const net::X509Certificate* cert) { |
| 189 VLOG(1) << "OnCertRemoved"; | 199 VLOG(1) << "OnCertRemoved"; |
| 190 LoadCertificates(); | 200 LoadCertificates(); |
| 191 } | 201 } |
| 192 | 202 |
| 193 } // namespace chromeos | 203 } // namespace chromeos |
| OLD | NEW |