Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('cert_viewer', function() { | 5 cr.define('cert_viewer', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Initialize the certificate viewer dialog by wiring up the close button, | 9 * Initialize the certificate viewer dialog by wiring up the close button, |
| 10 * substituting in translated strings and requesting certificate details. | 10 * substituting in translated strings and requesting certificate details. |
| 11 */ | 11 */ |
| 12 function initialize() { | 12 function initialize() { |
| 13 $('export').onclick = exportCertificate; | 13 $('export').onclick = exportCertificate; |
| 14 cr.ui.decorate('tabbox', cr.ui.TabBox); | 14 cr.ui.decorate('tabbox', cr.ui.TabBox); |
| 15 | 15 |
| 16 initializeTree($('hierarchy'), showCertificateFields); | 16 initializeTree($('hierarchy'), showCertificateFields); |
| 17 initializeTree($('cert-fields'), showCertificateFieldValue); | 17 initializeTree($('cert-fields'), showCertificateFieldValue); |
| 18 | 18 |
| 19 i18nTemplate.process(document, templateData); | 19 i18nTemplate.process(document, templateData); |
| 20 stripGtkAccessorKeys(); | 20 stripGtkAccessorKeys(); |
| 21 chrome.send('requestCertificateInfo'); | 21 chrome.send('requestCertificateInfo'); |
| 22 // TODO(kochi): ESC key should be handled in the views window side. | 22 // TODO(kochi): ESC key should be handled in the views window side. |
| 23 document.addEventListener('keydown', function(e) { | 23 document.addEventListener('keydown', function(e) { |
| 24 if (e.keyCode == 27) { // ESC | 24 if (e.keyCode == 27) { // ESC |
|
Dan Beam
2012/04/05 22:24:13
nit: no curlies
Tyler Breisacher (Chromium)
2012/04/05 22:49:55
Done.
| |
| 25 chrome.send('DialogClose'); | 25 chrome.send('DialogClose'); |
| 26 } | 26 } |
| 27 }); | 27 }); |
| 28 } | 28 } |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Initialize a cr.ui.Tree object from a given element using the specified | 31 * Initialize a cr.ui.Tree object from a given element using the specified |
| 32 * change handler. | 32 * change handler. |
| 33 * @param {HTMLElement} tree The HTMLElement to style as a tree. | 33 * @param {HTMLElement} tree The HTMLElement to style as a tree. |
| 34 * @param {function()} handler Function to call when a node is selected. | 34 * @param {function()} handler Function to call when a node is selected. |
| 35 */ | 35 */ |
| 36 function initializeTree(tree, handler) { | 36 function initializeTree(tree, handler) { |
| 37 cr.ui.decorate(tree, cr.ui.Tree); | 37 cr.ui.decorate(tree, cr.ui.Tree); |
| 38 tree.detail = {payload: {}, children: {}}; | 38 tree.detail = {payload: {}, children: {}}; |
| 39 tree.addEventListener('change', handler); | 39 tree.addEventListener('change', handler); |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * The tab name strings in the languages file have accessor keys indicated | 43 * The tab name strings in the languages file have accessor keys indicated |
| 44 * by a preceding & sign. Strip these out for now. | 44 * by a preceding & sign. Strip these out for now. |
| 45 * @TODO(flackr) These accessor keys could be implemented with Javascript or | 45 * TODO(flackr) These accessor keys could be implemented with Javascript or |
| 46 * translated strings could be added / modified to remove the & sign. | 46 * translated strings could be added / modified to remove the & sign. |
| 47 */ | 47 */ |
| 48 function stripGtkAccessorKeys() { | 48 function stripGtkAccessorKeys() { |
| 49 // Copy all the tab labels into an array. | 49 // Copy all the tab labels into an array. |
| 50 var nodes = Array.prototype.slice.call($('tabs').childNodes, 0); | 50 var nodes = Array.prototype.slice.call($('tabs').childNodes, 0); |
| 51 nodes.push($('export')); | 51 nodes.push($('export')); |
| 52 for (var i = 0; i < nodes.length; i++) | 52 for (var i = 0; i < nodes.length; i++) |
| 53 nodes[i].textContent = nodes[i].textContent.replace('&',''); | 53 nodes[i].textContent = nodes[i].textContent.replace('&', ''); |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Expand all nodes of the given tree object. | 57 * Expand all nodes of the given tree object. |
| 58 * @param {cr.ui.Tree} tree The tree object to expand all nodes on. | 58 * @param {cr.ui.Tree} tree The tree object to expand all nodes on. |
| 59 */ | 59 */ |
| 60 function revealTree(tree) { | 60 function revealTree(tree) { |
| 61 tree.expanded = true; | 61 tree.expanded = true; |
| 62 for (var key in tree.detail.children) { | 62 for (var key in tree.detail.children) { |
| 63 revealTree(tree.detail.children[key]); | 63 revealTree(tree.detail.children[key]); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 } | 173 } |
| 174 | 174 |
| 175 return { | 175 return { |
| 176 initialize: initialize, | 176 initialize: initialize, |
| 177 getCertificateInfo: getCertificateInfo, | 177 getCertificateInfo: getCertificateInfo, |
| 178 getCertificateFields: getCertificateFields, | 178 getCertificateFields: getCertificateFields, |
| 179 }; | 179 }; |
| 180 }); | 180 }); |
| 181 | 181 |
| 182 document.addEventListener('DOMContentLoaded', cert_viewer.initialize); | 182 document.addEventListener('DOMContentLoaded', cert_viewer.initialize); |
| OLD | NEW |