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', |
11 | 11 |
12 behaviors: [WebUIListenerBehavior, MainPageBehavior, I18nBehavior], | 12 behaviors: [WebUIListenerBehavior, MainPageBehavior, I18nBehavior], |
13 | 13 |
14 properties: { | 14 properties: { |
15 /** @private {?UpdateStatusChangedEvent} */ | 15 /** @private {?UpdateStatusChangedEvent} */ |
16 currentUpdateStatusEvent_: { | 16 currentUpdateStatusEvent_: { |
17 type: Object, | 17 type: Object, |
18 value: {message: '', progress: 0, status: UpdateStatus.DISABLED}, | 18 value: {message: '', progress: 0, status: UpdateStatus.DISABLED}, |
19 }, | 19 }, |
20 | 20 |
21 <if expr="chromeos"> | 21 // <if expr="chromeos"> |
22 /** @private */ | 22 /** @private */ |
23 hasCheckedForUpdates_: { | 23 hasCheckedForUpdates_: { |
24 type: Boolean, | 24 type: Boolean, |
25 value: false, | 25 value: false, |
26 }, | 26 }, |
27 | 27 |
28 /** @private {!BrowserChannel} */ | 28 /** @private {!BrowserChannel} */ |
29 currentChannel_: String, | 29 currentChannel_: String, |
30 | 30 |
31 /** @private {!BrowserChannel} */ | 31 /** @private {!BrowserChannel} */ |
32 targetChannel_: String, | 32 targetChannel_: String, |
33 | 33 |
34 /** @private {?RegulatoryInfo} */ | 34 /** @private {?RegulatoryInfo} */ |
35 regulatoryInfo_: Object, | 35 regulatoryInfo_: Object, |
36 </if> | 36 // </if> |
37 | 37 |
38 <if expr="_google_chrome and is_macosx"> | 38 // <if expr="_google_chrome and is_macosx"> |
39 /** @private {!PromoteUpdaterStatus} */ | 39 /** @private {!PromoteUpdaterStatus} */ |
40 promoteUpdaterStatus_: Object, | 40 promoteUpdaterStatus_: Object, |
41 </if> | 41 // </if> |
42 | 42 |
43 /** @private {!{obsolete: boolean, endOfLine: boolean}} */ | 43 /** @private {!{obsolete: boolean, endOfLine: boolean}} */ |
44 obsoleteSystemInfo_: { | 44 obsoleteSystemInfo_: { |
45 type: Object, | 45 type: Object, |
46 value: function() { | 46 value: function() { |
47 return { | 47 return { |
48 obsolete: loadTimeData.getBoolean('aboutObsoleteNowOrSoon'), | 48 obsolete: loadTimeData.getBoolean('aboutObsoleteNowOrSoon'), |
49 endOfLine: loadTimeData.getBoolean('aboutObsoleteEndOfTheLine'), | 49 endOfLine: loadTimeData.getBoolean('aboutObsoleteEndOfTheLine'), |
50 }; | 50 }; |
51 }, | 51 }, |
52 }, | 52 }, |
53 | 53 |
54 /** @private */ | 54 /** @private */ |
55 showUpdateStatus_: Boolean, | 55 showUpdateStatus_: Boolean, |
56 | 56 |
57 /** @private */ | 57 /** @private */ |
58 showButtonContainer_: Boolean, | 58 showButtonContainer_: Boolean, |
59 | 59 |
60 /** @private */ | 60 /** @private */ |
61 showRelaunch_: Boolean, | 61 showRelaunch_: Boolean, |
62 | 62 |
63 <if expr="chromeos"> | 63 // <if expr="chromeos"> |
64 /** @private */ | 64 /** @private */ |
65 showRelaunchAndPowerwash_: { | 65 showRelaunchAndPowerwash_: { |
66 type: Boolean, | 66 type: Boolean, |
67 computed: 'computeShowRelaunchAndPowerwash_(' + | 67 computed: 'computeShowRelaunchAndPowerwash_(' + |
68 'currentUpdateStatusEvent_, targetChannel_)', | 68 'currentUpdateStatusEvent_, targetChannel_)', |
69 }, | 69 }, |
70 | 70 |
71 /** @private */ | 71 /** @private */ |
72 showCheckUpdates_: { | 72 showCheckUpdates_: { |
73 type: Boolean, | 73 type: Boolean, |
74 computed: 'computeShowCheckUpdates_(currentUpdateStatusEvent_)', | 74 computed: 'computeShowCheckUpdates_(currentUpdateStatusEvent_)', |
75 }, | 75 }, |
76 </if> | 76 // </if> |
77 }, | 77 }, |
78 | 78 |
79 observers: [ | 79 observers: [ |
80 <if expr="not chromeos"> | 80 // <if expr="not chromeos"> |
81 'updateShowUpdateStatus_(' + | 81 'updateShowUpdateStatus_(' + |
82 'obsoleteSystemInfo_, currentUpdateStatusEvent_)', | 82 'obsoleteSystemInfo_, currentUpdateStatusEvent_)', |
83 'updateShowRelaunch_(currentUpdateStatusEvent_)', | 83 'updateShowRelaunch_(currentUpdateStatusEvent_)', |
84 'updateShowButtonContainer_(showRelaunch_)', | 84 'updateShowButtonContainer_(showRelaunch_)', |
85 </if> | 85 // </if> |
86 | 86 |
87 <if expr="chromeos"> | 87 // <if expr="chromeos"> |
88 'updateShowUpdateStatus_(' + | 88 'updateShowUpdateStatus_(' + |
89 'obsoleteSystemInfo_, currentUpdateStatusEvent_,' + | 89 'obsoleteSystemInfo_, currentUpdateStatusEvent_,' + |
90 'hasCheckedForUpdates_)', | 90 'hasCheckedForUpdates_)', |
91 'updateShowRelaunch_(currentUpdateStatusEvent_, targetChannel_,' + | 91 'updateShowRelaunch_(currentUpdateStatusEvent_, targetChannel_,' + |
92 'currentChannel_)', | 92 'currentChannel_)', |
93 'updateShowButtonContainer_(' + | 93 'updateShowButtonContainer_(' + |
94 'showRelaunch_, showRelaunchAndPowerwash_, showCheckUpdates_)', | 94 'showRelaunch_, showRelaunchAndPowerwash_, showCheckUpdates_)', |
95 </if> | 95 // </if> |
96 ], | 96 ], |
97 | 97 |
98 | 98 |
99 /** @private {?settings.AboutPageBrowserProxy} */ | 99 /** @private {?settings.AboutPageBrowserProxy} */ |
100 aboutBrowserProxy_: null, | 100 aboutBrowserProxy_: null, |
101 | 101 |
102 /** @private {?settings.LifetimeBrowserProxy} */ | 102 /** @private {?settings.LifetimeBrowserProxy} */ |
103 lifetimeBrowserProxy_: null, | 103 lifetimeBrowserProxy_: null, |
104 | 104 |
105 /** @override */ | 105 /** @override */ |
106 attached: function() { | 106 attached: function() { |
107 this.aboutBrowserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 107 this.aboutBrowserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); |
108 this.aboutBrowserProxy_.pageReady(); | 108 this.aboutBrowserProxy_.pageReady(); |
109 | 109 |
110 this.lifetimeBrowserProxy_ = | 110 this.lifetimeBrowserProxy_ = |
111 settings.LifetimeBrowserProxyImpl.getInstance(); | 111 settings.LifetimeBrowserProxyImpl.getInstance(); |
112 | 112 |
113 <if expr="chromeos"> | 113 // <if expr="chromeos"> |
114 this.addEventListener('target-channel-changed', function(e) { | 114 this.addEventListener('target-channel-changed', function(e) { |
115 this.targetChannel_ = e.detail; | 115 this.targetChannel_ = e.detail; |
116 }.bind(this)); | 116 }.bind(this)); |
117 | 117 |
118 this.aboutBrowserProxy_.getChannelInfo().then(function(info) { | 118 this.aboutBrowserProxy_.getChannelInfo().then(function(info) { |
119 this.currentChannel_ = info.currentChannel; | 119 this.currentChannel_ = info.currentChannel; |
120 this.targetChannel_ = info.targetChannel; | 120 this.targetChannel_ = info.targetChannel; |
121 this.startListening_(); | 121 this.startListening_(); |
122 }.bind(this)); | 122 }.bind(this)); |
123 | 123 |
124 this.aboutBrowserProxy_.getRegulatoryInfo().then(function(info) { | 124 this.aboutBrowserProxy_.getRegulatoryInfo().then(function(info) { |
125 this.regulatoryInfo_ = info; | 125 this.regulatoryInfo_ = info; |
126 }.bind(this)); | 126 }.bind(this)); |
127 </if> | 127 // </if> |
128 <if expr="not chromeos"> | 128 // <if expr="not chromeos"> |
129 this.startListening_(); | 129 this.startListening_(); |
130 </if> | 130 // </if> |
131 }, | 131 }, |
132 | 132 |
133 /** @private */ | 133 /** @private */ |
134 startListening_: function() { | 134 startListening_: function() { |
135 this.addWebUIListener( | 135 this.addWebUIListener( |
136 'update-status-changed', | 136 'update-status-changed', |
137 this.onUpdateStatusChanged_.bind(this)); | 137 this.onUpdateStatusChanged_.bind(this)); |
138 <if expr="_google_chrome and is_macosx"> | 138 // <if expr="_google_chrome and is_macosx"> |
139 this.addWebUIListener( | 139 this.addWebUIListener( |
140 'promotion-state-changed', | 140 'promotion-state-changed', |
141 this.onPromoteUpdaterStatusChanged_.bind(this)); | 141 this.onPromoteUpdaterStatusChanged_.bind(this)); |
142 </if> | 142 // </if> |
143 this.aboutBrowserProxy_.refreshUpdateStatus(); | 143 this.aboutBrowserProxy_.refreshUpdateStatus(); |
144 }, | 144 }, |
145 | 145 |
146 /** | 146 /** |
147 * @param {!UpdateStatusChangedEvent} event | 147 * @param {!UpdateStatusChangedEvent} event |
148 * @private | 148 * @private |
149 */ | 149 */ |
150 onUpdateStatusChanged_: function(event) { | 150 onUpdateStatusChanged_: function(event) { |
151 <if expr="chromeos"> | 151 // <if expr="chromeos"> |
152 if (event.status == UpdateStatus.CHECKING) | 152 if (event.status == UpdateStatus.CHECKING) |
153 this.hasCheckedForUpdates_ = true; | 153 this.hasCheckedForUpdates_ = true; |
154 </if> | 154 // </if> |
155 this.currentUpdateStatusEvent_ = event; | 155 this.currentUpdateStatusEvent_ = event; |
156 }, | 156 }, |
157 | 157 |
158 <if expr="_google_chrome and is_macosx"> | 158 // <if expr="_google_chrome and is_macosx"> |
159 /** | 159 /** |
160 * @param {!PromoteUpdaterStatus} status | 160 * @param {!PromoteUpdaterStatus} status |
161 * @private | 161 * @private |
162 */ | 162 */ |
163 onPromoteUpdaterStatusChanged_: function(status) { | 163 onPromoteUpdaterStatusChanged_: function(status) { |
164 this.promoteUpdaterStatus_ = status; | 164 this.promoteUpdaterStatus_ = status; |
165 }, | 165 }, |
166 | 166 |
167 /** | 167 /** |
168 * If #promoteUpdater isn't disabled, trigger update promotion. | 168 * If #promoteUpdater isn't disabled, trigger update promotion. |
169 * @private | 169 * @private |
170 */ | 170 */ |
171 onPromoteUpdaterTap_: function() { | 171 onPromoteUpdaterTap_: function() { |
172 // This is necessary because #promoteUpdater is not a button, so by default | 172 // This is necessary because #promoteUpdater is not a button, so by default |
173 // disable doesn't do anything. | 173 // disable doesn't do anything. |
174 if (this.promoteUpdaterStatus_.disabled) | 174 if (this.promoteUpdaterStatus_.disabled) |
175 return; | 175 return; |
176 this.aboutBrowserProxy_.promoteUpdater(); | 176 this.aboutBrowserProxy_.promoteUpdater(); |
177 }, | 177 }, |
178 | 178 |
179 /** | 179 /** |
180 * @param {!Event} event | 180 * @param {!Event} event |
181 * @private | 181 * @private |
182 */ | 182 */ |
183 onLearnMoreTap_: function(event) { | 183 onLearnMoreTap_: function(event) { |
184 // Stop the propagation of events, so that clicking on links inside | 184 // Stop the propagation of events, so that clicking on links inside |
185 // actionable items won't trigger action. | 185 // actionable items won't trigger action. |
186 event.stopPropagation(); | 186 event.stopPropagation(); |
187 }, | 187 }, |
188 </if> | 188 // </if> |
189 | 189 |
190 /** @private */ | 190 /** @private */ |
191 onHelpTap_: function() { | 191 onHelpTap_: function() { |
192 this.aboutBrowserProxy_.openHelpPage(); | 192 this.aboutBrowserProxy_.openHelpPage(); |
193 }, | 193 }, |
194 | 194 |
195 /** @private */ | 195 /** @private */ |
196 onRelaunchTap_: function() { | 196 onRelaunchTap_: function() { |
197 this.lifetimeBrowserProxy_.relaunch(); | 197 this.lifetimeBrowserProxy_.relaunch(); |
198 }, | 198 }, |
199 | 199 |
200 /** @private */ | 200 /** @private */ |
201 updateShowUpdateStatus_: function() { | 201 updateShowUpdateStatus_: function() { |
202 <if expr="chromeos"> | 202 // <if expr="chromeos"> |
203 // Assume the "updated" status is stale if we haven't checked yet. | 203 // Assume the "updated" status is stale if we haven't checked yet. |
204 if (this.currentUpdateStatusEvent_.status == UpdateStatus.UPDATED && | 204 if (this.currentUpdateStatusEvent_.status == UpdateStatus.UPDATED && |
205 !this.hasCheckedForUpdates_) { | 205 !this.hasCheckedForUpdates_) { |
206 this.showUpdateStatus_ = false; | 206 this.showUpdateStatus_ = false; |
207 return; | 207 return; |
208 } | 208 } |
209 </if> | 209 // </if> |
210 this.showUpdateStatus_ = | 210 this.showUpdateStatus_ = |
211 this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED && | 211 this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED && |
212 !this.obsoleteSystemInfo_.endOfLine; | 212 !this.obsoleteSystemInfo_.endOfLine; |
213 }, | 213 }, |
214 | 214 |
215 /** | 215 /** |
216 * Hide the button container if all buttons are hidden, otherwise the | 216 * Hide the button container if all buttons are hidden, otherwise the |
217 * container displayes an unwanted border (see secondary-action class). | 217 * container displayes an unwanted border (see secondary-action class). |
218 * @private | 218 * @private |
219 */ | 219 */ |
220 updateShowButtonContainer_: function() { | 220 updateShowButtonContainer_: function() { |
221 <if expr="not chromeos"> | 221 // <if expr="not chromeos"> |
222 this.showButtonContainer_ = this.showRelaunch_; | 222 this.showButtonContainer_ = this.showRelaunch_; |
223 </if> | 223 // </if> |
224 <if expr="chromeos"> | 224 // <if expr="chromeos"> |
225 this.showButtonContainer_ = this.showRelaunch_ || | 225 this.showButtonContainer_ = this.showRelaunch_ || |
226 this.showRelaunchAndPowerwash_ || this.showCheckUpdates_; | 226 this.showRelaunchAndPowerwash_ || this.showCheckUpdates_; |
227 </if> | 227 // </if> |
228 }, | 228 }, |
229 | 229 |
230 /** @private */ | 230 /** @private */ |
231 updateShowRelaunch_: function() { | 231 updateShowRelaunch_: function() { |
232 <if expr="not chromeos"> | 232 // <if expr="not chromeos"> |
233 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED); | 233 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED); |
234 </if> | 234 // </if> |
235 <if expr="chromeos"> | 235 // <if expr="chromeos"> |
236 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && | 236 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && |
237 !this.isTargetChannelMoreStable_(); | 237 !this.isTargetChannelMoreStable_(); |
238 </if> | 238 // </if> |
239 }, | 239 }, |
240 | 240 |
241 /** | 241 /** |
242 * @return {string} | 242 * @return {string} |
243 * @private | 243 * @private |
244 */ | 244 */ |
245 getUpdateStatusMessage_: function() { | 245 getUpdateStatusMessage_: function() { |
246 switch (this.currentUpdateStatusEvent_.status) { | 246 switch (this.currentUpdateStatusEvent_.status) { |
247 case UpdateStatus.CHECKING: | 247 case UpdateStatus.CHECKING: |
248 return this.i18n('aboutUpgradeCheckStarted'); | 248 return this.i18n('aboutUpgradeCheckStarted'); |
249 case UpdateStatus.NEARLY_UPDATED: | 249 case UpdateStatus.NEARLY_UPDATED: |
250 <if expr="chromeos"> | 250 // <if expr="chromeos"> |
251 if (this.currentChannel_ != this.targetChannel_) | 251 if (this.currentChannel_ != this.targetChannel_) |
252 return this.i18n('aboutUpgradeSuccessChannelSwitch'); | 252 return this.i18n('aboutUpgradeSuccessChannelSwitch'); |
253 </if> | 253 // </if> |
254 return this.i18n('aboutUpgradeRelaunch'); | 254 return this.i18n('aboutUpgradeRelaunch'); |
255 case UpdateStatus.UPDATED: | 255 case UpdateStatus.UPDATED: |
256 return this.i18n('aboutUpgradeUpToDate'); | 256 return this.i18n('aboutUpgradeUpToDate'); |
257 case UpdateStatus.UPDATING: | 257 case UpdateStatus.UPDATING: |
258 assert(typeof this.currentUpdateStatusEvent_.progress == 'number'); | 258 assert(typeof this.currentUpdateStatusEvent_.progress == 'number'); |
259 var progressPercent = this.currentUpdateStatusEvent_.progress + '%'; | 259 var progressPercent = this.currentUpdateStatusEvent_.progress + '%'; |
260 | 260 |
261 <if expr="chromeos"> | 261 // <if expr="chromeos"> |
262 if (this.currentChannel_ != this.targetChannel_) { | 262 if (this.currentChannel_ != this.targetChannel_) { |
263 return this.i18n('aboutUpgradeUpdatingChannelSwitch', | 263 return this.i18n('aboutUpgradeUpdatingChannelSwitch', |
264 this.i18n(settings.browserChannelToI18nId(this.targetChannel_)), | 264 this.i18n(settings.browserChannelToI18nId(this.targetChannel_)), |
265 progressPercent); | 265 progressPercent); |
266 } | 266 } |
267 </if> | 267 // </if> |
268 if (this.currentUpdateStatusEvent_.progress > 0) { | 268 if (this.currentUpdateStatusEvent_.progress > 0) { |
269 // NOTE(dbeam): some platforms (i.e. Mac) always send 0% while | 269 // NOTE(dbeam): some platforms (i.e. Mac) always send 0% while |
270 // updating (they don't support incremental upgrade progress). Though | 270 // updating (they don't support incremental upgrade progress). Though |
271 // it's certainly quite possible to validly end up here with 0% on | 271 // it's certainly quite possible to validly end up here with 0% on |
272 // platforms that support incremental progress, nobody really likes | 272 // platforms that support incremental progress, nobody really likes |
273 // seeing that they're 0% done with something. | 273 // seeing that they're 0% done with something. |
274 return this.i18n('aboutUpgradeUpdatingPercent', progressPercent); | 274 return this.i18n('aboutUpgradeUpdatingPercent', progressPercent); |
275 } | 275 } |
276 return this.i18n('aboutUpgradeUpdating'); | 276 return this.i18n('aboutUpgradeUpdating'); |
277 default: | 277 default: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 /** | 325 /** |
326 * @param {!UpdateStatus} status | 326 * @param {!UpdateStatus} status |
327 * @return {boolean} | 327 * @return {boolean} |
328 * @private | 328 * @private |
329 */ | 329 */ |
330 checkStatus_: function(status) { | 330 checkStatus_: function(status) { |
331 return this.currentUpdateStatusEvent_.status == status; | 331 return this.currentUpdateStatusEvent_.status == status; |
332 }, | 332 }, |
333 | 333 |
334 <if expr="chromeos"> | 334 // <if expr="chromeos"> |
335 /** | 335 /** |
336 * @return {boolean} | 336 * @return {boolean} |
337 * @private | 337 * @private |
338 */ | 338 */ |
339 isTargetChannelMoreStable_: function() { | 339 isTargetChannelMoreStable_: function() { |
340 assert(this.currentChannel_.length > 0); | 340 assert(this.currentChannel_.length > 0); |
341 assert(this.targetChannel_.length > 0); | 341 assert(this.targetChannel_.length > 0); |
342 return settings.isTargetChannelMoreStable( | 342 return settings.isTargetChannelMoreStable( |
343 this.currentChannel_, this.targetChannel_); | 343 this.currentChannel_, this.targetChannel_); |
344 }, | 344 }, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 this.checkStatus_(UpdateStatus.FAILED); | 377 this.checkStatus_(UpdateStatus.FAILED); |
378 }, | 378 }, |
379 | 379 |
380 /** | 380 /** |
381 * @return {boolean} | 381 * @return {boolean} |
382 * @private | 382 * @private |
383 */ | 383 */ |
384 shouldShowRegulatoryInfo_: function() { | 384 shouldShowRegulatoryInfo_: function() { |
385 return this.regulatoryInfo_ !== null; | 385 return this.regulatoryInfo_ !== null; |
386 }, | 386 }, |
387 </if> | 387 // </if> |
388 | 388 |
389 /** @private */ | 389 /** @private */ |
390 onProductLogoTap_: function() { | 390 onProductLogoTap_: function() { |
391 this.$['product-logo'].animate({ | 391 this.$['product-logo'].animate({ |
392 transform: ['none', 'rotate(-10turn)'], | 392 transform: ['none', 'rotate(-10turn)'], |
393 }, { | 393 }, { |
394 duration: 500, | 394 duration: 500, |
395 easing: 'cubic-bezier(1, 0, 0, 1)', | 395 easing: 'cubic-bezier(1, 0, 0, 1)', |
396 }); | 396 }); |
397 }, | 397 }, |
398 | 398 |
399 <if expr="_google_chrome"> | 399 // <if expr="_google_chrome"> |
400 /** @private */ | 400 /** @private */ |
401 onReportIssueTap_: function() { | 401 onReportIssueTap_: function() { |
402 this.aboutBrowserProxy_.openFeedbackDialog(); | 402 this.aboutBrowserProxy_.openFeedbackDialog(); |
403 }, | 403 }, |
404 </if> | 404 // </if> |
405 }); | 405 }); |
OLD | NEW |