Chromium Code Reviews| Index: chrome/browser/resources/settings/certificate_manager_page/certificate_manager_page.js |
| diff --git a/chrome/browser/resources/settings/certificate_manager_page/certificate_manager_page.js b/chrome/browser/resources/settings/certificate_manager_page/certificate_manager_page.js |
| index afa70a9b5d8bd4549374686e448f9242bbc98772..e1db657a3aca3977e8e7f538ceb45dcaac901764 100644 |
| --- a/chrome/browser/resources/settings/certificate_manager_page/certificate_manager_page.js |
| +++ b/chrome/browser/resources/settings/certificate_manager_page/certificate_manager_page.js |
| @@ -82,6 +82,13 @@ Polymer({ |
| * @private {null|!CertificatesError|!CertificatesImportError} |
| */ |
| errorDialogModel_: Object, |
| + |
| + /** |
| + * The element to return focus to, when the currently shown dialog is |
| + * closed. |
| + * @private {?HTMLElement} |
| + */ |
| + activeDialogAnchor_: Object, |
| }, |
| /** @override */ |
| @@ -110,25 +117,28 @@ Polymer({ |
| if (event.detail.certificateType == CertificateType.PERSONAL) { |
| this.openDialog_( |
| 'settings-certificate-password-decryption-dialog', |
| - 'showPasswordDecryptionDialog_'); |
| + 'showPasswordDecryptionDialog_', |
| + event.detail.anchor); |
| } else if (event.detail.certificateType == |
| CertificateType.CA) { |
| this.openDialog_( |
| - 'settings-ca-trust-edit-dialog', 'showCaTrustEditDialog_'); |
| + 'settings-ca-trust-edit-dialog', 'showCaTrustEditDialog_', |
| + event.detail.anchor); |
| } |
| } else { |
| if (event.detail.action == CertificateAction.EDIT) { |
| this.openDialog_( |
| - 'settings-ca-trust-edit-dialog', 'showCaTrustEditDialog_'); |
| + 'settings-ca-trust-edit-dialog', 'showCaTrustEditDialog_', |
| + event.detail.anchor); |
| } else if (event.detail.action == CertificateAction.DELETE) { |
| this.openDialog_( |
| 'settings-certificate-delete-confirmation-dialog', |
| - 'showDeleteConfirmationDialog_'); |
| + 'showDeleteConfirmationDialog_', event.detail.anchor); |
| } else if (event.detail.action == |
| CertificateAction.EXPORT_PERSONAL) { |
| this.openDialog_( |
| 'settings-certificate-password-encryption-dialog', |
| - 'showPasswordEncryptionDialog_'); |
| + 'showPasswordEncryptionDialog_', event.detail.anchor); |
| } |
| } |
| @@ -136,10 +146,12 @@ Polymer({ |
| }.bind(this)); |
| this.addEventListener('certificates-error', function(event) { |
| - this.errorDialogModel_ = event.detail; |
| + var detail = /** @type {!CertificatesErrorEventDetail} */ (event.detail); |
| + this.errorDialogModel_ = detail.error; |
| this.openDialog_( |
| 'settings-certificates-error-dialog', |
| - 'showErrorDialog_'); |
| + 'showErrorDialog_', |
| + detail.anchor); |
| event.stopPropagation(); |
| }.bind(this)); |
| }, |
| @@ -152,14 +164,19 @@ Polymer({ |
| * @param {string} dialogTagName The tag name of the dialog to be shown. |
| * @param {string} domIfBooleanName The name of the boolean variable |
| * corresponding to the dialog. |
| + * @param {?HTMLElement} anchor The element to focus when the dialog is |
| + * closed. If null, the previous anchor element should be reused. |
| * @private |
| */ |
| - openDialog_: function(dialogTagName, domIfBooleanName) { |
| + openDialog_: function(dialogTagName, domIfBooleanName, anchor) { |
| + if (anchor) |
| + this.activeDialogAnchor_ = anchor; |
| this.set(domIfBooleanName, true); |
| this.async(function() { |
| var dialog = this.$$(dialogTagName); |
| dialog.addEventListener('close', function() { |
| this.set(domIfBooleanName, false); |
| + this.activeDialogAnchor_.focus(); |
|
tommycli
2017/04/04 22:42:29
It looks like you don't actually need to store act
Dan Beam
2017/04/04 22:46:00
also, why only set it if (anchor)?
Dan Beam
2017/04/04 22:47:21
tommycli@: the difference is that openDialog_ (in
tommycli
2017/04/04 22:56:49
Ah yes, that behavior is different.
Actually now
dpapad
2017/04/04 23:15:42
Certificates manager page is a pretty interesting
tommycli
2017/04/04 23:21:26
Wow that's really tricky. If the above is the inte
dpapad
2017/04/05 00:03:18
I was hoping that the explanation given at the JSD
Dan Beam
2017/04/05 03:31:36
ping ^
tommycli
2017/04/05 16:11:44
dbeam: I'm assuming it's because if anchor is null
|
| }.bind(this)); |
| }.bind(this)); |
| }, |