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: [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: | |
|
tommycli
2016/05/20 00:30:45
optional nit: can we just do something like:
<if
dpapad
2016/05/20 00:51:34
Done.
| |
| 106 var messageId = 'aboutUpgradeRelaunch'; | |
| 107 <if expr="chromeos"> | |
| 108 if (this.channelsDiffer_) | |
| 109 messageId = 'aboutUpgradeSuccessChannelSwitch'; | |
| 110 </if> | |
| 111 return this.i18n(messageId); | |
| 112 case UpdateStatus.UPDATED: | |
| 113 return this.i18n('aboutUpgradeUpToDate'); | |
| 114 case UpdateStatus.UPDATING: | |
|
tommycli
2016/05/20 00:30:45
optional nit: and same in this case, i think we ca
dpapad
2016/05/20 00:51:34
Done.
| |
| 115 var messageId = 'aboutUpgradeUpdating'; | |
| 116 var channelDisplayName = null; | |
| 117 <if expr="chromeos"> | |
| 118 if (this.channelsDiffer_) { | |
| 119 messageId = 'aboutUpgradeUpdatingChannelSwitch'; | |
| 120 channelDisplayName = this.i18n( | |
| 121 settings.browserChannelToI18nId(this.targetChannel_)); | |
| 122 } | |
| 123 </if> | |
| 124 return this.i18n(messageId, channelDisplayName || undefined); | |
| 125 default: | |
| 126 return this.currentUpdateStatusEvent_.message; | |
| 127 } | |
| 128 }, | |
| 129 | |
| 130 /** | |
| 131 * @return {string} | |
| 132 * @private | |
| 133 */ | |
| 134 getIconCssClass_: function() { | |
| 135 switch (this.currentUpdateStatusEvent_.status) { | |
| 136 case UpdateStatus.FAILED: | |
| 137 return 'error-icon'; | |
| 138 case UpdateStatus.UPDATED: | |
| 139 case UpdateStatus.NEARLY_UPDATED: | |
| 140 return 'check-icon'; | |
| 141 default: | |
| 142 return ''; | |
| 143 } | |
| 144 }, | |
| 145 | |
| 146 /** | |
| 147 * @return {?string} | |
| 148 * @private | |
| 149 */ | |
| 150 getIcon_: function() { | |
| 151 switch (this.currentUpdateStatusEvent_.status) { | |
| 152 case UpdateStatus.DISABLED_BY_ADMIN: | |
| 153 return 'cr:domain'; | |
| 154 case UpdateStatus.FAILED: | |
| 155 return 'settings:error'; | |
| 156 case UpdateStatus.UPDATED: | |
| 157 case UpdateStatus.NEARLY_UPDATED: | |
| 158 return 'settings:check-circle'; | |
| 159 default: | |
| 160 return null; | |
| 161 } | |
| 162 }, | |
| 163 | |
| 164 /** | |
| 165 * @return {?string} | |
| 166 * @private | |
| 167 */ | |
| 168 getIconSrc_: function() { | |
| 169 switch (this.currentUpdateStatusEvent_.status) { | |
| 170 case UpdateStatus.CHECKING: | |
| 171 case UpdateStatus.UPDATING: | |
| 172 return 'chrome://resources/images/throbber_small.svg'; | |
| 173 default: | |
| 174 return null; | |
| 175 } | |
| 176 }, | |
| 177 | |
| 49 <if expr="chromeos"> | 178 <if expr="chromeos"> |
| 50 /** @private */ | 179 /** @private */ |
| 51 onDetailedBuildInfoTap_: function() { | 180 onDetailedBuildInfoTap_: function() { |
| 52 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( | 181 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( |
| 53 this.$.pages); | 182 this.$.pages); |
| 54 animatedPages.setSubpageChain(['detailed-build-info']); | 183 animatedPages.setSubpageChain(['detailed-build-info']); |
| 55 }, | 184 }, |
| 56 </if> | 185 </if> |
| 57 | 186 |
| 58 <if expr="_google_chrome"> | 187 <if expr="_google_chrome"> |
| 59 /** @private */ | 188 /** @private */ |
| 60 onReportIssueTap_: function() { | 189 onReportIssueTap_: function() { |
| 61 this.browserProxy_.openFeedbackDialog(); | 190 this.browserProxy_.openFeedbackDialog(); |
| 62 }, | 191 }, |
| 63 </if> | 192 </if> |
| 64 }); | 193 }); |
| OLD | NEW |