| 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: [RoutableBehavior], | 12 behaviors: [WebUIListenerBehavior, RoutableBehavior, I18nBehavior], |
| 13 | 13 |
| 14 properties: { | 14 properties: { |
| 15 /** | 15 /** |
| 16 * The current active route. | 16 * The current active route. |
| 17 */ | 17 */ |
| 18 currentRoute: { | 18 currentRoute: { |
| 19 type: Object, | 19 type: Object, |
| 20 notify: true, | 20 notify: true, |
| 21 }, | 21 }, |
| 22 |
| 23 /** @private {?UpdateStatusChangedEvent} */ |
| 24 currentUpdateStatusEvent_: Object, |
| 25 |
| 26 <if expr="chromeos"> |
| 27 /** |
| 28 * Whether the current and target channel is different. |
| 29 * @private |
| 30 */ |
| 31 channelsDiffer_: Boolean, |
| 32 |
| 33 /** @private {!BrowserChannel} */ |
| 34 targetChannel_: String, |
| 35 </if> |
| 22 }, | 36 }, |
| 23 | 37 |
| 24 /** @private {?settings.AboutPageBrowserProxy} */ | 38 /** @private {?settings.AboutPageBrowserProxy} */ |
| 25 browserProxy_: null, | 39 browserProxy_: null, |
| 26 | 40 |
| 27 /** | 41 /** |
| 28 * @type {string} Selector to get the sections. | 42 * @type {string} Selector to get the sections. |
| 29 * TODO(michaelpg): replace duplicate docs with @override once b/24294625 | 43 * TODO(michaelpg): replace duplicate docs with @override once b/24294625 |
| 30 * is fixed. | 44 * is fixed. |
| 31 */ | 45 */ |
| 32 sectionSelector: 'settings-section', | 46 sectionSelector: 'settings-section', |
| 33 | 47 |
| 34 /** @override */ | 48 /** @override */ |
| 35 ready: function() { | 49 ready: function() { |
| 36 this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 50 this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); |
| 51 this.browserProxy_.pageReady(); |
| 52 |
| 53 <if expr="chromeos"> |
| 54 Promise.all([ |
| 55 this.browserProxy_.getCurrentChannel(), |
| 56 this.browserProxy_.getTargetChannel(), |
| 57 ]).then(function(channels) { |
| 58 this.targetChannel_ = channels[1]; |
| 59 this.channelsDiffer_ = channels[0] != this.targetChannel_; |
| 60 this.startListening_(); |
| 61 }.bind(this)); |
| 62 </if> |
| 63 <if expr="not chromeos"> |
| 64 this.startListening_(); |
| 65 </if> |
| 66 }, |
| 67 |
| 68 /** @private */ |
| 69 startListening_: function() { |
| 70 this.addWebUIListener( |
| 71 'update-status-changed', |
| 72 /** @param {!UpdateStatusChangedEvent} event */ |
| 73 function(event) { |
| 74 this.currentUpdateStatusEvent_ = event; |
| 75 }.bind(this)); |
| 76 this.browserProxy_.refreshUpdateStatus(); |
| 37 }, | 77 }, |
| 38 | 78 |
| 39 /** @override */ | 79 /** @override */ |
| 40 attached: function() { | 80 attached: function() { |
| 41 this.scroller = this.parentElement; | 81 this.scroller = this.parentElement; |
| 42 }, | 82 }, |
| 43 | 83 |
| 44 /** @private */ | 84 /** @private */ |
| 45 onHelpTap_: function() { | 85 onHelpTap_: function() { |
| 46 this.browserProxy_.openHelpPage(); | 86 this.browserProxy_.openHelpPage(); |
| 47 }, | 87 }, |
| 48 | 88 |
| 89 /** |
| 90 * @return {boolean} |
| 91 * @private |
| 92 */ |
| 93 shouldShowUpdateStatus_: function() { |
| 94 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED; |
| 95 }, |
| 96 |
| 97 /** |
| 98 * @return {string} |
| 99 * @private |
| 100 */ |
| 101 getUpdateStatusMessage_: function() { |
| 102 switch (this.currentUpdateStatusEvent_.status) { |
| 103 case UpdateStatus.CHECKING: |
| 104 return this.i18n('aboutUpgradeCheckStarted'); |
| 105 case UpdateStatus.NEARLY_UPDATED: |
| 106 <if expr="chromeos"> |
| 107 if (this.channelsDiffer_) |
| 108 return this.i18n('aboutUpgradeSuccessChannelSwitch'); |
| 109 </if> |
| 110 return this.i18n('aboutUpgradeRelaunch'); |
| 111 case UpdateStatus.UPDATED: |
| 112 return this.i18n('aboutUpgradeUpToDate'); |
| 113 case UpdateStatus.UPDATING: |
| 114 <if expr="chromeos"> |
| 115 if (this.channelsDiffer_) { |
| 116 return this.i18n('aboutUpgradeUpdatingChannelSwitch', |
| 117 this.i18n(settings.browserChannelToI18nId(this.targetChannel_))); |
| 118 } |
| 119 </if> |
| 120 return this.i18n('aboutUpgradeUpdating'); |
| 121 default: |
| 122 return this.currentUpdateStatusEvent_.message; |
| 123 } |
| 124 }, |
| 125 |
| 126 /** |
| 127 * @return {?string} |
| 128 * @private |
| 129 */ |
| 130 getIcon_: function() { |
| 131 switch (this.currentUpdateStatusEvent_.status) { |
| 132 case UpdateStatus.DISABLED_BY_ADMIN: |
| 133 return 'cr:domain'; |
| 134 case UpdateStatus.FAILED: |
| 135 return 'settings:error'; |
| 136 case UpdateStatus.UPDATED: |
| 137 case UpdateStatus.NEARLY_UPDATED: |
| 138 return 'settings:check-circle'; |
| 139 default: |
| 140 return null; |
| 141 } |
| 142 }, |
| 143 |
| 144 /** |
| 145 * @return {?string} |
| 146 * @private |
| 147 */ |
| 148 getIconSrc_: function() { |
| 149 switch (this.currentUpdateStatusEvent_.status) { |
| 150 case UpdateStatus.CHECKING: |
| 151 case UpdateStatus.UPDATING: |
| 152 return 'chrome://resources/images/throbber_small.svg'; |
| 153 default: |
| 154 return null; |
| 155 } |
| 156 }, |
| 157 |
| 49 <if expr="chromeos"> | 158 <if expr="chromeos"> |
| 50 /** @private */ | 159 /** @private */ |
| 51 onDetailedBuildInfoTap_: function() { | 160 onDetailedBuildInfoTap_: function() { |
| 52 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( | 161 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( |
| 53 this.$.pages); | 162 this.$.pages); |
| 54 animatedPages.setSubpageChain(['detailed-build-info']); | 163 animatedPages.setSubpageChain(['detailed-build-info']); |
| 55 }, | 164 }, |
| 56 </if> | 165 </if> |
| 57 | 166 |
| 58 <if expr="_google_chrome"> | 167 <if expr="_google_chrome"> |
| 59 /** @private */ | 168 /** @private */ |
| 60 onReportIssueTap_: function() { | 169 onReportIssueTap_: function() { |
| 61 this.browserProxy_.openFeedbackDialog(); | 170 this.browserProxy_.openFeedbackDialog(); |
| 62 }, | 171 }, |
| 63 </if> | 172 </if> |
| 64 }); | 173 }); |
| OLD | NEW |