Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: chrome/browser/resources/settings/about_page/about_page.js

Issue 2538283002: MD Settings: Fix "Check for updates" button regression. (Closed)
Patch Set: Nit. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'updateShowRelaunch_(currentUpdateStatusEvent_)',
79 'updateShowButtonContainer_(showRelaunch_)',
80 </if>
81
82 <if expr="chromeos">
83 'updateShowUpdateStatus_(' +
84 'obsoleteSystemInfo_, currentUpdateStatusEvent_,' +
85 'hasCheckedForUpdates_)',
86 'updateShowRelaunch_(currentUpdateStatusEvent_, targetChannel_)',
87 'updateShowButtonContainer_(' +
88 'showRelaunch_, showRelaunchAndPowerwash_, showCheckUpdates_)',
89 </if>
90 ],
91
92
47 /** @private {?settings.AboutPageBrowserProxy} */ 93 /** @private {?settings.AboutPageBrowserProxy} */
48 aboutBrowserProxy_: null, 94 aboutBrowserProxy_: null,
49 95
50 /** @private {?settings.LifetimeBrowserProxy} */ 96 /** @private {?settings.LifetimeBrowserProxy} */
51 lifetimeBrowserProxy_: null, 97 lifetimeBrowserProxy_: null,
52 98
53 /** @override */ 99 /** @override */
54 attached: function() { 100 attached: function() {
55 this.aboutBrowserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance(); 101 this.aboutBrowserProxy_ = settings.AboutPageBrowserProxyImpl.getInstance();
56 this.aboutBrowserProxy_.pageReady(); 102 this.aboutBrowserProxy_.pageReady();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /** @private */ 151 /** @private */
106 onHelpTap_: function() { 152 onHelpTap_: function() {
107 this.aboutBrowserProxy_.openHelpPage(); 153 this.aboutBrowserProxy_.openHelpPage();
108 }, 154 },
109 155
110 /** @private */ 156 /** @private */
111 onRelaunchTap_: function() { 157 onRelaunchTap_: function() {
112 this.lifetimeBrowserProxy_.relaunch(); 158 this.lifetimeBrowserProxy_.relaunch();
113 }, 159 },
114 160
115 /** 161 /** @private */
116 * @return {boolean} 162 updateShowUpdateStatus_: function() {
117 * @private 163 <if expr="chromeos">
118 */ 164 // Assume the "updated" status is stale if we haven't checked yet.
119 shouldShowUpdateStatusMessage_: function() { 165 if (this.currentUpdateStatusEvent_.status == UpdateStatus.UPDATED &&
120 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED && 166 !this.hasCheckedForUpdates_) {
167 this.showUpdateStatus_ = false;
168 return;
169 }
170 </if>
171 this.showUpdateStatus_ =
172 this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED &&
121 !this.obsoleteSystemInfo_.endOfLine; 173 !this.obsoleteSystemInfo_.endOfLine;
122 }, 174 },
123 175
124 /** 176 /**
125 * @return {boolean} 177 * Hide the button container if all buttons are hidden, otherwise the
178 * container displayes an unwanted border (see secondary-action class).
126 * @private 179 * @private
127 */ 180 */
128 shouldShowUpdateStatusIcon_: function() { 181 updateShowButtonContainer_: function() {
129 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED || 182 <if expr="not chromeos">
130 this.obsoleteSystemInfo_.endOfLine; 183 this.showButtonContainer_ = this.showRelaunch_;
184 </if>
185 <if expr="chromeos">
186 this.showButtonContainer_ = this.showRelaunch_ ||
187 this.showRelaunchAndPowerwash_ || this.showCheckUpdates_;
188 </if>
189 },
190
191 /** @private */
192 updateShowRelaunch_: function() {
193 <if expr="not chromeos">
194 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED);
195 </if>
196 <if expr="chromeos">
197 this.showRelaunch_ = this.checkStatus_(UpdateStatus.NEARLY_UPDATED) &&
198 !this.isTargetChannelMoreStable_();
199 </if>
131 }, 200 },
132 201
133 /** 202 /**
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} 203 * @return {string}
151 * @private 204 * @private
152 */ 205 */
153 getUpdateStatusMessage_: function() { 206 getUpdateStatusMessage_: function() {
154 switch (this.currentUpdateStatusEvent_.status) { 207 switch (this.currentUpdateStatusEvent_.status) {
155 case UpdateStatus.CHECKING: 208 case UpdateStatus.CHECKING:
156 return this.i18n('aboutUpgradeCheckStarted'); 209 return this.i18n('aboutUpgradeCheckStarted');
157 case UpdateStatus.NEARLY_UPDATED: 210 case UpdateStatus.NEARLY_UPDATED:
158 <if expr="chromeos"> 211 <if expr="chromeos">
159 if (this.currentChannel_ != this.targetChannel_) 212 if (this.currentChannel_ != this.targetChannel_)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 311
259 /** @private */ 312 /** @private */
260 onRelaunchAndPowerwashTap_: function() { 313 onRelaunchAndPowerwashTap_: function() {
261 this.lifetimeBrowserProxy_.factoryReset(); 314 this.lifetimeBrowserProxy_.factoryReset();
262 }, 315 },
263 316
264 /** 317 /**
265 * @return {boolean} 318 * @return {boolean}
266 * @private 319 * @private
267 */ 320 */
268 shouldShowRelaunchAndPowerwash_: function() { 321 computeShowRelaunchAndPowerwash_: function() {
269 return this.checkStatus_(UpdateStatus.NEARLY_UPDATED) && 322 return this.checkStatus_(UpdateStatus.NEARLY_UPDATED) &&
270 this.isTargetChannelMoreStable_(); 323 this.isTargetChannelMoreStable_();
271 }, 324 },
272 325
273 /** @private */ 326 /** @private */
274 onCheckUpdatesTap_: function() { 327 onCheckUpdatesTap_: function() {
275 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING}); 328 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING});
276 this.aboutBrowserProxy_.requestUpdate(); 329 this.aboutBrowserProxy_.requestUpdate();
277 }, 330 },
278 331
279 /** 332 /**
280 * @return {boolean} 333 * @return {boolean}
281 * @private 334 * @private
282 */ 335 */
283 shouldShowCheckUpdates_: function() { 336 computeShowCheckUpdates_: function() {
284 return !this.hasCheckedForUpdates_ || 337 return !this.hasCheckedForUpdates_ ||
285 this.checkStatus_(UpdateStatus.FAILED); 338 this.checkStatus_(UpdateStatus.FAILED);
286 }, 339 },
287 340
288 /** 341 /**
289 * @return {boolean} 342 * @return {boolean}
290 * @private 343 * @private
291 */ 344 */
292 shouldShowRegulatoryInfo_: function() { 345 shouldShowRegulatoryInfo_: function() {
293 return this.regulatoryInfo_ !== null; 346 return this.regulatoryInfo_ !== null;
(...skipping 10 matching lines...) Expand all
304 }); 357 });
305 }, 358 },
306 359
307 <if expr="_google_chrome"> 360 <if expr="_google_chrome">
308 /** @private */ 361 /** @private */
309 onReportIssueTap_: function() { 362 onReportIssueTap_: function() {
310 this.aboutBrowserProxy_.openFeedbackDialog(); 363 this.aboutBrowserProxy_.openFeedbackDialog();
311 }, 364 },
312 </if> 365 </if>
313 }); 366 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/about_page/about_page.html ('k') | chrome/test/data/webui/settings/about_page_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698