Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview 'settings-ca-trust-edit-dialog' allows the user to |
| 7 * 'settings-ca-trust-edit-dialog' is the a dialog allowing the user to edit the | 7 * - specify the trust level of a certificate authority that is being |
| 8 * trust lever of a given certificate authority. | 8 * imported. |
| 9 * | 9 * - edit the trust level of an already existing certificate authority. |
| 10 * @group Chrome Settings Elements | |
| 11 * @element settings-ca-trust-edit-dialog | |
| 12 */ | 10 */ |
| 13 Polymer({ | 11 Polymer({ |
| 14 is: 'settings-ca-trust-edit-dialog', | 12 is: 'settings-ca-trust-edit-dialog', |
| 15 | 13 |
| 16 properties: { | 14 properties: { |
| 17 /** @private {!settings.CertificatesBrowserProxy} */ | 15 /** @private {!settings.CertificatesBrowserProxy} */ |
| 18 browserProxy_: Object, | 16 browserProxy_: Object, |
| 19 | 17 |
| 20 /** @type {!CertificateSubnode} */ | 18 /** @type {!CertificateSubnode} */ |
| 21 model: Object, | 19 model: Object, |
| 22 | 20 |
| 23 /** @private {?CaTrustInfo} */ | 21 /** @private {?CaTrustInfo} */ |
| 24 trustInfo_: Object, | 22 trustInfo_: Object, |
| 25 | 23 |
| 26 /** @private {string} */ | 24 /** @private {string} */ |
| 27 explanationText_: String, | 25 explanationText_: String, |
| 28 }, | 26 }, |
| 29 | 27 |
| 30 /** @override */ | 28 /** @override */ |
| 31 ready: function() { | 29 ready: function() { |
| 32 this.browserProxy_ = settings.CertificatesBrowserProxyImpl.getInstance(); | 30 this.browserProxy_ = settings.CertificatesBrowserProxyImpl.getInstance(); |
| 33 }, | 31 }, |
| 34 | 32 |
| 35 /** @override */ | 33 /** @override */ |
| 36 attached: function() { | 34 attached: function() { |
| 37 this.explanationText_ = loadTimeData.getStringF( | 35 this.explanationText_ = loadTimeData.getStringF( |
| 38 'certificateManagerCaTrustEditDialogExplanation', | 36 'certificateManagerCaTrustEditDialogExplanation', |
| 39 this.model.name); | 37 this.model.name); |
| 40 this.browserProxy_.getCaCertificateTrust(this.model.id).then( | 38 |
| 41 /** @param {!CaTrustInfo} trustInfo */ | 39 // A null |model.id| indicates that a certificate is being imported, |
| 42 function(trustInfo) { | 40 // otherwise an existing certificate is being edited. |
| 43 this.trustInfo_ = trustInfo; | 41 if (this.model.id !== null) { |
|
dschuyler
2016/04/05 23:58:11
Should the definition of CertificateSubnode
in cer
dpapad
2016/04/06 00:59:00
Yes, to be accurate id should be marked an nullabl
Dan Beam
2016/04/06 18:31:09
why not just (!this.model.id)?
dpapad
2016/04/06 18:56:52
Because 'id' can be zero, and it should still cons
Dan Beam
2016/04/06 19:00:54
I thought CertificateSubnode#id is a string?
dpapad
2016/04/06 19:08:10
Ah right, in this case zero is not a possibility,
| |
| 44 this.$.dialog.open(); | 42 this.browserProxy_.getCaCertificateTrust(this.model.id).then( |
| 45 }.bind(this)); | 43 /** @param {!CaTrustInfo} trustInfo */ |
| 44 function(trustInfo) { | |
| 45 this.trustInfo_ = trustInfo; | |
| 46 this.$.dialog.open(); | |
| 47 }.bind(this)); | |
| 48 } else { | |
| 49 this.$.dialog.open(); | |
| 50 } | |
| 46 }, | 51 }, |
| 47 | 52 |
| 48 /** @private */ | 53 /** @private */ |
| 49 onCancelTap_: function() { | 54 onCancelTap_: function() { |
| 50 this.$.dialog.close(); | 55 this.$.dialog.close(); |
| 51 }, | 56 }, |
| 52 | 57 |
| 53 /** @private */ | 58 /** @private */ |
| 54 onOkTap_: function() { | 59 onOkTap_: function() { |
| 55 this.$.spinner.active = true; | 60 this.$.spinner.active = true; |
| 56 this.browserProxy_.editCaCertificateTrust( | 61 |
| 57 this.model.id, this.$.ssl.checked, | 62 var whenDone = this.model.id === null ? |
| 58 this.$.email.checked, this.$.objSign.checked).then( | 63 this.browserProxy_.importCaCertificateTrustSelected( |
| 59 function() { | 64 this.$.ssl.checked, this.$.email.checked, this.$.objSign.checked) : |
| 60 this.$.spinner.active = false; | 65 this.browserProxy_.editCaCertificateTrust( |
| 61 this.$.dialog.close(); | 66 this.model.id, this.$.ssl.checked, |
| 62 }.bind(this), | 67 this.$.email.checked, this.$.objSign.checked); |
| 63 /** @param {!CertificatesError} error */ | 68 |
| 64 function(error) { | 69 whenDone.then(function() { |
| 65 this.$.dialog.close(); | 70 this.$.spinner.active = false; |
| 66 this.fire('certificates-error', error); | 71 this.$.dialog.close(); |
| 67 }.bind(this)); | 72 }.bind(this), |
| 73 /** @param {!CertificatesError} error */ | |
| 74 function(error) { | |
| 75 this.$.dialog.close(); | |
| 76 this.fire('certificates-error', error); | |
| 77 }.bind(this)); | |
| 68 }, | 78 }, |
| 69 }); | 79 }); |
| OLD | NEW |