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

Side by Side Diff: chrome/browser/resources/certificate_viewer.js

Issue 10407051: Revert r137984 "Fix for broken CertificateViewerUITest.testDetails." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/webui/certificate_viewer_dialog_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 cr.ui.decorate('tabbox', cr.ui.TabBox); 13 cr.ui.decorate('tabbox', cr.ui.TabBox);
14 14
15 i18nTemplate.process(document, templateData); 15 i18nTemplate.process(document, templateData);
16 16
17 var args = JSON.parse(chrome.dialogArguments); 17 var args = JSON.parse(chrome.dialogArguments);
18 getCertificateInfo(args); 18 getCertificateInfo(args);
19 19
20 /**
21 * Initialize the second tab's contents.
22 * This is a 'oneShot' function, meaning it will only be invoked once,
23 * no matter how many times it is called. This is done for unit-testing
24 * purposes in case a test needs to initialize the tab before the timer
25 * fires.
26 */
27 var initializeDetailTab = oneShot(function() {
28 initializeTree($('hierarchy'), showCertificateFields);
29 initializeTree($('cert-fields'), showCertificateFieldValue);
30 createCertificateHierarchy(args.hierarchy);
31 });
32
33 // The second tab's contents aren't visible on startup, so we can 20 // The second tab's contents aren't visible on startup, so we can
34 // shorten startup by not populating those controls until after we 21 // shorten startup by not populating those controls until after we
35 // have had a chance to draw the visible controls the first time. 22 // have had a chance to draw the visible controls the first time.
36 // The value of 200ms is quick enough that the user couldn't open the 23 // The value of 200ms is quick enough that the user couldn't open the
37 // tab in that time but long enough to allow the first tab to draw on 24 // tab in that time but long enough to allow the first tab to draw on
38 // even the slowest machine. 25 // even the slowest machine.
39 setTimeout(initializeDetailTab, 200); 26 setTimeout(function() {
40 27 initializeTree($('hierarchy'), showCertificateFields);
41 $('tabbox').addEventListener('selectedChange', function f(e) { 28 initializeTree($('cert-fields'), showCertificateFieldValue);
42 $('tabbox').removeEventListener('selectedChange', f); 29 createCertificateHierarchy(args.hierarchy);
43 initializeDetailTab(); 30 }, 200);
44 });
45 31
46 stripGtkAccessorKeys(); 32 stripGtkAccessorKeys();
47 33
48 $('export').onclick = exportCertificate; 34 $('export').onclick = exportCertificate;
49 35
50 // TODO(kochi): ESC key should be handled in the views window side. 36 // TODO(kochi): ESC key should be handled in the views window side.
51 document.addEventListener('keydown', function(e) { 37 document.addEventListener('keydown', function(e) {
52 if (e.keyCode == 27) // ESC 38 if (e.keyCode == 27) // ESC
53 chrome.send('DialogClose'); 39 chrome.send('DialogClose');
54 }); 40 });
55 } 41 }
56 42
57 /** 43 /**
58 * Decorate a function so that it can only be invoked once.
59 */
60 function oneShot(fn) {
61 var fired = false;
62 return function() {
63 if (fired) return;
64 fn();
65 fired = true;
66 };
67 }
68
69 /**
70 * Initialize a cr.ui.Tree object from a given element using the specified 44 * Initialize a cr.ui.Tree object from a given element using the specified
71 * change handler. 45 * change handler.
72 * @param {HTMLElement} tree The HTMLElement to style as a tree. 46 * @param {HTMLElement} tree The HTMLElement to style as a tree.
73 * @param {function()} handler Function to call when a node is selected. 47 * @param {function()} handler Function to call when a node is selected.
74 */ 48 */
75 function initializeTree(tree, handler) { 49 function initializeTree(tree, handler) {
76 cr.ui.decorate(tree, cr.ui.Tree); 50 cr.ui.decorate(tree, cr.ui.Tree);
77 tree.detail = {payload: {}, children: {}}; 51 tree.detail = {payload: {}, children: {}};
78 tree.addEventListener('change', handler); 52 tree.addEventListener('change', handler);
79 } 53 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 chrome.send('exportCertificate', [item.detail.payload.index]); 184 chrome.send('exportCertificate', [item.detail.payload.index]);
211 } 185 }
212 186
213 return { 187 return {
214 initialize: initialize, 188 initialize: initialize,
215 getCertificateFields: getCertificateFields, 189 getCertificateFields: getCertificateFields,
216 }; 190 };
217 }); 191 });
218 192
219 document.addEventListener('DOMContentLoaded', cert_viewer.initialize); 193 document.addEventListener('DOMContentLoaded', cert_viewer.initialize);
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/certificate_viewer_dialog_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698