| 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/certificate_manager_model.h" | 5 #include "chrome/browser/certificate_manager_model.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 bool is_extractable) { | 114 bool is_extractable) { |
| 115 int result = cert_db_.ImportFromPKCS12(module, data, password, | 115 int result = cert_db_.ImportFromPKCS12(module, data, password, |
| 116 is_extractable, NULL); | 116 is_extractable, NULL); |
| 117 if (result == net::OK) | 117 if (result == net::OK) |
| 118 Refresh(); | 118 Refresh(); |
| 119 return result; | 119 return result; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool CertificateManagerModel::ImportCACerts( | 122 bool CertificateManagerModel::ImportCACerts( |
| 123 const net::CertificateList& certificates, | 123 const net::CertificateList& certificates, |
| 124 net::CertDatabase::TrustBits trust_bits, | 124 net::NSSCertDatabase::TrustBits trust_bits, |
| 125 net::CertDatabase::ImportCertFailureList* not_imported) { | 125 net::NSSCertDatabase::ImportCertFailureList* not_imported) { |
| 126 bool result = cert_db_.ImportCACerts(certificates, trust_bits, not_imported); | 126 bool result = cert_db_.ImportCACerts(certificates, trust_bits, not_imported); |
| 127 if (result && not_imported->size() != certificates.size()) | 127 if (result && not_imported->size() != certificates.size()) |
| 128 Refresh(); | 128 Refresh(); |
| 129 return result; | 129 return result; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool CertificateManagerModel::ImportServerCert( | 132 bool CertificateManagerModel::ImportServerCert( |
| 133 const net::CertificateList& certificates, | 133 const net::CertificateList& certificates, |
| 134 net::CertDatabase::TrustBits trust_bits, | 134 net::NSSCertDatabase::TrustBits trust_bits, |
| 135 net::CertDatabase::ImportCertFailureList* not_imported) { | 135 net::NSSCertDatabase::ImportCertFailureList* not_imported) { |
| 136 bool result = cert_db_.ImportServerCert(certificates, trust_bits, | 136 bool result = cert_db_.ImportServerCert(certificates, trust_bits, |
| 137 not_imported); | 137 not_imported); |
| 138 if (result && not_imported->size() != certificates.size()) | 138 if (result && not_imported->size() != certificates.size()) |
| 139 Refresh(); | 139 Refresh(); |
| 140 return result; | 140 return result; |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool CertificateManagerModel::SetCertTrust( | 143 bool CertificateManagerModel::SetCertTrust( |
| 144 const net::X509Certificate* cert, | 144 const net::X509Certificate* cert, |
| 145 net::CertType type, | 145 net::CertType type, |
| 146 net::CertDatabase::TrustBits trust_bits) { | 146 net::NSSCertDatabase::TrustBits trust_bits) { |
| 147 return cert_db_.SetCertTrust(cert, type, trust_bits); | 147 return cert_db_.SetCertTrust(cert, type, trust_bits); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool CertificateManagerModel::Delete(net::X509Certificate* cert) { | 150 bool CertificateManagerModel::Delete(net::X509Certificate* cert) { |
| 151 bool result = cert_db_.DeleteCertAndKey(cert); | 151 bool result = cert_db_.DeleteCertAndKey(cert); |
| 152 if (result) | 152 if (result) |
| 153 Refresh(); | 153 Refresh(); |
| 154 return result; | 154 return result; |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool CertificateManagerModel::IsHardwareBacked( | 157 bool CertificateManagerModel::IsHardwareBacked( |
| 158 const net::X509Certificate* cert) const { | 158 const net::X509Certificate* cert) const { |
| 159 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
| 160 return crypto::IsTPMTokenReady() && | 160 return crypto::IsTPMTokenReady() && |
| 161 cert->os_cert_handle()->slot == | 161 cert->os_cert_handle()->slot == |
| 162 cert_db().GetPrivateModule()->os_module_handle(); | 162 cert_db().GetPrivateModule()->os_module_handle(); |
| 163 #else | 163 #else |
| 164 return false; | 164 return false; |
| 165 #endif | 165 #endif |
| 166 } | 166 } |
| OLD | NEW |