Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Unified Diff: chrome/browser/resources/settings/certificate_manager_page/certificate_manager_page.js

Issue 2792663002: MD Settings: Restore focus after closing dialogs, for certificate page. (Closed)
Patch Set: Add better explanation for |anchor| parameter in openDialog_ Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d48ce13c304e2903d1adf96b97f0b014c6bf88e5 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,22 @@ 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. This
+ * happens when a 'settings-certificates-error-dialog' is opened,
+ * which when closed should focus the anchor of the previous dialog (the
+ * one that generated the error).
* @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();
}.bind(this));
}.bind(this));
},

Powered by Google App Engine
This is Rietveld 408576698