Chromium Code Reviews| 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 524a21dd58c7d1ea2d668e667256f98b7c61d6e2..586a6d8784608b073126bfad52b6f3bdbf3f74b8 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 |
| @@ -38,8 +38,10 @@ Polymer({ |
| notify: true, |
| }, |
| - newUrl: { |
| + /** @private {string} */ |
| + newUrl_: { |
| type: String, |
| + value: '', |
| }, |
| /** |
| @@ -68,6 +70,7 @@ Polymer({ |
| /** @private */ |
| onAddPageTap_: function() { |
| + this.newUrl_ = ''; |
| this.$.addUrlDialog.open(); |
| }, |
| @@ -81,13 +84,18 @@ Polymer({ |
| this.$.addUrlDialog.close(); |
| }, |
| + /** |
| + * @return {boolean} Whether tapping the OK button should be allowed. |
| + * @private |
| + */ |
| + isOkAllowed_: function() { |
| + return this.newUrl_.length > 0; |
|
dschuyler
2016/03/01 03:15:52
Can we re-add the trim() to avoid urls like ' ' an
Dan Beam
2016/03/02 19:56:42
Done.
|
| + }, |
| + |
| /** @private */ |
| onOkTap_: function() { |
| - var value = this.newUrl && this.newUrl.trim(); |
| - if (!value) |
| - return; |
| - chrome.send('addStartupPage', [value]); |
| - this.newUrl = ''; |
| + assert(this.isOkAllowed_()); |
| + chrome.send('addStartupPage', [this.newUrl_]); |
| this.$.addUrlDialog.close(); |
| }, |