| 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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 std::string org; | 59 std::string org; |
| 60 if (!cert->subject().organization_names.empty()) | 60 if (!cert->subject().organization_names.empty()) |
| 61 org = cert->subject().organization_names[0]; | 61 org = cert->subject().organization_names[0]; |
| 62 if (org.empty()) | 62 if (org.empty()) |
| 63 org = cert->subject().GetDisplayName(); | 63 org = cert->subject().GetDisplayName(); |
| 64 | 64 |
| 65 (*map)[org].push_back(cert); | 65 (*map)[org].push_back(cert); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 string16 CertificateManagerModel::GetColumnText( | 69 base::string16 CertificateManagerModel::GetColumnText( |
| 70 const net::X509Certificate& cert, | 70 const net::X509Certificate& cert, |
| 71 Column column) const { | 71 Column column) const { |
| 72 string16 rv; | 72 base::string16 rv; |
| 73 switch (column) { | 73 switch (column) { |
| 74 case COL_SUBJECT_NAME: | 74 case COL_SUBJECT_NAME: |
| 75 rv = UTF8ToUTF16( | 75 rv = UTF8ToUTF16( |
| 76 x509_certificate_model::GetCertNameOrNickname(cert.os_cert_handle())); | 76 x509_certificate_model::GetCertNameOrNickname(cert.os_cert_handle())); |
| 77 | 77 |
| 78 // TODO(xiyuan): Put this into a column when we have js tree-table. | 78 // TODO(xiyuan): Put this into a column when we have js tree-table. |
| 79 if (IsHardwareBacked(&cert)) { | 79 if (IsHardwareBacked(&cert)) { |
| 80 rv = l10n_util::GetStringFUTF16( | 80 rv = l10n_util::GetStringFUTF16( |
| 81 IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT, | 81 IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT, |
| 82 rv, | 82 rv, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 96 rv = base::TimeFormatShortDateNumeric(cert.valid_expiry()); | 96 rv = base::TimeFormatShortDateNumeric(cert.valid_expiry()); |
| 97 break; | 97 break; |
| 98 default: | 98 default: |
| 99 NOTREACHED(); | 99 NOTREACHED(); |
| 100 } | 100 } |
| 101 return rv; | 101 return rv; |
| 102 } | 102 } |
| 103 | 103 |
| 104 int CertificateManagerModel::ImportFromPKCS12(net::CryptoModule* module, | 104 int CertificateManagerModel::ImportFromPKCS12(net::CryptoModule* module, |
| 105 const std::string& data, | 105 const std::string& data, |
| 106 const string16& password, | 106 const base::string16& password, |
| 107 bool is_extractable) { | 107 bool is_extractable) { |
| 108 int result = cert_db_->ImportFromPKCS12(module, data, password, | 108 int result = cert_db_->ImportFromPKCS12(module, data, password, |
| 109 is_extractable, NULL); | 109 is_extractable, NULL); |
| 110 if (result == net::OK) | 110 if (result == net::OK) |
| 111 Refresh(); | 111 Refresh(); |
| 112 return result; | 112 return result; |
| 113 } | 113 } |
| 114 | 114 |
| 115 bool CertificateManagerModel::ImportCACerts( | 115 bool CertificateManagerModel::ImportCACerts( |
| 116 const net::CertificateList& certificates, | 116 const net::CertificateList& certificates, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 144 bool result = cert_db_->DeleteCertAndKey(cert); | 144 bool result = cert_db_->DeleteCertAndKey(cert); |
| 145 if (result) | 145 if (result) |
| 146 Refresh(); | 146 Refresh(); |
| 147 return result; | 147 return result; |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool CertificateManagerModel::IsHardwareBacked( | 150 bool CertificateManagerModel::IsHardwareBacked( |
| 151 const net::X509Certificate* cert) const { | 151 const net::X509Certificate* cert) const { |
| 152 return cert_db_->IsHardwareBacked(cert); | 152 return cert_db_->IsHardwareBacked(cert); |
| 153 } | 153 } |
| OLD | NEW |