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

Side by Side Diff: chrome/browser/resources/settings/on_startup_page/startup_urls_page.js

Issue 2782393004: MD Settings: Restore focus after closing dialogs, for startup page. (Closed)
Patch Set: Fix test. 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
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 'settings-startup-urls-page' is the settings page 6 * @fileoverview 'settings-startup-urls-page' is the settings page
7 * containing the urls that will be opened when chrome is started. 7 * containing the urls that will be opened when chrome is started.
8 */ 8 */
9 9
10 Polymer({ 10 Polymer({
(...skipping 16 matching lines...) Expand all
27 /** @private */ 27 /** @private */
28 showStartupUrlDialog_: Boolean, 28 showStartupUrlDialog_: Boolean,
29 29
30 /** @private {?StartupPageInfo} */ 30 /** @private {?StartupPageInfo} */
31 startupUrlDialogModel_: Object, 31 startupUrlDialogModel_: Object,
32 32
33 /** @private {Object}*/ 33 /** @private {Object}*/
34 lastFocused_: Object, 34 lastFocused_: Object,
35 }, 35 },
36 36
37 /**
38 * The element to return focus to, when the startup-url-dialog is closed.
39 * @private {?HTMLElement}
40 */
41 startupUrlDialogAnchor_: null,
42
37 /** @override */ 43 /** @override */
38 attached: function() { 44 attached: function() {
39 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); 45 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance();
40 this.addWebUIListener('update-startup-pages', function(startupPages) { 46 this.addWebUIListener('update-startup-pages', function(startupPages) {
41 // If an "edit" URL dialog was open, close it, because the underlying page 47 // If an "edit" URL dialog was open, close it, because the underlying page
42 // might have just been removed (and model indices have changed anyway). 48 // might have just been removed (and model indices have changed anyway).
43 if (this.startupUrlDialogModel_) 49 if (this.startupUrlDialogModel_)
44 this.destroyUrlDialog_(); 50 this.destroyUrlDialog_();
45 this.startupPages_ = startupPages; 51 this.startupPages_ = startupPages;
46 this.updateScrollableContents(); 52 this.updateScrollableContents();
47 }.bind(this)); 53 }.bind(this));
48 this.browserProxy_.loadStartupPages(); 54 this.browserProxy_.loadStartupPages();
49 55
50 this.addEventListener(settings.EDIT_STARTUP_URL_EVENT, function(event) { 56 this.addEventListener(settings.EDIT_STARTUP_URL_EVENT, function(event) {
51 this.startupUrlDialogModel_ = event.detail; 57 this.startupUrlDialogModel_ = event.detail.model;
58 this.startupUrlDialogAnchor_ = event.detail.anchor;
52 this.showStartupUrlDialog_ = true; 59 this.showStartupUrlDialog_ = true;
53 event.stopPropagation(); 60 event.stopPropagation();
54 }.bind(this)); 61 }.bind(this));
55 }, 62 },
56 63
57 /** 64 /**
58 * @param {!Event} e 65 * @param {!Event} e
59 * @private 66 * @private
60 */ 67 */
61 onAddPageTap_: function(e) { 68 onAddPageTap_: function(e) {
62 e.preventDefault(); 69 e.preventDefault();
63 this.showStartupUrlDialog_ = true; 70 this.showStartupUrlDialog_ = true;
71 this.startupUrlDialogAnchor_ = /** @type {!HTMLElement} */ (
72 this.$$('#addPage a[is=action-link]'));
64 }, 73 },
65 74
66 /** @private */ 75 /** @private */
67 destroyUrlDialog_: function() { 76 destroyUrlDialog_: function() {
68 this.showStartupUrlDialog_ = false; 77 this.showStartupUrlDialog_ = false;
69 this.startupUrlDialogModel_ = null; 78 this.startupUrlDialogModel_ = null;
79 if (this.startupUrlDialogAnchor_) {
80 this.startupUrlDialogAnchor_.focus();
81 this.startupUrlDialogAnchor_ = null;
82 }
70 }, 83 },
71 84
72 /** @private */ 85 /** @private */
73 onUseCurrentPagesTap_: function() { 86 onUseCurrentPagesTap_: function() {
74 this.browserProxy_.useCurrentPages(); 87 this.browserProxy_.useCurrentPages();
75 }, 88 },
76 }); 89 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698