| OLD | NEW |
| 1 // Copyright (c) 2011 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('options', function() { | 5 cr.define('options', function() { |
| 6 const Tree = cr.ui.Tree; | 6 const Tree = cr.ui.Tree; |
| 7 const TreeItem = cr.ui.TreeItem; | 7 const TreeItem = cr.ui.TreeItem; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Creates a new tree item for certificate data. | 10 * Creates a new tree item for certificate data. |
| 11 * @param {Object=} data Data used to create a certificate tree item. | 11 * @param {Object=} data Data used to create a certificate tree item. |
| 12 * @constructor | 12 * @constructor |
| 13 * @extends {TreeItem} | 13 * @extends {TreeItem} |
| 14 */ | 14 */ |
| 15 function CertificateTreeItem(data) { | 15 function CertificateTreeItem(data) { |
| 16 // TODO(mattm): other columns | 16 // TODO(mattm): other columns |
| 17 var treeItem = new TreeItem({ | 17 var treeItem = new TreeItem({ |
| 18 label: data.name, | 18 label: data.name, |
| 19 data: data | 19 data: data |
| 20 }); | 20 }); |
| 21 treeItem.__proto__ = CertificateTreeItem.prototype; | 21 treeItem.__proto__ = CertificateTreeItem.prototype; |
| 22 | 22 |
| 23 if (data.icon) { | 23 if (data.icon) { |
| 24 treeItem.icon = data.icon; | 24 treeItem.icon = data.icon; |
| 25 } | 25 } |
| 26 | 26 |
| 27 if (data.untrusted) { | 27 if (data.untrusted) { |
| 28 var badge = document.createElement('span'); | 28 var badge = document.createElement('span'); |
| 29 badge.setAttribute('class', 'certUntrusted'); | 29 badge.setAttribute('class', 'certUntrusted'); |
| 30 badge.textContent = localStrings.getString("badgeCertUntrusted"); | 30 badge.textContent = localStrings.getString('badgeCertUntrusted'); |
| 31 treeItem.labelElement.insertBefore( | 31 treeItem.labelElement.insertBefore( |
| 32 badge, treeItem.labelElement.firstChild); | 32 badge, treeItem.labelElement.firstChild); |
| 33 } | 33 } |
| 34 | 34 |
| 35 return treeItem; | 35 return treeItem; |
| 36 } | 36 } |
| 37 | 37 |
| 38 CertificateTreeItem.prototype = { | 38 CertificateTreeItem.prototype = { |
| 39 __proto__: TreeItem.prototype, | 39 __proto__: TreeItem.prototype, |
| 40 | 40 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (child.data && child.data.id) | 82 if (child.data && child.data.id) |
| 83 delete this.treeLookup_[child.data.id]; | 83 delete this.treeLookup_[child.data.id]; |
| 84 }, | 84 }, |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Clears the tree. | 87 * Clears the tree. |
| 88 */ | 88 */ |
| 89 clear: function() { | 89 clear: function() { |
| 90 // Remove all fields without recreating the object since other code | 90 // Remove all fields without recreating the object since other code |
| 91 // references it. | 91 // references it. |
| 92 for (var id in this.treeLookup_){ | 92 for (var id in this.treeLookup_) |
| 93 delete this.treeLookup_[id]; | 93 delete this.treeLookup_[id]; |
| 94 } | |
| 95 this.textContent = ''; | 94 this.textContent = ''; |
| 96 }, | 95 }, |
| 97 | 96 |
| 98 /** | 97 /** |
| 99 * Populate the tree. | 98 * Populate the tree. |
| 100 * @param {Array} nodesData Nodes data array. | 99 * @param {Array} nodesData Nodes data array. |
| 101 */ | 100 */ |
| 102 populate: function(nodesData) { | 101 populate: function(nodesData) { |
| 103 this.clear(); | 102 this.clear(); |
| 104 | 103 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 119 | 118 |
| 120 cr.dispatchSimpleEvent(this, 'change'); | 119 cr.dispatchSimpleEvent(this, 'change'); |
| 121 }, | 120 }, |
| 122 }; | 121 }; |
| 123 | 122 |
| 124 return { | 123 return { |
| 125 CertificatesTree: CertificatesTree | 124 CertificatesTree: CertificatesTree |
| 126 }; | 125 }; |
| 127 }); | 126 }); |
| 128 | 127 |
| OLD | NEW |