| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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-manager-page' is the settings page | 6 * @fileoverview 'settings-certificate-manager-page' is the settings page |
| 7 * containing SSL certificate settings. | 7 * containing SSL certificate settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-certificate-manager-page', | 10 is: 'settings-certificate-manager-page', |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 * @return {boolean} Whether to show tab at |tabIndex|. | 96 * @return {boolean} Whether to show tab at |tabIndex|. |
| 97 * @private | 97 * @private |
| 98 */ | 98 */ |
| 99 isTabSelected_: function(selectedIndex, tabIndex) { | 99 isTabSelected_: function(selectedIndex, tabIndex) { |
| 100 return selectedIndex == tabIndex; | 100 return selectedIndex == tabIndex; |
| 101 }, | 101 }, |
| 102 | 102 |
| 103 /** @override */ | 103 /** @override */ |
| 104 ready: function() { | 104 ready: function() { |
| 105 this.addEventListener(settings.CertificateActionEvent, function(event) { | 105 this.addEventListener(settings.CertificateActionEvent, function(event) { |
| 106 this.dialogModel_ = event.detail.subnode; | 106 if (event.detail.action == settings.CertificateAction.IMPORT) { |
| 107 this.dialogModelCertificateType_ = event.detail.certificateType; | 107 this.handleImportAction_(event.detail); |
| 108 if (event.detail.action == settings.CertificateAction.EDIT) { | 108 } else { |
| 109 this.openDialog_( | 109 this.dialogModel_ = event.detail.subnode; |
| 110 'settings-ca-trust-edit-dialog', | 110 this.dialogModelCertificateType_ = event.detail.certificateType; |
| 111 'showCaTrustEditDialog_'); | 111 if (event.detail.action == settings.CertificateAction.EDIT) { |
| 112 } else if (event.detail.action == settings.CertificateAction.DELETE) { | 112 this.openDialog_( |
| 113 this.openDialog_( | 113 'settings-ca-trust-edit-dialog', |
| 114 'settings-certificate-delete-confirmation-dialog', | 114 'showCaTrustEditDialog_'); |
| 115 'showDeleteConfirmationDialog_'); | 115 } else if (event.detail.action == settings.CertificateAction.DELETE) { |
| 116 } else if (event.detail.action == | 116 this.openDialog_( |
| 117 settings.CertificateAction.EXPORT_PERSONAL) { | 117 'settings-certificate-delete-confirmation-dialog', |
| 118 this.openDialog_( | 118 'showDeleteConfirmationDialog_'); |
| 119 'settings-certificate-password-encryption-dialog', | 119 } else if (event.detail.action == |
| 120 'showPasswordEncryptionDialog_'); | 120 settings.CertificateAction.EXPORT_PERSONAL) { |
| 121 } else if (event.detail.action == | 121 this.openDialog_( |
| 122 settings.CertificateAction.IMPORT_PERSONAL) { | 122 'settings-certificate-password-encryption-dialog', |
| 123 this.openDialog_( | 123 'showPasswordEncryptionDialog_'); |
| 124 'settings-certificate-password-decryption-dialog', | 124 } |
| 125 'showPasswordDecryptionDialog_'); | |
| 126 } else if (event.detail.action == settings.CertificateAction.IMPORT_CA) { | |
| 127 // TODO(dpapad): Implement this. | |
| 128 } | 125 } |
| 126 |
| 127 event.stopPropagation(); |
| 128 }.bind(this)); |
| 129 |
| 130 this.addEventListener('certificates-error', function(event) { |
| 131 this.errorDialogModel_ = event.detail; |
| 132 this.openDialog_( |
| 133 'settings-certificates-error-dialog', |
| 134 'showErrorDialog_'); |
| 129 event.stopPropagation(); | 135 event.stopPropagation(); |
| 130 }.bind(this)); | 136 }.bind(this)); |
| 131 }, | 137 }, |
| 132 | 138 |
| 133 /** | 139 /** |
| 134 * Opens a dialog and registers listeners for | 140 * Handles a |CertificateAction.IMPORT| for cases where a dialog needs to be |
| 135 * 1) Removing the dialog from the DOM once is closed. | 141 * displayed to the user. |
| 136 * 2) Showing an error dialog if necessary. | 142 * @param {!CertificateActionEventDetail} eventdetail |
| 137 * The listeners are destroyed when the dialog is removed (because of | 143 * @private |
| 138 * 'restamp'); | 144 */ |
| 145 handleImportAction_: function(actionEvent) { |
| 146 if (actionEvent.certificateType == settings.CertificateType.PERSONAL) { |
| 147 this.openDialog_( |
| 148 'settings-certificate-password-decryption-dialog', |
| 149 'showPasswordDecryptionDialog_'); |
| 150 } else if (actionEvent.certificateType == settings.CertificateType.CA) { |
| 151 // TODO(dpapad): Implement this. |
| 152 } |
| 153 }, |
| 154 |
| 155 /** |
| 156 * Opens a dialog and registers a listener for removing the dialog from the |
| 157 * DOM once is closed. The listener is destroyed when the dialog is removed |
| 158 * (because of 'restamp'). |
| 139 * | 159 * |
| 140 * @param {string} dialogTagName The tag name of the dialog to be shown. | 160 * @param {string} dialogTagName The tag name of the dialog to be shown. |
| 141 * @param {string} domIfBooleanName The name of the boolean variable | 161 * @param {string} domIfBooleanName The name of the boolean variable |
| 142 * corresponding to the dialog. | 162 * corresponding to the dialog. |
| 143 * @private | 163 * @private |
| 144 */ | 164 */ |
| 145 openDialog_: function(dialogTagName, domIfBooleanName) { | 165 openDialog_: function(dialogTagName, domIfBooleanName) { |
| 146 this.set(domIfBooleanName, true); | 166 this.set(domIfBooleanName, true); |
| 147 this.async(function() { | 167 this.async(function() { |
| 148 var dialog = this.$$(dialogTagName); | 168 var dialog = this.$$(dialogTagName); |
| 149 dialog.addEventListener('iron-overlay-closed', function() { | 169 dialog.addEventListener('iron-overlay-closed', function() { |
| 150 this.set(domIfBooleanName, false); | 170 this.set(domIfBooleanName, false); |
| 151 }.bind(this)); | 171 }.bind(this)); |
| 152 dialog.addEventListener('certificates-error', function(event) { | |
| 153 this.errorDialogModel_ = event.detail; | |
| 154 this.openDialog_( | |
| 155 'settings-certificates-error-dialog', | |
| 156 'showErrorDialog_'); | |
| 157 }.bind(this)); | |
| 158 }.bind(this)); | 172 }.bind(this)); |
| 159 }, | 173 }, |
| 160 }); | 174 }); |
| OLD | NEW |