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 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 void CertificateManagerModel::Refresh() { | 33 void CertificateManagerModel::Refresh() { |
34 VLOG(1) << "refresh started"; | 34 VLOG(1) << "refresh started"; |
35 net::CryptoModuleList modules; | 35 net::CryptoModuleList modules; |
36 cert_db_->ListModules(&modules, false); | 36 cert_db_->ListModules(&modules, false); |
37 VLOG(1) << "refresh waiting for unlocking..."; | 37 VLOG(1) << "refresh waiting for unlocking..."; |
38 chrome::UnlockSlotsIfNecessary( | 38 chrome::UnlockSlotsIfNecessary( |
39 modules, | 39 modules, |
40 chrome::kCryptoModulePasswordListCerts, | 40 chrome::kCryptoModulePasswordListCerts, |
41 "", // unused. | 41 std::string(), // unused. |
42 base::Bind(&CertificateManagerModel::RefreshSlotsUnlocked, | 42 base::Bind(&CertificateManagerModel::RefreshSlotsUnlocked, |
43 base::Unretained(this))); | 43 base::Unretained(this))); |
44 } | 44 } |
45 | 45 |
46 void CertificateManagerModel::RefreshSlotsUnlocked() { | 46 void CertificateManagerModel::RefreshSlotsUnlocked() { |
47 VLOG(1) << "refresh listing certs..."; | 47 VLOG(1) << "refresh listing certs..."; |
48 cert_db_->ListCerts(&cert_list_); | 48 cert_db_->ListCerts(&cert_list_); |
49 observer_->CertificatesRefreshed(); | 49 observer_->CertificatesRefreshed(); |
50 VLOG(1) << "refresh finished"; | 50 VLOG(1) << "refresh finished"; |
51 } | 51 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 rv, | 88 rv, |
89 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_HARDWARE_BACKED)); | 89 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_HARDWARE_BACKED)); |
90 } | 90 } |
91 #endif | 91 #endif |
92 break; | 92 break; |
93 case COL_CERTIFICATE_STORE: | 93 case COL_CERTIFICATE_STORE: |
94 rv = UTF8ToUTF16( | 94 rv = UTF8ToUTF16( |
95 x509_certificate_model::GetTokenName(cert.os_cert_handle())); | 95 x509_certificate_model::GetTokenName(cert.os_cert_handle())); |
96 break; | 96 break; |
97 case COL_SERIAL_NUMBER: | 97 case COL_SERIAL_NUMBER: |
98 rv = ASCIIToUTF16( | 98 rv = ASCIIToUTF16(x509_certificate_model::GetSerialNumberHexified( |
99 x509_certificate_model::GetSerialNumberHexified( | 99 cert.os_cert_handle(), std::string())); |
100 cert.os_cert_handle(), "")); | |
101 break; | 100 break; |
102 case COL_EXPIRES_ON: | 101 case COL_EXPIRES_ON: |
103 if (!cert.valid_expiry().is_null()) | 102 if (!cert.valid_expiry().is_null()) |
104 rv = base::TimeFormatShortDateNumeric(cert.valid_expiry()); | 103 rv = base::TimeFormatShortDateNumeric(cert.valid_expiry()); |
105 break; | 104 break; |
106 default: | 105 default: |
107 NOTREACHED(); | 106 NOTREACHED(); |
108 } | 107 } |
109 return rv; | 108 return rv; |
110 } | 109 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool CertificateManagerModel::IsHardwareBacked( | 157 bool CertificateManagerModel::IsHardwareBacked( |
159 const net::X509Certificate* cert) const { | 158 const net::X509Certificate* cert) const { |
160 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
161 return crypto::IsTPMTokenReady() && | 160 return crypto::IsTPMTokenReady() && |
162 cert->os_cert_handle()->slot == | 161 cert->os_cert_handle()->slot == |
163 cert_db_->GetPrivateModule()->os_module_handle(); | 162 cert_db_->GetPrivateModule()->os_module_handle(); |
164 #else | 163 #else |
165 return false; | 164 return false; |
166 #endif | 165 #endif |
167 } | 166 } |
OLD | NEW |