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 c8ba1c61264f02f3122c94ac2c8d9cff95daed12..51669432735714d3a70b1b1716f218ec1f834d2e 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 |
@@ -42,10 +42,16 @@ Polymer({ |
/** @private {string} */ |
newUrl_: { |
+ observer: 'newUrlChanged_', |
type: String, |
value: '', |
}, |
+ isNewUrlValid_: { |
+ type: Boolean, |
+ value: false, |
+ }, |
+ |
/** |
* Pages to load upon browser startup. |
* @private {!Array<!StartupPageInfo>} |
@@ -94,16 +100,27 @@ Polymer({ |
}, |
/** |
- * @return {boolean} Whether tapping the Add button should be allowed. |
+ * @param {string} newUrl |
* @private |
*/ |
- isAddEnabled_: function() { |
- return this.browserProxy_.canAddPage(this.newUrl_); |
+ 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. |
+ }); |
}, |
/** @private */ |
onAddTap_: function() { |
- assert(this.isAddEnabled_()); |
+ assert(this.isNewUrlValid_); |
this.browserProxy_.addStartupPage(this.newUrl_); |
this.$.addUrlDialog.close(); |
}, |