OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview settings-certificate-subentry represents an SSL certificate |
| 7 * sub-entry. |
| 8 */ |
| 9 Polymer({ |
| 10 is: 'settings-certificate-subentry', |
| 11 |
| 12 properties: { |
| 13 /** @type {!CertificateSubnode>} */ |
| 14 model: Object, |
| 15 |
| 16 /** @type {!settings.CertificateType} */ |
| 17 certificateType: String, |
| 18 }, |
| 19 |
| 20 /** @private {!settings.CertificatesManagerBrowserProxy} */ |
| 21 browserProxy_: null, |
| 22 |
| 23 /** @override */ |
| 24 ready: function() { |
| 25 this.browserProxy_ = settings.CertificatesBrowserProxyImpl.getInstance(); |
| 26 }, |
| 27 |
| 28 /** |
| 29 * @param {!Event} event |
| 30 * @private |
| 31 */ |
| 32 onViewTap_: function(event) { |
| 33 this.closePopupMenu_(); |
| 34 this.browserProxy_.viewCertificate(this.model.id); |
| 35 }, |
| 36 |
| 37 /** |
| 38 * @param {!Event} event |
| 39 * @private |
| 40 */ |
| 41 onEditTap_: function(event) { |
| 42 this.closePopupMenu_(); |
| 43 // TODO(dpapad): Open edit dialog. |
| 44 }, |
| 45 |
| 46 /** |
| 47 * @param {!Event} event |
| 48 * @private |
| 49 */ |
| 50 onDeleteTap_: function(event) { |
| 51 this.closePopupMenu_(); |
| 52 // TODO(dpapad): Open delete confirmation dialog. |
| 53 }, |
| 54 |
| 55 /** |
| 56 * @param {!Event} event |
| 57 * @private |
| 58 */ |
| 59 onExportTap_: function(event) { |
| 60 this.closePopupMenu_(); |
| 61 if (this.certificateType == settings.CertificateType.PERSONAL) { |
| 62 // TODO(dpapad): Open password encryption dialog. |
| 63 } else { |
| 64 this.browserProxy_.exportCertificate(this.model.id); |
| 65 } |
| 66 }, |
| 67 |
| 68 /** @private */ |
| 69 onImportTap_: function() { |
| 70 this.closePopupMenu_(); |
| 71 if (this.certificateType == settings.CertificateType.PERSONAL) { |
| 72 // TODO(dpapad): Figure out when to pass true (ChromeOS?). |
| 73 this.browserProxy_.importPersonalCertificate(false).then( |
| 74 function(showPasswordPrompt) { |
| 75 if (showPasswordPrompt) { |
| 76 // TODO(dpapad): Show password decryption dialog. |
| 77 } |
| 78 }.bind(this)); |
| 79 } else if (this.certificateType == settings.CertificateType.CA) { |
| 80 this.browserProxy_.importCaCertificate().then( |
| 81 function(certificateName) { |
| 82 // TODO(dpapad): Show import dialog. |
| 83 }.bind(this)); |
| 84 } else if (this.certificateType == settings.CertificateType.SERVER) { |
| 85 this.browserProxy_.importServerCertificate(); |
| 86 } |
| 87 }, |
| 88 |
| 89 /** |
| 90 * @param {string} certificateType The type of this certificate. |
| 91 * @return {boolean} Whether the certificate can be edited. |
| 92 * @private |
| 93 */ |
| 94 canEdit_: function(certificateType) { |
| 95 return this.certificateType == settings.CertificateType.CA; |
| 96 }, |
| 97 |
| 98 /** |
| 99 * @param {string} certificateType The type of this certificate. |
| 100 * @return {boolean} Whether a certificate can be imported. |
| 101 * @private |
| 102 */ |
| 103 canImport_: function(certificateType) { |
| 104 return this.certificateType != settings.CertificateType.OTHER; |
| 105 }, |
| 106 |
| 107 /** @private */ |
| 108 closePopupMenu_: function() { |
| 109 this.$$('iron-dropdown').close(); |
| 110 }, |
| 111 }); |
OLD | NEW |