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_: { | |
dpapad
2016/03/31 18:39:56
Nit(optional): When the default value is false you
Dan Beam
2016/03/31 22:06:54
i wouldn't encourage this, as one might assume the
| |
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 27 matching lines...) Expand all Loading... | |
86 /** @private */ | 92 /** @private */ |
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 /** @private */ |
97 * @return {boolean} Whether tapping the Add button should be allowed. | 103 newUrlChanged_: function() { |
98 * @private | 104 this.browserProxy_.validateStartupPage(this.newUrl_).then(function(valid) { |
99 */ | 105 this.isNewUrlValid_ = valid; |
dpapad
2016/03/31 18:39:56
Nit (optional): s/valid/isValid
Dan Beam
2016/03/31 22:06:54
Done.
| |
100 isAddEnabled_: function() { | 106 }.bind(this)); |
101 return this.browserProxy_.canAddPage(this.newUrl_); | |
102 }, | 107 }, |
103 | 108 |
104 /** @private */ | 109 /** @private */ |
105 onAddTap_: function() { | 110 onAddTap_: function() { |
106 assert(this.isAddEnabled_()); | 111 assert(this.isNewUrlValid_); |
107 this.browserProxy_.addStartupPage(this.newUrl_); | 112 this.browserProxy_.addStartupPage(this.newUrl_); |
108 this.$.addUrlDialog.close(); | 113 this.$.addUrlDialog.close(); |
109 }, | 114 }, |
110 | 115 |
111 /** | 116 /** |
112 * @param {!{model: !{index: number}}} e | 117 * @param {!{model: !{index: number}}} e |
113 * @private | 118 * @private |
114 */ | 119 */ |
115 onRemoveUrlTap_: function(e) { | 120 onRemoveUrlTap_: function(e) { |
116 this.browserProxy_.removeStartupPage(e.model.index); | 121 this.browserProxy_.removeStartupPage(e.model.index); |
117 }, | 122 }, |
118 }); | 123 }); |
OLD | NEW |