| 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-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 15 matching lines...) Expand all Loading... |
| 26 showStartupUrlDialog_: Boolean, | 26 showStartupUrlDialog_: Boolean, |
| 27 | 27 |
| 28 /** @private {?StartupPageInfo} */ | 28 /** @private {?StartupPageInfo} */ |
| 29 startupUrlDialogModel_: Object, | 29 startupUrlDialogModel_: Object, |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /** @override */ | 32 /** @override */ |
| 33 attached: function() { | 33 attached: function() { |
| 34 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); | 34 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); |
| 35 this.addWebUIListener('update-startup-pages', function(startupPages) { | 35 this.addWebUIListener('update-startup-pages', function(startupPages) { |
| 36 // If an "edit" URL dialog was open, close it, because the underlying page |
| 37 // might have just been removed (and model indices have changed anyway). |
| 38 if (this.startupUrlDialogModel_) |
| 39 this.destroyUrlDialog_(); |
| 36 this.startupPages_ = startupPages; | 40 this.startupPages_ = startupPages; |
| 37 this.updateScrollableContents(); | 41 this.updateScrollableContents(); |
| 38 }.bind(this)); | 42 }.bind(this)); |
| 39 this.browserProxy_.loadStartupPages(); | 43 this.browserProxy_.loadStartupPages(); |
| 40 | 44 |
| 41 this.addEventListener(settings.EDIT_STARTUP_URL_EVENT, function(event) { | 45 this.addEventListener(settings.EDIT_STARTUP_URL_EVENT, function(event) { |
| 42 this.startupUrlDialogModel_ = event.detail; | 46 this.startupUrlDialogModel_ = event.detail; |
| 43 this.openDialog_(); | 47 this.showStartupUrlDialog_ = true; |
| 44 event.stopPropagation(); | 48 event.stopPropagation(); |
| 45 }.bind(this)); | 49 }.bind(this)); |
| 46 }, | 50 }, |
| 47 | 51 |
| 48 /** @private */ | 52 /** @private */ |
| 49 onAddPageTap_: function() { | 53 onAddPageTap_: function() { |
| 50 this.openDialog_(); | |
| 51 }, | |
| 52 | |
| 53 /** | |
| 54 * Opens the dialog and registers a listener for removing the dialog from the | |
| 55 * DOM once is closed. The listener is destroyed when the dialog is removed | |
| 56 * (because of 'restamp'). | |
| 57 * @private | |
| 58 */ | |
| 59 openDialog_: function() { | |
| 60 this.showStartupUrlDialog_ = true; | 54 this.showStartupUrlDialog_ = true; |
| 61 this.async(function() { | |
| 62 var dialog = this.$$('settings-startup-url-dialog'); | |
| 63 dialog.addEventListener('close', function() { | |
| 64 this.showStartupUrlDialog_ = false; | |
| 65 this.startupUrlDialogModel_ = null; | |
| 66 }.bind(this)); | |
| 67 }.bind(this)); | |
| 68 }, | 55 }, |
| 69 | 56 |
| 70 /** @private */ | 57 /** @private */ |
| 58 destroyUrlDialog_: function() { |
| 59 this.showStartupUrlDialog_ = false; |
| 60 this.startupUrlDialogModel_ = null; |
| 61 }, |
| 62 |
| 63 /** @private */ |
| 71 onUseCurrentPagesTap_: function() { | 64 onUseCurrentPagesTap_: function() { |
| 72 this.browserProxy_.useCurrentPages(); | 65 this.browserProxy_.useCurrentPages(); |
| 73 }, | 66 }, |
| 74 }); | 67 }); |
| OLD | NEW |