OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @fileoverview 'settings-about-page' contains version and OS related | 6 * @fileoverview 'settings-about-page' contains version and OS related |
7 * information. | 7 * information. |
8 */ | 8 */ |
9 Polymer({ | 9 Polymer({ |
10 is: 'settings-about-page', | 10 is: 'settings-about-page', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 browserProxy_: null, | 42 browserProxy_: null, |
43 | 43 |
44 /** | 44 /** |
45 * @type {string} Selector to get the sections. | 45 * @type {string} Selector to get the sections. |
46 * TODO(michaelpg): replace duplicate docs with @override once b/24294625 | 46 * TODO(michaelpg): replace duplicate docs with @override once b/24294625 |
47 * is fixed. | 47 * is fixed. |
48 */ | 48 */ |
49 sectionSelector: 'settings-section', | 49 sectionSelector: 'settings-section', |
50 | 50 |
51 /** @override */ | 51 /** @override */ |
52 ready: function() { | 52 attached: function() { |
53 this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 53 this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); |
54 this.browserProxy_.pageReady(); | 54 this.browserProxy_.pageReady(); |
55 | 55 |
56 <if expr="chromeos"> | 56 <if expr="chromeos"> |
| 57 this.addEventListener('target-channel-changed', function(e) { |
| 58 this.targetChannel_ = e.detail; |
| 59 }.bind(this)); |
| 60 |
57 Promise.all([ | 61 Promise.all([ |
58 this.browserProxy_.getCurrentChannel(), | 62 this.browserProxy_.getCurrentChannel(), |
59 this.browserProxy_.getTargetChannel(), | 63 this.browserProxy_.getTargetChannel(), |
60 ]).then(function(channels) { | 64 ]).then(function(channels) { |
61 this.currentChannel_ = channels[0]; | 65 this.currentChannel_ = channels[0]; |
62 this.targetChannel_ = channels[1]; | 66 this.targetChannel_ = channels[1]; |
63 | 67 |
64 this.startListening_(); | 68 this.startListening_(); |
65 }.bind(this)); | 69 }.bind(this)); |
66 | 70 |
67 this.browserProxy_.getRegulatoryInfo().then(function(info) { | 71 this.browserProxy_.getRegulatoryInfo().then(function(info) { |
68 this.regulatoryInfo_ = info; | 72 this.regulatoryInfo_ = info; |
69 }.bind(this)); | 73 }.bind(this)); |
70 </if> | 74 </if> |
71 <if expr="not chromeos"> | 75 <if expr="not chromeos"> |
72 this.startListening_(); | 76 this.startListening_(); |
73 </if> | 77 </if> |
| 78 |
| 79 this.scroller = this.parentElement; |
74 }, | 80 }, |
75 | 81 |
76 /** @private */ | 82 /** @private */ |
77 startListening_: function() { | 83 startListening_: function() { |
78 this.addWebUIListener( | 84 this.addWebUIListener( |
79 'update-status-changed', | 85 'update-status-changed', |
80 this.onUpdateStatusChanged_.bind(this)); | 86 this.onUpdateStatusChanged_.bind(this)); |
81 this.browserProxy_.refreshUpdateStatus(); | 87 this.browserProxy_.refreshUpdateStatus(); |
82 }, | 88 }, |
83 | 89 |
84 /** | 90 /** |
85 * @param {!UpdateStatusChangedEvent} event | 91 * @param {!UpdateStatusChangedEvent} event |
86 * @private | 92 * @private |
87 */ | 93 */ |
88 onUpdateStatusChanged_: function(event) { | 94 onUpdateStatusChanged_: function(event) { |
89 <if expr="chromeos"> | 95 <if expr="chromeos"> |
90 if (event.status == UpdateStatus.CHECKING) | 96 if (event.status == UpdateStatus.CHECKING) |
91 this.hasCheckedForUpdates_ = true; | 97 this.hasCheckedForUpdates_ = true; |
92 </if> | 98 </if> |
93 this.currentUpdateStatusEvent_ = event; | 99 this.currentUpdateStatusEvent_ = event; |
94 }, | 100 }, |
95 | 101 |
96 /** @override */ | |
97 attached: function() { | |
98 this.scroller = this.parentElement; | |
99 }, | |
100 | |
101 /** @private */ | 102 /** @private */ |
102 onHelpTap_: function() { | 103 onHelpTap_: function() { |
103 this.browserProxy_.openHelpPage(); | 104 this.browserProxy_.openHelpPage(); |
104 }, | 105 }, |
105 | 106 |
106 /** @private */ | 107 /** @private */ |
107 onRelaunchTap_: function() { | 108 onRelaunchTap_: function() { |
108 this.browserProxy_.relaunchNow(); | 109 this.browserProxy_.relaunchNow(); |
109 }, | 110 }, |
110 | 111 |
111 /** | 112 /** |
112 * @return {boolean} | 113 * @return {boolean} |
113 * @private | 114 * @private |
114 */ | 115 */ |
115 shouldShowUpdateStatus_: function() { | 116 shouldShowUpdateStatus_: function() { |
116 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED; | 117 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED; |
117 }, | 118 }, |
118 | 119 |
119 /** | 120 /** |
120 * @return {boolean} | 121 * @return {boolean} |
121 * @private | 122 * @private |
122 */ | 123 */ |
123 shouldShowRelaunch_: function() { | 124 shouldShowRelaunch_: function() { |
124 var shouldShow = false; | 125 var shouldShow = false; |
125 <if expr="not chromeos"> | 126 <if expr="not chromeos"> |
126 shouldShow = | 127 shouldShow = this.checkStatus_(UpdateStatus.NEARLY_UPDATED); |
127 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED; | |
128 </if> | 128 </if> |
129 <if expr="chromeos"> | 129 <if expr="chromeos"> |
130 shouldShow = !this.isTargetChannelMoreStable_() && | 130 shouldShow = this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && |
131 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED; | 131 !this.isTargetChannelMoreStable_(); |
132 </if> | 132 </if> |
133 return shouldShow; | 133 return shouldShow; |
134 }, | 134 }, |
135 | 135 |
136 /** | 136 /** |
137 * @return {string} | 137 * @return {string} |
138 * @private | 138 * @private |
139 */ | 139 */ |
140 getUpdateStatusMessage_: function() { | 140 getUpdateStatusMessage_: function() { |
141 switch (this.currentUpdateStatusEvent_.status) { | 141 switch (this.currentUpdateStatusEvent_.status) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 getIconSrc_: function() { | 187 getIconSrc_: function() { |
188 switch (this.currentUpdateStatusEvent_.status) { | 188 switch (this.currentUpdateStatusEvent_.status) { |
189 case UpdateStatus.CHECKING: | 189 case UpdateStatus.CHECKING: |
190 case UpdateStatus.UPDATING: | 190 case UpdateStatus.UPDATING: |
191 return 'chrome://resources/images/throbber_small.svg'; | 191 return 'chrome://resources/images/throbber_small.svg'; |
192 default: | 192 default: |
193 return null; | 193 return null; |
194 } | 194 } |
195 }, | 195 }, |
196 | 196 |
| 197 /** |
| 198 * @param {!UpdateStatus} status |
| 199 * @return {boolean} |
| 200 * @private |
| 201 */ |
| 202 checkStatus_: function(status) { |
| 203 return this.currentUpdateStatusEvent_.status == status; |
| 204 }, |
| 205 |
197 <if expr="chromeos"> | 206 <if expr="chromeos"> |
198 /** | 207 /** |
199 * @return {boolean} | 208 * @return {boolean} |
200 * @private | 209 * @private |
201 */ | 210 */ |
202 isTargetChannelMoreStable_: function() { | 211 isTargetChannelMoreStable_: function() { |
203 assert(this.currentChannel_.length > 0); | 212 assert(this.currentChannel_.length > 0); |
204 assert(this.targetChannel_.length > 0); | 213 assert(this.targetChannel_.length > 0); |
205 return settings.isTargetChannelMoreStable( | 214 return settings.isTargetChannelMoreStable( |
206 this.currentChannel_, this.targetChannel_); | 215 this.currentChannel_, this.targetChannel_); |
207 }, | 216 }, |
208 | 217 |
209 /** @private */ | 218 /** @private */ |
210 onDetailedBuildInfoTap_: function() { | 219 onDetailedBuildInfoTap_: function() { |
211 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( | 220 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( |
212 this.$.pages); | 221 this.$.pages); |
213 animatedPages.setSubpageChain(['detailed-build-info']); | 222 animatedPages.setSubpageChain(['detailed-build-info']); |
214 }, | 223 }, |
215 | 224 |
216 /** @private */ | 225 /** @private */ |
217 onRelaunchAndPowerwashTap_: function() { | 226 onRelaunchAndPowerwashTap_: function() { |
218 // TODO(dpapad): Implement this. | 227 // TODO(dpapad): Implement this. |
219 }, | 228 }, |
220 | 229 |
221 /** | 230 /** |
222 * @return {boolean} | 231 * @return {boolean} |
223 * @private | 232 * @private |
224 */ | 233 */ |
225 shouldShowRelaunchAndPowerwash_: function() { | 234 shouldShowRelaunchAndPowerwash_: function() { |
226 return this.isTargetChannelMoreStable_() && | 235 return this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && |
227 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED; | 236 this.isTargetChannelMoreStable_(); |
228 }, | 237 }, |
229 | 238 |
230 /** @private */ | 239 /** @private */ |
231 onCheckUpdatesTap_: function() { | 240 onCheckUpdatesTap_: function() { |
232 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING}); | 241 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING}); |
233 this.browserProxy_.requestUpdate(); | 242 this.browserProxy_.requestUpdate(); |
234 }, | 243 }, |
235 | 244 |
236 /** | 245 /** |
237 * @return {boolean} | 246 * @return {boolean} |
238 * @private | 247 * @private |
239 */ | 248 */ |
240 shouldShowCheckUpdates_: function() { | 249 shouldShowCheckUpdates_: function() { |
241 return !this.hasCheckedForUpdates_ || | 250 return !this.hasCheckedForUpdates_ || |
242 this.currentUpdateStatusEvent_.status == UpdateStatus.FAILED; | 251 this.checkStatus_(UpdateStatus.FAILED); |
243 }, | 252 }, |
244 | 253 |
245 /** | 254 /** |
246 * @return {boolean} | 255 * @return {boolean} |
247 * @private | 256 * @private |
248 */ | 257 */ |
249 shouldShowRegulatoryInfo_: function() { | 258 shouldShowRegulatoryInfo_: function() { |
250 return this.regulatoryInfo_ !== null; | 259 return this.regulatoryInfo_ !== null; |
251 }, | 260 }, |
252 </if> | 261 </if> |
253 | 262 |
254 <if expr="_google_chrome"> | 263 <if expr="_google_chrome"> |
255 /** @private */ | 264 /** @private */ |
256 onReportIssueTap_: function() { | 265 onReportIssueTap_: function() { |
257 this.browserProxy_.openFeedbackDialog(); | 266 this.browserProxy_.openFeedbackDialog(); |
258 }, | 267 }, |
259 </if> | 268 </if> |
260 }); | 269 }); |
OLD | NEW |