Chromium Code Reviews| 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..3170dd305ea0731ed549a8bd55418aff7b74b138 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', []); |
| } |
| /** |
| @@ -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('&',''); |
| + // Convert the NodeList to an array so that we can use concat. |
|
Rick Byers
2011/08/09 20:03:41
Update this comment now (no longer using concat).
flackr
2011/08/09 20:58:00
Done.
|
| + var nodes = Array.prototype.slice.call($('tabs').childNodes, 0); |
| + nodes.push($('export')); |
| + for (var i = 0; i < nodes.length; i++) { |
| + nodes[i].textContent = nodes[i].textContent.replace('&',''); |
| } |
| } |
| @@ -105,23 +107,41 @@ 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); |
| + } |
| + |
| + /** |
| * Show certificate field value for a selected certificate field. |
| */ |
| function showCertificateFieldValue() { |
| @@ -132,9 +152,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]); |
| + } |
| + |
| return { |
| initialize: initialize, |
| getCertificateInfo: getCertificateInfo, |
| + getCertificateFields: getCertificateFields, |
| }; |
| }); |