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

Unified Diff: chrome/browser/resources/certificate_viewer.js

Issue 7528027: Add export function to WebUI certificate viewer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Adds TODO comment related to passing certificate viewer parent. Created 9 years, 4 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/resources/certificate_viewer.js
diff --git a/chrome/browser/resources/certificate_viewer.js b/chrome/browser/resources/certificate_viewer.js
index 1f4cdcc75df72f0fa89e97a96c29608f6c8ce4f7..b35784d2476588dd988769ec450d6d11131cea6a 100644
--- a/chrome/browser/resources/certificate_viewer.js
+++ b/chrome/browser/resources/certificate_viewer.js
@@ -13,6 +13,7 @@ cr.define('cert_viewer', function() {
$('close').onclick = function() {
window.close();
}
+ $('export').onclick = exportCertificate;
cr.ui.decorate('tabbox', cr.ui.TabBox);
initializeTree($('hierarchy'), showCertificateFields);
@@ -20,8 +21,7 @@ cr.define('cert_viewer', function() {
i18nTemplate.process(document, templateData);
stripGtkAccessorKeys();
- var args = JSON.parse(chrome.dialogArguments);
- chrome.send('requestCertificateInfo', [args.cert]);
+ chrome.send('RequestCertificateInfo');
James Hawkins 2011/08/12 19:58:26 s/Request/request/
flackr 2011/08/15 13:47:38 Done.
}
/**
@@ -43,9 +43,11 @@ cr.define('cert_viewer', function() {
* translated strings could be added / modified to remove the & sign.
*/
function stripGtkAccessorKeys() {
- var tabs = $('tabs').childNodes;
- for (var i = 0; i < tabs.length; i++) {
- tabs[i].textContent = tabs[i].textContent.replace('&','');
+ // Copy all the tab labels into an array.
+ var nodes = Array.prototype.slice.call($('tabs').childNodes, 0);
+ nodes.push($('export'));
+ for (var i = 0; i < nodes.length; i++) {
James Hawkins 2011/08/12 19:58:26 Remove braces.
flackr 2011/08/15 13:47:38 Done.
+ nodes[i].textContent = nodes[i].textContent.replace('&','');
}
}
@@ -105,20 +107,37 @@ cr.define('cert_viewer', function() {
}
/**
- * Show certificate fields for the selected certificate in the hierarchy.
+ * Clear any previous certificate fields in the tree.
*/
- function showCertificateFields() {
+ function clearCertificateFields() {
var treeItem = $('cert-fields');
for (var key in treeItem.detail.children) {
treeItem.remove(treeItem.detail.children[key]);
delete treeItem.detail.children[key];
}
+ }
+
+ /**
+ * Request certificate fields for the selected certificate in the hierarchy.
+ */
+ function showCertificateFields() {
+ clearCertificateFields();
var item = $('hierarchy').selectedItem;
- if (item && item.detail.payload.fields) {
- treeItem.add(treeItem.detail.children['root'] =
- constructTree(item.detail.payload.fields[0]));
- revealTree(treeItem);
- }
+ if (item && item.detail.payload.index !== undefined)
+ chrome.send('RequestCertificateFields', [item.detail.payload.index]);
+ }
+
+ /**
+ * Show the returned certificate fields for the selected certificate.
+ * @param {Object} certFields A dictionary containing the fields tree
+ * structure.
+ */
+ function getCertificateFields(certFields) {
+ clearCertificateFields();
+ var treeItem = $('cert-fields');
+ treeItem.add(treeItem.detail.children['root'] =
+ constructTree(certFields[0]));
+ revealTree(treeItem);
}
/**
@@ -132,9 +151,19 @@ cr.define('cert_viewer', function() {
$('cert-field-value').textContent = '';
}
+ /**
+ * Export the selected certificate.
+ */
+ function exportCertificate() {
+ var item = $('hierarchy').selectedItem;
+ if (item && item.detail.payload.index !== undefined)
+ chrome.send('ExportCertificate', [item.detail.payload.index]);
James Hawkins 2011/08/12 19:58:26 s/Export/export/
flackr 2011/08/15 13:47:38 Done.
+ }
+
return {
initialize: initialize,
getCertificateInfo: getCertificateInfo,
+ getCertificateFields: getCertificateFields,
};
});

Powered by Google App Engine
This is Rietveld 408576698