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

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: Nits. 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();
75 window.setUpdateStatus = this.onUpdateStatusChanged_.bind(this);
tommycli 2016/05/20 22:53:19 Was this a leftover also?
dpapad 2016/05/20 23:25:36 Ah yes. Removed.
77 }, 76 },
78 77
79 /** @override */ 78 /**
79 * @param {!UpdateStatusChangedEvent} event
80 * @private
81 */
82 onUpdateStatusChanged_: function(event) {
83 <if expr="chromeos">
84 if (event.status == UpdateStatus.CHECKING)
85 this.hasCheckedForUpdates_ = true;
86 </if>
87 this.currentUpdateStatusEvent_ = event;
88 },
89
90 /** @override */
80 attached: function() { 91 attached: function() {
81 this.scroller = this.parentElement; 92 this.scroller = this.parentElement;
82 }, 93 },
83 94
84 /** @private */ 95 /** @private */
85 onHelpTap_: function() { 96 onHelpTap_: function() {
86 this.browserProxy_.openHelpPage(); 97 this.browserProxy_.openHelpPage();
87 }, 98 },
88 99
100 /** @private */
101 onRelaunchTap_: function() {
102 this.browserProxy_.relaunchNow();
103 },
104
89 /** 105 /**
90 * @return {boolean} 106 * @return {boolean}
91 * @private 107 * @private
92 */ 108 */
93 shouldShowUpdateStatus_: function() { 109 shouldShowUpdateStatus_: function() {
94 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED; 110 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED;
95 }, 111 },
96 112
97 /** 113 /**
114 * @return {boolean}
115 * @private
116 */
117 shouldShowRelaunch_: function() {
118 var shouldShow = false;
119 <if expr="not chromeos">
120 shouldShow =
121 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED;
122 </if>
123 <if expr="chromeos">
124 shouldShow = !this.isTargetChannelMoreStable_() &&
125 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED;
126 </if>
127 return shouldShow;
128 },
129
130 /**
98 * @return {string} 131 * @return {string}
99 * @private 132 * @private
100 */ 133 */
101 getUpdateStatusMessage_: function() { 134 getUpdateStatusMessage_: function() {
102 switch (this.currentUpdateStatusEvent_.status) { 135 switch (this.currentUpdateStatusEvent_.status) {
103 case UpdateStatus.CHECKING: 136 case UpdateStatus.CHECKING:
104 return this.i18n('aboutUpgradeCheckStarted'); 137 return this.i18n('aboutUpgradeCheckStarted');
105 case UpdateStatus.NEARLY_UPDATED: 138 case UpdateStatus.NEARLY_UPDATED:
106 <if expr="chromeos"> 139 <if expr="chromeos">
107 if (this.channelsDiffer_) 140 if (this.currentChannel_ != this.targetChannel_)
108 return this.i18n('aboutUpgradeSuccessChannelSwitch'); 141 return this.i18n('aboutUpgradeSuccessChannelSwitch');
109 </if> 142 </if>
110 return this.i18n('aboutUpgradeRelaunch'); 143 return this.i18n('aboutUpgradeRelaunch');
111 case UpdateStatus.UPDATED: 144 case UpdateStatus.UPDATED:
112 return this.i18n('aboutUpgradeUpToDate'); 145 return this.i18n('aboutUpgradeUpToDate');
113 case UpdateStatus.UPDATING: 146 case UpdateStatus.UPDATING:
114 <if expr="chromeos"> 147 <if expr="chromeos">
115 if (this.channelsDiffer_) { 148 if (this.currentChannel_ != this.targetChannel_) {
116 return this.i18n('aboutUpgradeUpdatingChannelSwitch', 149 return this.i18n('aboutUpgradeUpdatingChannelSwitch',
117 this.i18n(settings.browserChannelToI18nId(this.targetChannel_))); 150 this.i18n(settings.browserChannelToI18nId(this.targetChannel_)));
118 } 151 }
119 </if> 152 </if>
120 return this.i18n('aboutUpgradeUpdating'); 153 return this.i18n('aboutUpgradeUpdating');
121 default: 154 default:
122 return this.currentUpdateStatusEvent_.message; 155 return this.currentUpdateStatusEvent_.message || '';
123 } 156 }
124 }, 157 },
125 158
126 /** 159 /**
127 * @return {?string} 160 * @return {?string}
128 * @private 161 * @private
129 */ 162 */
130 getIcon_: function() { 163 getIcon_: function() {
131 switch (this.currentUpdateStatusEvent_.status) { 164 switch (this.currentUpdateStatusEvent_.status) {
132 case UpdateStatus.DISABLED_BY_ADMIN: 165 case UpdateStatus.DISABLED_BY_ADMIN:
(...skipping 16 matching lines...) Expand all
149 switch (this.currentUpdateStatusEvent_.status) { 182 switch (this.currentUpdateStatusEvent_.status) {
150 case UpdateStatus.CHECKING: 183 case UpdateStatus.CHECKING:
151 case UpdateStatus.UPDATING: 184 case UpdateStatus.UPDATING:
152 return 'chrome://resources/images/throbber_small.svg'; 185 return 'chrome://resources/images/throbber_small.svg';
153 default: 186 default:
154 return null; 187 return null;
155 } 188 }
156 }, 189 },
157 190
158 <if expr="chromeos"> 191 <if expr="chromeos">
192 /**
193 * @return {boolean}
194 * @private
195 */
196 isTargetChannelMoreStable_: function() {
197 // List of channels in increasing stability order.
198 var channelList = [
199 BrowserChannel.DEV,
200 BrowserChannel.BETA,
201 BrowserChannel.STABLE,
202 ];
203 var currentIndex = channelList.indexOf(this.currentChannel_);
204 var targetIndex = channelList.indexOf(this.targetChannel_);
205 return currentIndex < targetIndex;
206 },
207
159 /** @private */ 208 /** @private */
160 onDetailedBuildInfoTap_: function() { 209 onDetailedBuildInfoTap_: function() {
161 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ ( 210 var animatedPages = /** @type {!SettingsAnimatedPagesElement} */ (
162 this.$.pages); 211 this.$.pages);
163 animatedPages.setSubpageChain(['detailed-build-info']); 212 animatedPages.setSubpageChain(['detailed-build-info']);
164 }, 213 },
214
215 /** @private */
216 onRelaunchAndPowerwashTap_: function() {
217 // TODO(dpapad): Implement this.
218 },
219
220 /**
221 * @return {boolean}
222 * @private
223 */
224 shouldShowRelaunchAndPowerwash_: function() {
225 return this.isTargetChannelMoreStable_() &&
226 this.currentUpdateStatusEvent_.status == UpdateStatus.NEARLY_UPDATED;
227 },
228
229 /** @private */
230 onCheckUpdatesTap_: function() {
231 this.onUpdateStatusChanged_({status: UpdateStatus.CHECKING});
232 this.browserProxy_.requestUpdate();
233 },
234
235 /**
236 * @return {boolean}
237 * @private
238 */
239 shouldShowCheckUpdates_: function() {
240 return !this.hasCheckedForUpdates_ ||
241 this.currentUpdateStatusEvent_.status == UpdateStatus.FAILED;
242 },
165 </if> 243 </if>
166 244
167 <if expr="_google_chrome"> 245 <if expr="_google_chrome">
168 /** @private */ 246 /** @private */
169 onReportIssueTap_: function() { 247 onReportIssueTap_: function() {
170 this.browserProxy_.openFeedbackDialog(); 248 this.browserProxy_.openFeedbackDialog();
171 }, 249 },
172 </if> 250 </if>
173 }); 251 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698