Chromium Code Reviews| Index: chrome/browser/ui/views/certificate_selector.cc |
| diff --git a/chrome/browser/ui/views/certificate_selector.cc b/chrome/browser/ui/views/certificate_selector.cc |
| index 6b9348b3ce33e1270cacbf8a2e020024b956d70d..03da38216905f6bda65f185e5201dcf23b2b9f4c 100644 |
| --- a/chrome/browser/ui/views/certificate_selector.cc |
| +++ b/chrome/browser/ui/views/certificate_selector.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "build/build_config.h" |
| #include "chrome/browser/certificate_viewer.h" |
| +#include "chrome/common/net/x509_certificate_model.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "components/constrained_window/constrained_window_views.h" |
| #include "components/guest_view/browser/guest_view_base.h" |
| @@ -39,8 +40,8 @@ |
| namespace chrome { |
| -const int CertificateSelector::kTableViewWidth = 400; |
| -const int CertificateSelector::kTableViewHeight = 100; |
| +const int CertificateSelector::kTableViewWidth = 500; |
| +const int CertificateSelector::kTableViewHeight = 150; |
| class CertificateSelector::CertificateTableModel : public ui::TableModel { |
| public: |
| @@ -58,15 +59,34 @@ class CertificateSelector::CertificateTableModel : public ui::TableModel { |
| base::string16 subject; |
| base::string16 issuer; |
| base::string16 provider; |
| + base::string16 serial; |
| }; |
| std::vector<Row> rows_; |
| DISALLOW_COPY_AND_ASSIGN(CertificateTableModel); |
| }; |
| +#if defined(OS_WIN) |
| +const char kHexCharLookup[0x10] = { |
| + '0', '1', '2', '3', '4', '5', '6', '7', |
| + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', |
| +}; |
| + |
| +std::string BytesToHexString(const std::string& bytes) { |
| + std::string result; |
| + for (size_t i = 0; i < bytes.size(); ++i) { |
| + result.push_back(kHexCharLookup[(bytes[i] >> 4) & 0xf]); |
| + result.push_back(kHexCharLookup[bytes[i] & 0xf]); |
| + } |
| + return result; |
| +} |
| +#endif |
| + |
| CertificateSelector::CertificateTableModel::CertificateTableModel( |
| const net::CertificateList& certs, |
| const std::vector<std::string>& provider_names) { |
| + const std::string alternative_text = |
| + l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); |
| DCHECK_EQ(certs.size(), provider_names.size()); |
| for (size_t i = 0; i < certs.size(); i++) { |
| net::X509Certificate* cert = certs[i].get(); |
| @@ -74,6 +94,13 @@ CertificateSelector::CertificateTableModel::CertificateTableModel( |
| row.subject = base::UTF8ToUTF16(cert->subject().GetDisplayName()); |
| row.issuer = base::UTF8ToUTF16(cert->issuer().GetDisplayName()); |
| row.provider = base::UTF8ToUTF16(provider_names[i]); |
| +#if defined(OS_WIN) |
| + row.serial = base::UTF8ToUTF16(BytesToHexString(cert->serial_number())); |
|
Ryan Sleevi
2016/04/28 22:13:00
You should actually be able to use this method on
meacer
2016/04/29 00:20:03
Done.
|
| +#else |
| + row.serial = |
| + base::UTF8ToUTF16(x509_certificate_model::GetSerialNumberHexified( |
| + cert->os_cert_handle(), alternative_text)); |
| +#endif |
| rows_.push_back(row); |
| } |
| } |
| @@ -96,6 +123,8 @@ base::string16 CertificateSelector::CertificateTableModel::GetText( |
| return row.issuer; |
| case IDS_CERT_SELECTOR_PROVIDER_COLUMN: |
| return row.provider; |
| + case IDS_CERT_SELECTOR_SERIAL_COLUMN: |
| + return row.serial; |
| default: |
| NOTREACHED(); |
| } |
| @@ -142,7 +171,6 @@ CertificateSelector::CertificateSelector( |
| provider_name = extension->short_name(); |
| show_provider_column_ = true; |
| } // Otherwise the certificate is provided by the platform. |
| - |
| certificates_.push_back(cert); |
| provider_names.push_back(provider_name); |
| } |
| @@ -150,7 +178,6 @@ CertificateSelector::CertificateSelector( |
| provider_names.assign(certificates.size(), std::string()); |
| certificates_ = certificates; |
| #endif |
| - |
| model_.reset(new CertificateTableModel(certificates_, provider_names)); |
| } |
| @@ -199,6 +226,8 @@ void CertificateSelector::InitWithText( |
| columns.push_back(ui::TableColumn(IDS_CERT_SELECTOR_PROVIDER_COLUMN, |
| ui::TableColumn::LEFT, -1, 0.4f)); |
| } |
| + columns.push_back(ui::TableColumn(IDS_CERT_SELECTOR_SERIAL_COLUMN, |
| + ui::TableColumn::LEFT, -1, 0.2f)); |
| table_ = new views::TableView(model_.get(), columns, views::TEXT_ONLY, |
| true /* single_selection */); |
| table_->SetObserver(this); |