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 * @typedef {{ | 6 * @typedef {{ |
7 * 'title': string, | 7 * 'title': string, |
8 * 'tooltip': string, | 8 * 'tooltip': string, |
9 * 'url': string | 9 * 'url': string |
10 * }} | 10 * }} |
(...skipping 24 matching lines...) Expand all Loading... | |
35 prefs: { | 35 prefs: { |
36 type: Object, | 36 type: Object, |
37 notify: true, | 37 notify: true, |
38 }, | 38 }, |
39 | 39 |
40 /** @type {settings.StartupUrlsPageBrowserProxy} */ | 40 /** @type {settings.StartupUrlsPageBrowserProxy} */ |
41 browserProxy_: Object, | 41 browserProxy_: Object, |
42 | 42 |
43 /** @private {string} */ | 43 /** @private {string} */ |
44 newUrl_: { | 44 newUrl_: { |
45 observer: 'newUrlChanged_', | |
45 type: String, | 46 type: String, |
46 value: '', | 47 value: '', |
47 }, | 48 }, |
48 | 49 |
50 isNewUrlValid_: { | |
51 type: Boolean, | |
52 value: false, | |
53 }, | |
54 | |
49 /** | 55 /** |
50 * Pages to load upon browser startup. | 56 * Pages to load upon browser startup. |
51 * @private {!Array<!StartupPageInfo>} | 57 * @private {!Array<!StartupPageInfo>} |
52 */ | 58 */ |
53 startupPages_: Array, | 59 startupPages_: Array, |
54 }, | 60 }, |
55 | 61 |
56 created: function() { | 62 created: function() { |
57 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); | 63 this.browserProxy_ = settings.StartupUrlsPageBrowserProxyImpl.getInstance(); |
58 }, | 64 }, |
(...skipping 28 matching lines...) Expand all Loading... | |
87 onUseCurrentPagesTap_: function() { | 93 onUseCurrentPagesTap_: function() { |
88 this.browserProxy_.useCurrentPages(); | 94 this.browserProxy_.useCurrentPages(); |
89 }, | 95 }, |
90 | 96 |
91 /** @private */ | 97 /** @private */ |
92 onCancelTap_: function() { | 98 onCancelTap_: function() { |
93 this.$.addUrlDialog.close(); | 99 this.$.addUrlDialog.close(); |
94 }, | 100 }, |
95 | 101 |
96 /** | 102 /** |
97 * @return {boolean} Whether tapping the Add button should be allowed. | 103 * @param {string} newUrl |
98 * @private | 104 * @private |
99 */ | 105 */ |
100 isAddEnabled_: function() { | 106 newUrlChanged_: function(newUrl) { |
dschuyler
2016/03/31 20:29:25
There looks to be a small race condition here.
I t
Dan Beam
2016/03/31 22:06:55
Done.
| |
101 return this.browserProxy_.canAddPage(this.newUrl_); | 107 this.browserProxy_.validateStartupPage(newUrl).then(function(isValid) { |
108 this.isNewUrlValid_ = isValid; | |
109 }.bind(this)); | |
102 }, | 110 }, |
103 | 111 |
104 /** @private */ | 112 /** @private */ |
105 onAddTap_: function() { | 113 onAddTap_: function() { |
106 assert(this.isAddEnabled_()); | 114 assert(this.isNewUrlValid_); |
107 this.browserProxy_.addStartupPage(this.newUrl_); | 115 this.browserProxy_.addStartupPage(this.newUrl_); |
108 this.$.addUrlDialog.close(); | 116 this.$.addUrlDialog.close(); |
109 }, | 117 }, |
110 | 118 |
111 /** | 119 /** |
112 * @param {!{model: !{index: number}}} e | 120 * @param {!{model: !{index: number}}} e |
113 * @private | 121 * @private |
114 */ | 122 */ |
115 onRemoveUrlTap_: function(e) { | 123 onRemoveUrlTap_: function(e) { |
116 this.browserProxy_.removeStartupPage(e.model.index); | 124 this.browserProxy_.removeStartupPage(e.model.index); |
117 }, | 125 }, |
118 }); | 126 }); |
OLD | NEW |