Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4096)

Unified Diff: chrome/browser/ui/views/certificate_selector.cc

Issue 1918143005: Add a serial number column to the certificate selector dialog and fix its size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra var Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..afab9efa311114fc4901c81f6ccb7c80c6971a35 100644
--- a/chrome/browser/ui/views/certificate_selector.cc
+++ b/chrome/browser/ui/views/certificate_selector.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/web_contents.h"
#include "grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
+
#include "ui/base/models/table_model.h"
#include "ui/base/models/table_model_observer.h"
#include "ui/views/controls/button/label_button.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,12 +59,29 @@ 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);
};
+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;
Ryan Sleevi 2016/04/29 00:30:29 pedantry: std::string result(bytes.size() * 3, '0'
meacer 2016/04/29 17:39:42 Removed in favor of HexEncode.
+ for (size_t i = 0; i < bytes.size(); ++i) {
+ result.push_back(kHexCharLookup[(bytes[i] >> 4) & 0xf]);
+ result.push_back(kHexCharLookup[bytes[i] & 0xf]);
+ if (i != bytes.size() - 1)
+ result.push_back(':');
+ }
+ return result;
+}
+
CertificateSelector::CertificateTableModel::CertificateTableModel(
const net::CertificateList& certs,
const std::vector<std::string>& provider_names) {
@@ -74,6 +92,7 @@ CertificateSelector::CertificateTableModel::CertificateTableModel(
row.subject = base::UTF8ToUTF16(cert->subject().GetDisplayName());
row.issuer = base::UTF8ToUTF16(cert->issuer().GetDisplayName());
row.provider = base::UTF8ToUTF16(provider_names[i]);
+ row.serial = base::UTF8ToUTF16(BytesToHexString(cert->serial_number()));
Ryan Sleevi 2016/04/29 00:30:29 I leave the UI in your fully capable hands, but th
meacer 2016/04/29 17:39:42 I searched for combinations of (Binary,Hex,String)
rows_.push_back(row);
}
}
@@ -96,6 +115,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 +163,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 +170,6 @@ CertificateSelector::CertificateSelector(
provider_names.assign(certificates.size(), std::string());
certificates_ = certificates;
#endif
-
Ryan Sleevi 2016/04/29 00:30:29 Eh, I thought this helped readability, but *shrug*
meacer 2016/04/29 17:39:42 Not intentional, fixed locally but added back when
model_.reset(new CertificateTableModel(certificates_, provider_names));
}
@@ -199,6 +218,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);
@@ -210,6 +231,10 @@ void CertificateSelector::InitWithText(
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
}
+ui::TableModel* CertificateSelector::table_model_for_testing() const {
+ return model_.get();
+}
+
net::X509Certificate* CertificateSelector::GetSelectedCert() const {
const int selected = table_->FirstSelectedRow();
if (selected < 0) // Nothing is selected in |table_|.
« no previous file with comments | « chrome/browser/ui/views/certificate_selector.h ('k') | chrome/browser/ui/views/certificate_selector_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698