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

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: Fix comment. 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
« no previous file with comments | « chrome/browser/resources/certificate_viewer.html ('k') | chrome/browser/ui/webui/certificate_viewer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7cd94d0e6cba21b666cb60876e1d95c74433b350 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/09 21:00:50 No need to pass an empty array param.
flackr 2011/08/09 21:14:23 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++) {
+ 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) {
James Hawkins 2011/08/09 21:00:50 No braces for single line logic blocks.
flackr 2011/08/09 21:14:23 Done.
+ 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,
};
});
« no previous file with comments | « chrome/browser/resources/certificate_viewer.html ('k') | chrome/browser/ui/webui/certificate_viewer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698