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

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

Issue 1997453006: MD Settings: About page, updating buttons based on current update status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@about_page_main3
Patch Set: @private Created 4 years, 7 months 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, 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 */
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;
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 || '';
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
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() {
196 assert(this.currentChannel_.length > 0);
197 assert(this.targetChannel_.length > 0);
198
199 // List of channels in increasing stability order.
200 var channelList = [
201 BrowserChannel.DEV,
202 BrowserChannel.BETA,
203 BrowserChannel.STABLE,
204 ];
205 var currentIndex = channelList.indexOf(this.currentChannel_);
206 var targetIndex = channelList.indexOf(this.targetChannel_);
207 return currentIndex < targetIndex;
208 },
209
159 /** @private */ 210 /** @private */
160 onDetailedBuildInfoTap_: function() { 211 onDetailedBuildInfoTap_: function() {
161 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( 212 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ (
162 this.$.pages); 213 this.$.pages);
163 animatedPages.setSubpageChain(['detailed-build-info']); 214 animatedPages.setSubpageChain(['detailed-build-info']);
164 }, 215 },
216
217 /** @private */
218 onRelaunchAndPowerwashTap_: function() {
219 // TODO(dpapad): Implement this.
220 },
221
222 /**
223 * @return {boolean}
224 * @private
225 */
226 shouldShowRelaunchAndPowerwash_: function() {
227 return this.isTargetChannelMoreStable_() &&
228 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED;
229 },
230
231 /** @private */
232 onCheckUpdatesTap_: function() {
233 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING});
234 this.browserProxy_.requestUpdate();
235 },
236
237 /**
238 * @return {boolean}
239 * @private
240 */
241 shouldShowCheckUpdates_: function() {
242 return !this.hasCheckedForUpdates_ ||
243 this.currentUpdateStatusEvent_.status == UpdateStatus.FAILED;
244 },
165 </if> 245 </if>
166 246
167 <if expr="_google_chrome"> 247 <if expr="_google_chrome">
168 /** @private */ 248 /** @private */
169 onReportIssueTap_: function() { 249 onReportIssueTap_: function() {
170 this.browserProxy_.openFeedbackDialog(); 250 this.browserProxy_.openFeedbackDialog();
171 }, 251 },
172 </if> 252 </if>
173 }); 253 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698