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 417f5604149127090ba1f345c62099a21237d685..904f98316035af3c4e8ca5d01fa8a7f914646cf8 100644 |
| --- a/chrome/browser/resources/certificate_viewer.js |
| +++ b/chrome/browser/resources/certificate_viewer.js |
| @@ -14,20 +14,13 @@ cr.define('cert_viewer', function() { |
| i18nTemplate.process(document, templateData); |
| - var args = JSON.parse(chrome.dialogArguments); |
| - getCertificateInfo(args); |
| - |
| // The second tab's contents aren't visible on startup, so we can |
| // shorten startup by not populating those controls until after we |
| // have had a chance to draw the visible controls the first time. |
| // The value of 200ms is quick enough that the user couldn't open the |
| // tab in that time but long enough to allow the first tab to draw on |
| // even the slowest machine. |
| - setTimeout(function() { |
| - initializeTree($('hierarchy'), showCertificateFields); |
| - initializeTree($('cert-fields'), showCertificateFieldValue); |
| - createCertificateHierarchy(args.hierarchy); |
| - }, 200); |
| + setTimeout(initializeSecondTab, 200); |
|
flackr
2012/05/17 15:46:56
Can we also hook this up to the tab change and use
Kevin Greer
2012/05/17 15:56:12
Are you sure? That seems a little hackish and add
flackr
2012/05/17 16:56:58
By triggering it on selecting the details tab the
|
| stripGtkAccessorKeys(); |
| @@ -41,6 +34,33 @@ cr.define('cert_viewer', function() { |
| } |
| /** |
| + * Decorate a function so that it can only be invoked once. |
| + */ |
| + function oneShot(fn) { |
| + var fired = false; |
| + return function() { |
| + if (fired) return; |
| + fn(); |
| + fired = true; |
| + }; |
| + } |
| + |
| + /** |
| + * Initialize the second tab's contents. |
| + * This is a 'oneShot' function, meaning it will only be invoked once, |
| + * no matter how many times it is called. This is done for unit-testing |
| + * purposes in case a test needs to initialize the tab before the timer |
| + * fires. |
| + */ |
| + var initializeSecondTab = oneShot(function() { |
|
flackr
2012/05/17 15:46:56
nit: Call this initializeDetailsTab.
Kevin Greer
2012/05/17 15:56:12
Agreed. That's a better name. Changed.
On 2012/0
|
| + var args = JSON.parse(chrome.dialogArguments); |
| + getCertificateInfo(args); |
| + initializeTree($('hierarchy'), showCertificateFields); |
| + initializeTree($('cert-fields'), showCertificateFieldValue); |
| + createCertificateHierarchy(args.hierarchy); |
| + }); |
| + |
| + /** |
| * Initialize a cr.ui.Tree object from a given element using the specified |
| * change handler. |
| * @param {HTMLElement} tree The HTMLElement to style as a tree. |