Index: chrome/browser/resources/settings/on_startup_page/startup_urls_page.js |
diff --git a/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js b/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js |
index a7dbf30bbb2bad21be017726354a43b6fc7d7f44..1d24c367bed4100e327c259fce16b2d0b47c4b09 100644 |
--- a/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js |
+++ b/chrome/browser/resources/settings/on_startup_page/startup_urls_page.js |
@@ -33,6 +33,10 @@ Polymer({ |
attached: function() { |
this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); |
this.addWebUIListener('update-startup-pages', function(startupPages) { |
+ // If an "edit" URL dialog was open, close it, because the underlying page |
+ // might have just been removed (and model indices have changed anyway). |
+ if (this.startupUrlDialogModel_) |
+ this.destroyUrlDialog_(); |
this.startupPages_ = startupPages; |
this.updateScrollableContents(); |
}.bind(this)); |
@@ -40,31 +44,20 @@ Polymer({ |
this.addEventListener(settings.EDIT_STARTUP_URL_EVENT, function(event) { |
this.startupUrlDialogModel_ = event.detail; |
- this.openDialog_(); |
+ this.showStartupUrlDialog_ = true; |
event.stopPropagation(); |
}.bind(this)); |
}, |
/** @private */ |
onAddPageTap_: function() { |
- this.openDialog_(); |
+ this.showStartupUrlDialog_ = true; |
}, |
- /** |
- * Opens the dialog and registers a listener for removing the dialog from the |
- * DOM once is closed. The listener is destroyed when the dialog is removed |
- * (because of 'restamp'). |
- * @private |
- */ |
- openDialog_: function() { |
- this.showStartupUrlDialog_ = true; |
- this.async(function() { |
- var dialog = this.$$('settings-startup-url-dialog'); |
- dialog.addEventListener('close', function() { |
- this.showStartupUrlDialog_ = false; |
- this.startupUrlDialogModel_ = null; |
- }.bind(this)); |
- }.bind(this)); |
+ /** @private */ |
+ destroyUrlDialog_: function() { |
+ this.showStartupUrlDialog_ = false; |
+ this.startupUrlDialogModel_ = null; |
}, |
/** @private */ |