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

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_list.js

Issue 2791053002: MD Settings: Restore focus after closing dialogs, for content settings. (Closed)
Patch Set: Nit. 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_list.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6 * @fileoverview
7 * 'site-list' shows a list of Allowed and Blocked sites for a given 7 * 'site-list' shows a list of Allowed and Blocked sites for a given
8 * category. 8 * category.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 type: Object, 101 type: Object,
102 values: { 102 values: {
103 ALLOW: 'Allow', 103 ALLOW: 'Allow',
104 BLOCK: 'Block', 104 BLOCK: 'Block',
105 RESET: 'Reset', 105 RESET: 'Reset',
106 SESSION_ONLY: 'SessionOnly', 106 SESSION_ONLY: 'SessionOnly',
107 } 107 }
108 }, 108 },
109 }, 109 },
110 110
111 /**
112 * The element to return focus to, when the currntly active dialog is closed.
113 * @private {?HTMLElement}
114 */
115 activeDialogAnchor_: null,
116
111 observers: ['configureWidget_(category, categorySubtype)'], 117 observers: ['configureWidget_(category, categorySubtype)'],
112 118
113 ready: function() { 119 ready: function() {
114 this.addWebUIListener('contentSettingSitePermissionChanged', 120 this.addWebUIListener('contentSettingSitePermissionChanged',
115 this.siteWithinCategoryChanged_.bind(this)); 121 this.siteWithinCategoryChanged_.bind(this));
116 this.addWebUIListener('onIncognitoStatusChanged', 122 this.addWebUIListener('onIncognitoStatusChanged',
117 this.onIncognitoStatusChanged_.bind(this)); 123 this.onIncognitoStatusChanged_.bind(this));
118 }, 124 },
119 125
120 /** 126 /**
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 assert(!this.readOnlyList); 214 assert(!this.readOnlyList);
209 e.preventDefault(); 215 e.preventDefault();
210 var dialog = document.createElement('add-site-dialog'); 216 var dialog = document.createElement('add-site-dialog');
211 dialog.category = this.category; 217 dialog.category = this.category;
212 dialog.contentSetting = this.categorySubtype; 218 dialog.contentSetting = this.categorySubtype;
213 this.shadowRoot.appendChild(dialog); 219 this.shadowRoot.appendChild(dialog);
214 220
215 dialog.open(this.categorySubtype); 221 dialog.open(this.categorySubtype);
216 222
217 dialog.addEventListener('close', function() { 223 dialog.addEventListener('close', function() {
224 this.$.addSite.focus();
218 dialog.remove(); 225 dialog.remove();
219 }); 226 }.bind(this));
220 }, 227 },
221 228
222 /** 229 /**
223 * Populate the sites list for display. 230 * Populate the sites list for display.
224 * @private 231 * @private
225 */ 232 */
226 populateList_: function() { 233 populateList_: function() {
227 if (this.allSites) { 234 if (this.allSites) {
228 this.getAllSitesList_().then(function(lists) { 235 this.getAllSitesList_().then(function(lists) {
229 this.processExceptions_(lists); 236 this.processExceptions_(lists);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // bound to the dialog. 435 // bound to the dialog.
429 /** @type {!CrActionMenuElement} */ ( 436 /** @type {!CrActionMenuElement} */ (
430 this.$$('dialog[is=cr-action-menu]')).close(); 437 this.$$('dialog[is=cr-action-menu]')).close();
431 this.showEditExceptionDialog_ = true; 438 this.showEditExceptionDialog_ = true;
432 }, 439 },
433 440
434 /** @private */ 441 /** @private */
435 onEditExceptionDialogClosed_: function() { 442 onEditExceptionDialogClosed_: function() {
436 this.showEditExceptionDialog_ = false; 443 this.showEditExceptionDialog_ = false;
437 this.actionMenuSite_ = null; 444 this.actionMenuSite_ = null;
445 this.activeDialogAnchor_.focus();
446 this.activeDialogAnchor_ = null;
438 }, 447 },
439 448
440 /** @private */ 449 /** @private */
441 onResetTap_: function() { 450 onResetTap_: function() {
442 this.resetPermissionForOrigin_(this.actionMenuSite_); 451 this.resetPermissionForOrigin_(this.actionMenuSite_);
443 this.closeActionMenu_(); 452 this.closeActionMenu_();
444 }, 453 },
445 454
446 /** 455 /**
447 * Returns the appropriate site description to display. This can, for example, 456 * Returns the appropriate site description to display. This can, for example,
(...skipping 19 matching lines...) Expand all
467 */ 476 */
468 onResetButtonTap_: function(e) { 477 onResetButtonTap_: function(e) {
469 this.resetPermissionForOrigin_(e.model.item); 478 this.resetPermissionForOrigin_(e.model.item);
470 }, 479 },
471 480
472 /** 481 /**
473 * @param {!{model: !{item: !SiteException}}} e 482 * @param {!{model: !{item: !SiteException}}} e
474 * @private 483 * @private
475 */ 484 */
476 onShowActionMenuTap_: function(e) { 485 onShowActionMenuTap_: function(e) {
486 this.activeDialogAnchor_ = /** @type {!HTMLElement} */ (
487 Polymer.dom(/** @type {!Event} */ (e)).localTarget);
dschuyler 2017/04/03 21:44:56 There's a lot of text for a simple "A = B" line. C
dpapad 2017/04/03 23:42:09 Tried changing the @param to "{!Event|!{model: !{i
488
477 this.actionMenuSite_ = e.model.item; 489 this.actionMenuSite_ = e.model.item;
478 /** @type {!CrActionMenuElement} */ ( 490 /** @type {!CrActionMenuElement} */ (
479 this.$$('dialog[is=cr-action-menu]')).showAt( 491 this.$$('dialog[is=cr-action-menu]')).showAt(this.activeDialogAnchor_);
480 /** @type {!Element} */ (
481 Polymer.dom(/** @type {!Event} */ (e)).localTarget));
482 }, 492 },
483 493
484 /** @private */ 494 /** @private */
485 closeActionMenu_: function() { 495 closeActionMenu_: function() {
486 this.actionMenuSite_ = null; 496 this.actionMenuSite_ = null;
497 this.activeDialogAnchor_ = null;
487 var actionMenu = /** @type {!CrActionMenuElement} */ ( 498 var actionMenu = /** @type {!CrActionMenuElement} */ (
488 this.$$('dialog[is=cr-action-menu]')); 499 this.$$('dialog[is=cr-action-menu]'));
489 if (actionMenu.open) 500 if (actionMenu.open)
490 actionMenu.close(); 501 actionMenu.close();
491 }, 502 },
492 }); 503 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_list.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698