| 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 'settings-certificate-list' is an element that displays a list | 6 * @fileoverview 'settings-certificate-list' is an element that displays a list |
| 7 * of certificates. | 7 * of certificates. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-certificate-list', | 10 is: 'settings-certificate-list', |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 }, | 45 }, |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * @return {boolean} | 48 * @return {boolean} |
| 49 * @private | 49 * @private |
| 50 */ | 50 */ |
| 51 canImport_: function() { | 51 canImport_: function() { |
| 52 return this.certificateType != CertificateType.OTHER; | 52 return this.certificateType != CertificateType.OTHER; |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 // <if expr="chromeos"> |
| 56 /** |
| 57 * @return {boolean} |
| 58 * @private |
| 59 */ |
| 60 canImportAndBind_: function() { |
| 61 return this.certificateType == CertificateType.PERSONAL; |
| 62 }, |
| 63 // </if> |
| 64 |
| 55 /** | 65 /** |
| 56 * Handles a rejected Promise returned from |browserProxy_|. | 66 * Handles a rejected Promise returned from |browserProxy_|. |
| 57 * @param {*} error Expects {!CertificatesError|!CertificatesImportError}. | 67 * @param {*} error Expects {!CertificatesError|!CertificatesImportError}. |
| 58 * @private | 68 * @private |
| 59 */ | 69 */ |
| 60 onRejected_: function(error) { | 70 onRejected_: function(error) { |
| 61 if (error === null) { | 71 if (error === null) { |
| 62 // Nothing to do here. Null indicates that the user clicked "cancel" on | 72 // Nothing to do here. Null indicates that the user clicked "cancel" on |
| 63 // a native file chooser dialog. | 73 // a native file chooser dialog. |
| 64 return; | 74 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 settings.CertificateActionEvent, | 89 settings.CertificateActionEvent, |
| 80 /** @type {!CertificateActionEventDetail} */ ({ | 90 /** @type {!CertificateActionEventDetail} */ ({ |
| 81 action: CertificateAction.IMPORT, | 91 action: CertificateAction.IMPORT, |
| 82 subnode: subnode, | 92 subnode: subnode, |
| 83 certificateType: this.certificateType, | 93 certificateType: this.certificateType, |
| 84 })); | 94 })); |
| 85 }, | 95 }, |
| 86 | 96 |
| 87 /** @private */ | 97 /** @private */ |
| 88 onImportTap_: function() { | 98 onImportTap_: function() { |
| 99 this.handleImport_(false); |
| 100 }, |
| 101 |
| 102 // <if expr="chromeos"> |
| 103 /** @private */ |
| 104 onImportAndBindTap_: function() { |
| 105 this.handleImport_(true); |
| 106 }, |
| 107 // </if> |
| 108 |
| 109 /** |
| 110 * @param {boolean} useHardwareBacked |
| 111 * @private |
| 112 */ |
| 113 handleImport_: function(useHardwareBacked) { |
| 89 var browserProxy = settings.CertificatesBrowserProxyImpl.getInstance(); | 114 var browserProxy = settings.CertificatesBrowserProxyImpl.getInstance(); |
| 90 if (this.certificateType == CertificateType.PERSONAL) { | 115 if (this.certificateType == CertificateType.PERSONAL) { |
| 91 browserProxy.importPersonalCertificate(false).then( | 116 browserProxy.importPersonalCertificate(useHardwareBacked).then( |
| 92 function(showPasswordPrompt) { | 117 function(showPasswordPrompt) { |
| 93 if (showPasswordPrompt) | 118 if (showPasswordPrompt) |
| 94 this.dispatchImportActionEvent_(null); | 119 this.dispatchImportActionEvent_(null); |
| 95 }.bind(this), | 120 }.bind(this), |
| 96 this.onRejected_.bind(this)); | 121 this.onRejected_.bind(this)); |
| 97 } else if (this.certificateType == CertificateType.CA) { | 122 } else if (this.certificateType == CertificateType.CA) { |
| 98 browserProxy.importCaCertificate().then( | 123 browserProxy.importCaCertificate().then( |
| 99 function(certificateName) { | 124 function(certificateName) { |
| 100 this.dispatchImportActionEvent_({name: certificateName}); | 125 this.dispatchImportActionEvent_({name: certificateName}); |
| 101 }.bind(this), | 126 }.bind(this), |
| 102 this.onRejected_.bind(this)); | 127 this.onRejected_.bind(this)); |
| 103 } else if (this.certificateType == CertificateType.SERVER) { | 128 } else if (this.certificateType == CertificateType.SERVER) { |
| 104 browserProxy.importServerCertificate().catch( | 129 browserProxy.importServerCertificate().catch( |
| 105 this.onRejected_.bind(this)); | 130 this.onRejected_.bind(this)); |
| 106 } else { | 131 } else { |
| 107 assertNotReached(); | 132 assertNotReached(); |
| 108 } | 133 } |
| 109 }, | 134 }, |
| 110 }); | 135 }); |
| OLD | NEW |