| 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('options', function() { | 5 cr.define('options', function() { |
| 6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
| 7 | 7 |
| 8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
| 9 // CertificateManagerTab class: | 9 // CertificateManagerTab class: |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 handleCertificatesTreeChange_: function(e) { | 139 handleCertificatesTreeChange_: function(e) { |
| 140 var data = null; | 140 var data = null; |
| 141 if (this.tree.selectedItem) { | 141 if (this.tree.selectedItem) { |
| 142 data = this.tree.selectedItem.data; | 142 data = this.tree.selectedItem.data; |
| 143 } | 143 } |
| 144 | 144 |
| 145 this.updateButtonState(data); | 145 this.updateButtonState(data); |
| 146 }, | 146 }, |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // TODO(xiyuan): Use notification from backend instead of polling. | |
| 150 // TPM token check polling timer. | |
| 151 var tpmPollingTimer; | |
| 152 | |
| 153 // Initiate tpm token check if needed. | |
| 154 function checkTpmToken() { | |
| 155 var importAndBindButton = $('personalCertsTab-import-and-bind'); | |
| 156 | |
| 157 if (importAndBindButton && importAndBindButton.disabled) | |
| 158 chrome.send('checkTpmTokenReady'); | |
| 159 } | |
| 160 | |
| 161 // Stop tpm polling timer. | |
| 162 function stopTpmTokenCheckPolling() { | |
| 163 if (tpmPollingTimer) { | |
| 164 window.clearTimeout(tpmPollingTimer); | |
| 165 tpmPollingTimer = undefined; | |
| 166 } | |
| 167 } | |
| 168 | |
| 169 ///////////////////////////////////////////////////////////////////////////// | 149 ///////////////////////////////////////////////////////////////////////////// |
| 170 // CertificateManager class: | 150 // CertificateManager class: |
| 171 | 151 |
| 172 /** | 152 /** |
| 173 * Encapsulated handling of ChromeOS accounts options page. | 153 * Encapsulated handling of ChromeOS accounts options page. |
| 174 * @constructor | 154 * @constructor |
| 175 */ | 155 */ |
| 176 function CertificateManager(model) { | 156 function CertificateManager(model) { |
| 177 OptionsPage.call(this, 'certificates', | 157 OptionsPage.call(this, 'certificates', |
| 178 loadTimeData.getString('certificateManagerPageTabTitle'), | 158 loadTimeData.getString('certificateManagerPageTabTitle'), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 205 * Handler for OptionsPage's visible property change event. | 185 * Handler for OptionsPage's visible property change event. |
| 206 * @private | 186 * @private |
| 207 * @param {Event} e Property change event. | 187 * @param {Event} e Property change event. |
| 208 */ | 188 */ |
| 209 handleVisibleChange_: function(e) { | 189 handleVisibleChange_: function(e) { |
| 210 if (!this.initalized_ && this.visible) { | 190 if (!this.initalized_ && this.visible) { |
| 211 this.initalized_ = true; | 191 this.initalized_ = true; |
| 212 OptionsPage.showTab($('personal-certs-nav-tab')); | 192 OptionsPage.showTab($('personal-certs-nav-tab')); |
| 213 chrome.send('populateCertificateManager'); | 193 chrome.send('populateCertificateManager'); |
| 214 } | 194 } |
| 215 | |
| 216 if (cr.isChromeOS) { | |
| 217 // Ensure TPM token check on visible and stop polling when hidden. | |
| 218 if (this.visible) | |
| 219 checkTpmToken(); | |
| 220 else | |
| 221 stopTpmTokenCheckPolling(); | |
| 222 } | |
| 223 } | 195 } |
| 224 }; | 196 }; |
| 225 | 197 |
| 226 // CertificateManagerHandler callbacks. | 198 // CertificateManagerHandler callbacks. |
| 227 CertificateManager.onPopulateTree = function(args) { | 199 CertificateManager.onPopulateTree = function(args) { |
| 228 $(args[0]).populate(args[1]); | 200 $(args[0]).populate(args[1]); |
| 229 }; | 201 }; |
| 230 | 202 |
| 231 CertificateManager.exportPersonalAskPassword = function(args) { | 203 CertificateManager.exportPersonalAskPassword = function(args) { |
| 232 CertificateBackupOverlay.show(); | 204 CertificateBackupOverlay.show(); |
| 233 }; | 205 }; |
| 234 | 206 |
| 235 CertificateManager.importPersonalAskPassword = function(args) { | 207 CertificateManager.importPersonalAskPassword = function(args) { |
| 236 CertificateRestoreOverlay.show(); | 208 CertificateRestoreOverlay.show(); |
| 237 }; | 209 }; |
| 238 | 210 |
| 239 CertificateManager.onCheckTpmTokenReady = function(ready) { | 211 CertificateManager.onModelReady = function() { |
| 240 var importAndBindButton = $('personalCertsTab-import-and-bind'); | 212 var importAndBindButton = $('personalCertsTab-import-and-bind'); |
| 241 if (importAndBindButton) { | 213 if (importAndBindButton !== null) |
| 242 importAndBindButton.disabled = !ready; | 214 importAndBindButton.disabled = false; |
| 243 | 215 $('personalCertsTab-import').disabled = false; |
| 244 // Check again after 5 seconds if Tpm is not ready and certificate manager | 216 $('serverCertsTab-import').disabled = false; |
| 245 // is still visible. | 217 $('caCertsTab-import').disabled = false; |
| 246 if (!ready && CertificateManager.getInstance().visible) | |
| 247 tpmPollingTimer = window.setTimeout(checkTpmToken, 5000); | |
| 248 } | |
| 249 }; | 218 }; |
| 250 | 219 |
| 251 // Export | 220 // Export |
| 252 return { | 221 return { |
| 253 CertificateManagerTab: CertificateManagerTab, | 222 CertificateManagerTab: CertificateManagerTab, |
| 254 CertificateManager: CertificateManager | 223 CertificateManager: CertificateManager |
| 255 }; | 224 }; |
| 256 }); | 225 }); |
| OLD | NEW |