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 51669432735714d3a70b1b1716f218ec1f834d2e..6ec9bc28dade3a824b6e25cf120713f06cfd952b 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 |
@@ -14,14 +14,6 @@ var StartupPageInfo; |
/** |
* @fileoverview 'settings-startup-urls-page' is the settings page |
* containing the urls that will be opened when chrome is started. |
- * |
- * Example: |
- * |
- * <neon-animated-pages> |
- * <settings-startup-urls-page prefs="{{prefs}}"> |
- * </settings-startup-urls-page> |
- * ... other pages ... |
- * </neon-animated-pages> |
*/ |
Polymer({ |
is: 'settings-startup-urls-page', |
@@ -29,43 +21,24 @@ Polymer({ |
behaviors: [WebUIListenerBehavior], |
properties: { |
- /** |
- * Preferences state. |
- */ |
- prefs: { |
- type: Object, |
- notify: true, |
- }, |
- |
/** @type {settings.StartupUrlsPageBrowserProxy} */ |
browserProxy_: Object, |
- /** @private {string} */ |
- newUrl_: { |
- observer: 'newUrlChanged_', |
- type: String, |
- value: '', |
- }, |
- |
- isNewUrlValid_: { |
- type: Boolean, |
- value: false, |
- }, |
- |
/** |
* Pages to load upon browser startup. |
* @private {!Array<!StartupPageInfo>} |
*/ |
startupPages_: Array, |
- }, |
- created: function() { |
- this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); |
+ showStartupUrlDialog_: Boolean, |
}, |
+ /** @override */ |
attached: function() { |
- this.addWebUIListener('update-startup-pages', |
- this.updateStartupPages_.bind(this)); |
+ this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); |
+ this.addWebUIListener('update-startup-pages', function(startupPages) { |
+ this.startupPages_ = startupPages; |
+ }.bind(this)); |
this.browserProxy_.loadStartupPages(); |
}, |
@@ -78,51 +51,25 @@ Polymer({ |
return getFaviconImageSet(url); |
}, |
- /** @private */ |
- updateStartupPages_: function(startupPages) { |
- this.startupPages_ = startupPages; |
- }, |
- |
- /** @private */ |
- onAddPageTap_: function() { |
- this.newUrl_ = ''; |
- this.$.addUrlDialog.open(); |
- }, |
- |
- /** @private */ |
- onUseCurrentPagesTap_: function() { |
- this.browserProxy_.useCurrentPages(); |
- }, |
- |
- /** @private */ |
- onCancelTap_: function() { |
- this.$.addUrlDialog.close(); |
- }, |
- |
/** |
- * @param {string} newUrl |
+ * 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 |
*/ |
- newUrlChanged_: function(newUrl) { |
- if (this.validationResolver_) |
- this.validationResolver_.reject(false); |
- |
- /** @type {?PromiseResolver<boolean>} */ |
- this.validationResolver_ = this.browserProxy_.validateStartupPage(newUrl); |
- |
- this.validationResolver_.promise.then(function(isValid) { |
- this.isNewUrlValid_ = isValid; |
- this.validationResolver_ = null; |
- }.bind(this), function() { |
- // Squelchs console errors. |
- }); |
+ onAddPageTap_: function() { |
+ this.showStartupUrlDialog_ = true; |
+ this.async(function() { |
+ var dialog = this.$$('settings-startup-url-dialog'); |
+ dialog.addEventListener('iron-overlay-closed', function() { |
+ this.showStartupUrlDialog_ = false; |
+ }.bind(this)); |
+ }.bind(this)); |
}, |
/** @private */ |
- onAddTap_: function() { |
- assert(this.isNewUrlValid_); |
- this.browserProxy_.addStartupPage(this.newUrl_); |
- this.$.addUrlDialog.close(); |
+ onUseCurrentPagesTap_: function() { |
+ this.browserProxy_.useCurrentPages(); |
}, |
/** |