Chromium Code Reviews| 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_: Boolean, | 23 hasCheckedForUpdates_: { |
| 24 type: Boolean, | |
| 25 value: false, | |
| 26 }, | |
| 24 | 27 |
| 25 /** @private {!BrowserChannel} */ | 28 /** @private {!BrowserChannel} */ |
| 26 currentChannel_: String, | 29 currentChannel_: String, |
| 27 | 30 |
| 28 /** @private {!BrowserChannel} */ | 31 /** @private {!BrowserChannel} */ |
| 29 targetChannel_: String, | 32 targetChannel_: String, |
| 30 | 33 |
| 31 /** @private {?RegulatoryInfo} */ | 34 /** @private {?RegulatoryInfo} */ |
| 32 regulatoryInfo_: Object, | 35 regulatoryInfo_: Object, |
| 33 </if> | 36 </if> |
| 34 | 37 |
| 35 /** @private {!{obsolete: boolean, endOfLine: boolean}} */ | 38 /** @private {!{obsolete: boolean, endOfLine: boolean}} */ |
| 36 obsoleteSystemInfo_: { | 39 obsoleteSystemInfo_: { |
| 37 type: Object, | 40 type: Object, |
| 38 value: function() { | 41 value: function() { |
| 39 return { | 42 return { |
| 40 obsolete: loadTimeData.getBoolean('aboutObsoleteNowOrSoon'), | 43 obsolete: loadTimeData.getBoolean('aboutObsoleteNowOrSoon'), |
| 41 endOfLine: loadTimeData.getBoolean('aboutObsoleteEndOfTheLine'), | 44 endOfLine: loadTimeData.getBoolean('aboutObsoleteEndOfTheLine'), |
| 42 }; | 45 }; |
| 43 }, | 46 }, |
| 44 }, | 47 }, |
| 48 | |
| 49 /** @private */ | |
| 50 showUpdateStatus_: Boolean, | |
| 51 | |
| 52 /** @private */ | |
| 53 showButtonContainer_: Boolean, | |
| 54 | |
| 55 /** @private */ | |
| 56 showRelaunch_: Boolean, | |
| 57 | |
| 58 <if expr="chromeos"> | |
| 59 /** @private */ | |
| 60 showRelaunchAndPowerwash_: { | |
| 61 type: Boolean, | |
| 62 computed: 'computeShowRelaunchAndPowerwash_(' + | |
| 63 'currentUpdateStatusEvent_, targetChannel_)', | |
| 64 }, | |
| 65 | |
| 66 /** @private */ | |
| 67 showCheckUpdates_: { | |
| 68 type: Boolean, | |
| 69 computed: 'computeShowCheckUpdates_(currentUpdateStatusEvent_)', | |
| 70 }, | |
| 71 </if> | |
| 45 }, | 72 }, |
| 46 | 73 |
| 74 observers: [ | |
| 75 <if expr="not chromeos"> | |
| 76 'updateShowUpdateStatus_(' + | |
| 77 'obsoleteSystemInfo_, currentUpdateStatusEvent_)', | |
| 78 </if> | |
| 79 <if expr="chromeos"> | |
| 80 'updateShowUpdateStatus_(' + | |
| 81 'obsoleteSystemInfo_, currentUpdateStatusEvent_,' + | |
| 82 'hasCheckedForUpdates_)', | |
| 83 </if> | |
| 84 | |
| 85 <if expr="not chromeos"> | |
| 86 'updateShowRelaunch_(currentUpdateStatusEvent_)', | |
| 87 </if> | |
| 88 <if expr="chromeos"> | |
| 89 'updateShowRelaunch_(currentUpdateStatusEvent_, targetChannel_)', | |
| 90 </if> | |
| 91 | |
| 92 <if expr="not chromeos"> | |
| 93 'updateShowButtonContainer_(showRelaunch_)', | |
| 94 </if> | |
| 95 <if expr="chromeos"> | |
| 96 'updateShowButtonContainer_(' + | |
| 97 'showRelaunch_, showRelaunchAndPowerwash_,showCheckUpdates_)', | |
| 98 </if> | |
|
Dan Beam
2016/12/06 02:03:18
can put each observer into a single if here? i.e.
dpapad
2016/12/06 17:00:40
Done.
| |
| 99 ], | |
| 100 | |
| 101 | |
| 47 /** @private {?settings.AboutPageBrowserProxy} */ | 102 /** @private {?settings.AboutPageBrowserProxy} */ |
| 48 aboutBrowserProxy_: null, | 103 aboutBrowserProxy_: null, |
| 49 | 104 |
| 50 /** @private {?settings.LifetimeBrowserProxy} */ | 105 /** @private {?settings.LifetimeBrowserProxy} */ |
| 51 lifetimeBrowserProxy_: null, | 106 lifetimeBrowserProxy_: null, |
| 52 | 107 |
| 53 /** @override */ | 108 /** @override */ |
| 54 attached: function() { | 109 attached: function() { |
| 55 this.aboutBrowserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 110 this.aboutBrowserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); |
| 56 this.aboutBrowserProxy_.pageReady(); | 111 this.aboutBrowserProxy_.pageReady(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 /** @private */ | 160 /** @private */ |
| 106 onHelpTap_: function() { | 161 onHelpTap_: function() { |
| 107 this.aboutBrowserProxy_.openHelpPage(); | 162 this.aboutBrowserProxy_.openHelpPage(); |
| 108 }, | 163 }, |
| 109 | 164 |
| 110 /** @private */ | 165 /** @private */ |
| 111 onRelaunchTap_: function() { | 166 onRelaunchTap_: function() { |
| 112 this.lifetimeBrowserProxy_.relaunch(); | 167 this.lifetimeBrowserProxy_.relaunch(); |
| 113 }, | 168 }, |
| 114 | 169 |
| 115 /** | 170 /** @private */ |
| 116 * @return {boolean} | 171 updateShowUpdateStatus_: function() { |
| 117 * @private | 172 <if expr="chromeos"> |
| 118 */ | 173 // Assume the "updated" status is stale if we haven't checked yet. |
| 119 shouldShowUpdateStatusMessage_: function() { | 174 if (this.currentUpdateStatusEvent_.status == UpdateStatus.UPDATED && |
| 120 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED && | 175 !this.hasCheckedForUpdates_) { |
| 176 this.showUpdateStatus_ = false; | |
| 177 return; | |
| 178 } | |
| 179 </if> | |
| 180 this.showUpdateStatus_ = | |
| 181 this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED && | |
| 121 !this.obsoleteSystemInfo_.endOfLine; | 182 !this.obsoleteSystemInfo_.endOfLine; |
| 122 }, | 183 }, |
| 123 | 184 |
| 124 /** | 185 /** |
| 125 * @return {boolean} | 186 * Hide the button container if all buttons are hidden, otherwise the |
| 187 * container displayes an unwanted border (see secondary-action class). | |
| 126 * @private | 188 * @private |
| 127 */ | 189 */ |
| 128 shouldShowUpdateStatusIcon_: function() { | 190 updateShowButtonContainer_: function() { |
| 129 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED || | 191 this.showButtonContainer_ = this.showRelaunch_; |
| 130 this.obsoleteSystemInfo_.endOfLine; | 192 <if expr="chromeos"> |
| 193 this.showButtonContainer_ = this.showButtonContainer_ || | |
| 194 this.showRelaunchAndPowerwash_ || this.showCheckUpdates_; | |
|
Dan Beam
2016/12/06 02:03:18
can you avoid setting this twice for the sake of o
dpapad
2016/12/06 17:00:40
Done (avoided setting it twice) , but in a simpler
| |
| 195 </if> | |
| 196 }, | |
| 197 | |
| 198 /** @private */ | |
| 199 updateShowRelaunch_: function() { | |
| 200 <if expr="not chromeos"> | |
| 201 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED); | |
| 202 </if> | |
| 203 <if expr="chromeos"> | |
| 204 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && | |
| 205 !this.isTargetChannelMoreStable_(); | |
| 206 </if> | |
|
Dan Beam
2016/12/06 02:03:18
var showRelaunch = this.checkStatus_(UpdateStatus.
dpapad
2016/12/06 17:00:40
Acknowledged. I think that completely separating t
| |
| 131 }, | 207 }, |
| 132 | 208 |
| 133 /** | 209 /** |
| 134 * @return {boolean} | |
| 135 * @private | |
| 136 */ | |
| 137 shouldShowRelaunch_: function() { | |
| 138 var shouldShow = false; | |
| 139 <if expr="not chromeos"> | |
| 140 shouldShow = this.checkStatus_(UpdateStatus.NEARLY_UPDATED); | |
| 141 </if> | |
| 142 <if expr="chromeos"> | |
| 143 shouldShow = this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && | |
| 144 !this.isTargetChannelMoreStable_(); | |
| 145 </if> | |
| 146 return shouldShow; | |
| 147 }, | |
| 148 | |
| 149 /** | |
| 150 * @return {string} | 210 * @return {string} |
| 151 * @private | 211 * @private |
| 152 */ | 212 */ |
| 153 getUpdateStatusMessage_: function() { | 213 getUpdateStatusMessage_: function() { |
| 154 switch (this.currentUpdateStatusEvent_.status) { | 214 switch (this.currentUpdateStatusEvent_.status) { |
| 155 case UpdateStatus.CHECKING: | 215 case UpdateStatus.CHECKING: |
| 156 return this.i18n('aboutUpgradeCheckStarted'); | 216 return this.i18n('aboutUpgradeCheckStarted'); |
| 157 case UpdateStatus.NEARLY_UPDATED: | 217 case UpdateStatus.NEARLY_UPDATED: |
| 158 <if expr="chromeos"> | 218 <if expr="chromeos"> |
| 159 if (this.currentChannel_ != this.targetChannel_) | 219 if (this.currentChannel_ != this.targetChannel_) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 | 318 |
| 259 /** @private */ | 319 /** @private */ |
| 260 onRelaunchAndPowerwashTap_: function() { | 320 onRelaunchAndPowerwashTap_: function() { |
| 261 this.lifetimeBrowserProxy_.factoryReset(); | 321 this.lifetimeBrowserProxy_.factoryReset(); |
| 262 }, | 322 }, |
| 263 | 323 |
| 264 /** | 324 /** |
| 265 * @return {boolean} | 325 * @return {boolean} |
| 266 * @private | 326 * @private |
| 267 */ | 327 */ |
| 268 shouldShowRelaunchAndPowerwash_: function() { | 328 computeShowRelaunchAndPowerwash_: function() { |
| 269 return this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && | 329 return this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && |
| 270 this.isTargetChannelMoreStable_(); | 330 this.isTargetChannelMoreStable_(); |
| 271 }, | 331 }, |
| 272 | 332 |
| 273 /** @private */ | 333 /** @private */ |
| 274 onCheckUpdatesTap_: function() { | 334 onCheckUpdatesTap_: function() { |
| 275 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING}); | 335 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING}); |
| 276 this.aboutBrowserProxy_.requestUpdate(); | 336 this.aboutBrowserProxy_.requestUpdate(); |
| 277 }, | 337 }, |
| 278 | 338 |
| 279 /** | 339 /** |
| 280 * @return {boolean} | 340 * @return {boolean} |
| 281 * @private | 341 * @private |
| 282 */ | 342 */ |
| 283 shouldShowCheckUpdates_: function() { | 343 computeShowCheckUpdates_: function() { |
| 284 return !this.hasCheckedForUpdates_ || | 344 return !this.hasCheckedForUpdates_ || |
| 285 this.checkStatus_(UpdateStatus.FAILED); | 345 this.checkStatus_(UpdateStatus.FAILED); |
| 286 }, | 346 }, |
| 287 | 347 |
| 288 /** | 348 /** |
| 289 * @return {boolean} | 349 * @return {boolean} |
| 290 * @private | 350 * @private |
| 291 */ | 351 */ |
| 292 shouldShowRegulatoryInfo_: function() { | 352 shouldShowRegulatoryInfo_: function() { |
| 293 return this.regulatoryInfo_ !== null; | 353 return this.regulatoryInfo_ !== null; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 304 }); | 364 }); |
| 305 }, | 365 }, |
| 306 | 366 |
| 307 <if expr="_google_chrome"> | 367 <if expr="_google_chrome"> |
| 308 /** @private */ | 368 /** @private */ |
| 309 onReportIssueTap_: function() { | 369 onReportIssueTap_: function() { |
| 310 this.aboutBrowserProxy_.openFeedbackDialog(); | 370 this.aboutBrowserProxy_.openFeedbackDialog(); |
| 311 }, | 371 }, |
| 312 </if> | 372 </if> |
| 313 }); | 373 }); |
| OLD | NEW |