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, RoutableBehavior, I18nBehavior], | 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 | 22 |
23 /** @private {?UpdateStatusChangedEvent} */ | 23 /** @private {?UpdateStatusChangedEvent} */ |
24 currentUpdateStatusEvent_: Object, | 24 currentUpdateStatusEvent_: Object, |
25 | 25 |
26 <if expr="chromeos"> | 26 <if expr="chromeos"> |
27 /** | 27 /** private */ |
tommycli
2016/05/20 22:53:18
nit: @private {boolean} ?
dpapad
2016/05/20 23:25:35
I've been told in other code reviews that the comp
tommycli
2016/05/20 23:32:28
Sounds good. I think you still need to add an "@"
| |
28 * Whether the current and target channel is different. | 28 hasCheckedForUpdates_: Boolean, |
29 * @private | 29 |
30 */ | 30 /** @private {!BrowserChannel} */ |
31 channelsDiffer_: Boolean, | 31 currentChannel_: String, |
32 | 32 |
33 /** @private {!BrowserChannel} */ | 33 /** @private {!BrowserChannel} */ |
34 targetChannel_: String, | 34 targetChannel_: String, |
35 </if> | 35 </if> |
36 }, | 36 }, |
37 | 37 |
38 /** @private {?settings.AboutPageBrowserProxy} */ | 38 /** @private {?settings.AboutPageBrowserProxy} */ |
39 browserProxy_: null, | 39 browserProxy_: null, |
40 | 40 |
41 /** | 41 /** |
42 * @type {string} Selector to get the sections. | 42 * @type {string} Selector to get the sections. |
43 * TODO(michaelpg): replace duplicate docs with @override once b/24294625 | 43 * TODO(michaelpg): replace duplicate docs with @override once b/24294625 |
44 * is fixed. | 44 * is fixed. |
45 */ | 45 */ |
46 sectionSelector: 'settings-section', | 46 sectionSelector: 'settings-section', |
47 | 47 |
48 /** @override */ | 48 /** @override */ |
49 ready: function() { | 49 ready: function() { |
50 this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); | 50 this.browserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); |
51 this.browserProxy_.pageReady(); | 51 this.browserProxy_.pageReady(); |
52 | 52 |
53 <if expr="chromeos"> | 53 <if expr="chromeos"> |
54 Promise.all([ | 54 Promise.all([ |
55 this.browserProxy_.getCurrentChannel(), | 55 this.browserProxy_.getCurrentChannel(), |
56 this.browserProxy_.getTargetChannel(), | 56 this.browserProxy_.getTargetChannel(), |
57 ]).then(function(channels) { | 57 ]).then(function(channels) { |
58 this.currentChannel_ = channels[0]; | |
58 this.targetChannel_ = channels[1]; | 59 this.targetChannel_ = channels[1]; |
59 this.channelsDiffer_ = channels[0] != this.targetChannel_; | 60 |
60 this.startListening_(); | 61 this.startListening_(); |
61 }.bind(this)); | 62 }.bind(this)); |
62 </if> | 63 </if> |
63 <if expr="not chromeos"> | 64 <if expr="not chromeos"> |
64 this.startListening_(); | 65 this.startListening_(); |
65 </if> | 66 </if> |
66 }, | 67 }, |
67 | 68 |
68 /** @private */ | 69 /** @private */ |
69 startListening_: function() { | 70 startListening_: function() { |
70 this.addWebUIListener( | 71 this.addWebUIListener( |
71 'update-status-changed', | 72 'update-status-changed', |
72 /** @param {!UpdateStatusChangedEvent} event */ | 73 this.onUpdateStatusChanged_.bind(this)); |
73 function(event) { | |
74 this.currentUpdateStatusEvent_ = event; | |
75 }.bind(this)); | |
76 this.browserProxy_.refreshUpdateStatus(); | 74 this.browserProxy_.refreshUpdateStatus(); |
77 }, | 75 }, |
78 | 76 |
79 /** @override */ | 77 /** |
78 * @param {!UpdateStatusChangedEvent} event | |
79 * @private | |
80 */ | |
81 onUpdateStatusChanged_: function(event) { | |
82 <if expr="chromeos"> | |
83 if (event.status == UpdateStatus.CHECKING) | |
84 this.hasCheckedForUpdates_ = true; | |
85 </if> | |
86 this.currentUpdateStatusEvent_ = event; | |
87 }, | |
88 | |
89 /** @override */ | |
80 attached: function() { | 90 attached: function() { |
81 this.scroller = this.parentElement; | 91 this.scroller = this.parentElement; |
82 }, | 92 }, |
83 | 93 |
84 /** @private */ | 94 /** @private */ |
85 onHelpTap_: function() { | 95 onHelpTap_: function() { |
86 this.browserProxy_.openHelpPage(); | 96 this.browserProxy_.openHelpPage(); |
87 }, | 97 }, |
88 | 98 |
99 /** @private */ | |
100 onRelaunchTap_: function() { | |
101 this.browserProxy_.relaunchNow(); | |
102 }, | |
103 | |
89 /** | 104 /** |
90 * @return {boolean} | 105 * @return {boolean} |
91 * @private | 106 * @private |
92 */ | 107 */ |
93 shouldShowUpdateStatus_: function() { | 108 shouldShowUpdateStatus_: function() { |
94 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED; | 109 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED; |
95 }, | 110 }, |
96 | 111 |
97 /** | 112 /** |
113 * @return {boolean} | |
114 * @private | |
115 */ | |
116 shouldShowRelaunch_: function() { | |
117 var shouldShow = false; | |
tommycli
2016/05/20 22:53:18
nit: eliminate var in favor of direct returns?
dpapad
2016/05/20 23:25:35
Can't avoid the variable here, that was my first v
tommycli
2016/05/20 23:32:28
Ahh... that makes sense. Thanks for the clarificat
| |
118 <if expr="not chromeos"> | |
119 shouldShow = | |
120 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED; | |
121 </if> | |
122 <if expr="chromeos"> | |
123 shouldShow = !this.isTargetChannelMoreStable_() && | |
124 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED; | |
125 </if> | |
126 return shouldShow; | |
127 }, | |
128 | |
129 /** | |
98 * @return {string} | 130 * @return {string} |
99 * @private | 131 * @private |
100 */ | 132 */ |
101 getUpdateStatusMessage_: function() { | 133 getUpdateStatusMessage_: function() { |
102 switch (this.currentUpdateStatusEvent_.status) { | 134 switch (this.currentUpdateStatusEvent_.status) { |
103 case UpdateStatus.CHECKING: | 135 case UpdateStatus.CHECKING: |
104 return this.i18n('aboutUpgradeCheckStarted'); | 136 return this.i18n('aboutUpgradeCheckStarted'); |
105 case UpdateStatus.NEARLY_UPDATED: | 137 case UpdateStatus.NEARLY_UPDATED: |
106 <if expr="chromeos"> | 138 <if expr="chromeos"> |
107 if (this.channelsDiffer_) | 139 if (this.currentChannel_ != this.targetChannel_) |
108 return this.i18n('aboutUpgradeSuccessChannelSwitch'); | 140 return this.i18n('aboutUpgradeSuccessChannelSwitch'); |
109 </if> | 141 </if> |
110 return this.i18n('aboutUpgradeRelaunch'); | 142 return this.i18n('aboutUpgradeRelaunch'); |
111 case UpdateStatus.UPDATED: | 143 case UpdateStatus.UPDATED: |
112 return this.i18n('aboutUpgradeUpToDate'); | 144 return this.i18n('aboutUpgradeUpToDate'); |
113 case UpdateStatus.UPDATING: | 145 case UpdateStatus.UPDATING: |
114 <if expr="chromeos"> | 146 <if expr="chromeos"> |
115 if (this.channelsDiffer_) { | 147 if (this.currentChannel_ != this.targetChannel_) { |
116 return this.i18n('aboutUpgradeUpdatingChannelSwitch', | 148 return this.i18n('aboutUpgradeUpdatingChannelSwitch', |
117 this.i18n(settings.browserChannelToI18nId(this.targetChannel_))); | 149 this.i18n(settings.browserChannelToI18nId(this.targetChannel_))); |
118 } | 150 } |
119 </if> | 151 </if> |
120 return this.i18n('aboutUpgradeUpdating'); | 152 return this.i18n('aboutUpgradeUpdating'); |
121 default: | 153 default: |
122 return this.currentUpdateStatusEvent_.message; | 154 return this.currentUpdateStatusEvent_.message || ''; |
tommycli
2016/05/20 22:53:18
Looking at the C++ handler, is it possible for the
dpapad
2016/05/20 23:25:35
The C++ is actually passing an empty string whenev
| |
123 } | 155 } |
124 }, | 156 }, |
125 | 157 |
126 /** | 158 /** |
127 * @return {?string} | 159 * @return {?string} |
128 * @private | 160 * @private |
129 */ | 161 */ |
130 getIcon_: function() { | 162 getIcon_: function() { |
131 switch (this.currentUpdateStatusEvent_.status) { | 163 switch (this.currentUpdateStatusEvent_.status) { |
132 case UpdateStatus.DISABLED_BY_ADMIN: | 164 case UpdateStatus.DISABLED_BY_ADMIN: |
(...skipping 16 matching lines...) Expand all Loading... | |
149 switch (this.currentUpdateStatusEvent_.status) { | 181 switch (this.currentUpdateStatusEvent_.status) { |
150 case UpdateStatus.CHECKING: | 182 case UpdateStatus.CHECKING: |
151 case UpdateStatus.UPDATING: | 183 case UpdateStatus.UPDATING: |
152 return 'chrome://resources/images/throbber_small.svg'; | 184 return 'chrome://resources/images/throbber_small.svg'; |
153 default: | 185 default: |
154 return null; | 186 return null; |
155 } | 187 } |
156 }, | 188 }, |
157 | 189 |
158 <if expr="chromeos"> | 190 <if expr="chromeos"> |
191 /** | |
192 * @return {boolean} | |
193 * @private | |
194 */ | |
195 isTargetChannelMoreStable_: function() { | |
tommycli
2016/05/20 22:53:18
should this have some asserts at the top that the
dpapad
2016/05/20 23:25:35
Done.
| |
196 // List of channels in increasing stability order. | |
197 var channelList = [ | |
198 BrowserChannel.DEV, | |
199 BrowserChannel.BETA, | |
200 BrowserChannel.STABLE, | |
201 ]; | |
202 var currentIndex = channelList.indexOf(this.currentChannel_); | |
203 var targetIndex = channelList.indexOf(this.targetChannel_); | |
204 return currentIndex < targetIndex; | |
205 }, | |
206 | |
159 /** @private */ | 207 /** @private */ |
160 onDetailedBuildInfoTap_: function() { | 208 onDetailedBuildInfoTap_: function() { |
161 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( | 209 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( |
162 this.$.pages); | 210 this.$.pages); |
163 animatedPages.setSubpageChain(['detailed-build-info']); | 211 animatedPages.setSubpageChain(['detailed-build-info']); |
164 }, | 212 }, |
213 | |
214 /** @private */ | |
215 onRelaunchAndPowerwashTap_: function() { | |
216 // TODO(dpapad): Implement this. | |
217 }, | |
218 | |
219 /** | |
220 * @return {boolean} | |
221 * @private | |
222 */ | |
223 shouldShowRelaunchAndPowerwash_: function() { | |
224 return this.isTargetChannelMoreStable_() && | |
225 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED; | |
226 }, | |
227 | |
228 /** @private */ | |
229 onCheckUpdatesTap_: function() { | |
230 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING}); | |
231 this.browserProxy_.requestUpdate(); | |
232 }, | |
233 | |
234 /** | |
235 * @return {boolean} | |
236 * @private | |
237 */ | |
238 shouldShowCheckUpdates_: function() { | |
239 return !this.hasCheckedForUpdates_ || | |
240 this.currentUpdateStatusEvent_.status == UpdateStatus.FAILED; | |
241 }, | |
165 </if> | 242 </if> |
166 | 243 |
167 <if expr="_google_chrome"> | 244 <if expr="_google_chrome"> |
168 /** @private */ | 245 /** @private */ |
169 onReportIssueTap_: function() { | 246 onReportIssueTap_: function() { |
170 this.browserProxy_.openFeedbackDialog(); | 247 this.browserProxy_.openFeedbackDialog(); |
171 }, | 248 }, |
172 </if> | 249 </if> |
173 }); | 250 }); |
OLD | NEW |