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

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

Issue 1987813004: MD Settings: About page, implementing update status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. 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: [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() {
tommycli 2016/05/19 20:44:48 optional suggestion: maybe isUpdateStatusShown? (o
dpapad 2016/05/19 21:31:05 I find the suggested naming a bit backward compare
94 return this.currentUpdateStatusEvent_.status != UpdateStatus.DISABLED;
95 },
96
97 /**
98 * @return {string}
99 * @private
100 */
101 getUpdateStatusMessage_: function() {
tommycli 2016/05/19 20:44:48 Arg... yeah this is complicated and i can't think
dpapad 2016/05/19 21:31:05 Done.
102 var messageId = null;
103 var channelDisplayName = null;
104
105 switch (this.currentUpdateStatusEvent_.status) {
106 case UpdateStatus.CHECKING:
107 messageId = 'aboutUpgradeCheckStarted';
108 break;
109 case UpdateStatus.NEARLY_UPDATED:
110 messageId = 'aboutUpgradeRelaunch';
111 <if expr="chromeos">
112 if (this.channelsDiffer_)
113 messageId = 'aboutUpgradeSuccessChannelSwitch';
114 </if>
115 break;
116 case UpdateStatus.UPDATED:
117 messageId = 'aboutUpgradeUpToDate';
118 break;
119 case UpdateStatus.UPDATING:
120 messageId = 'aboutUpgradeUpdating';
121 <if expr="chromeos">
122 if (this.channelsDiffer_) {
123 messageId = 'aboutUpgradeUpdatingChannelSwitch';
124 channelDisplayName = this.i18n(
125 settings.browserChannelToI18nId(this.targetChannel_));
126 }
127 </if>
128 break;
129 }
130
131 return messageId == null ?
132 this.currentUpdateStatusEvent_.message :
133 this.i18n(messageId, channelDisplayName || undefined);
134 },
135
136 /**
137 * @return {string}
138 * @private
139 */
140 getIconCssClass_: function() {
141 switch (this.currentUpdateStatusEvent_.status) {
142 case UpdateStatus.FAILED: return 'error-icon';
tommycli 2016/05/19 20:44:48 formatting nit: maybe put these returns on the sep
dpapad 2016/05/19 21:31:05 Done.
143 case UpdateStatus.UPDATED:
144 case UpdateStatus.NEARLY_UPDATED:
145 return 'check-icon';
146 default: return '';
tommycli 2016/05/19 20:44:48 nit: same here
dpapad 2016/05/19 21:31:05 Done.
147 }
148 },
149
150 /**
151 * @return {?string}
152 * @private
153 */
154 getIcon_: function() {
155 switch (this.currentUpdateStatusEvent_.status) {
156 case UpdateStatus.DISABLED_BY_ADMIN: return 'cr:domain';
tommycli 2016/05/19 20:44:48 formatting nit: same here
dpapad 2016/05/19 21:31:05 Done.
157 case UpdateStatus.FAILED: return 'settings:error';
158 case UpdateStatus.UPDATED:
159 case UpdateStatus.NEARLY_UPDATED:
160 return 'settings:check-circle';
161 default: return null;
162 }
163 },
164
165 /**
166 * @return {?string}
167 * @private
168 */
169 getIconSrc_: function() {
170 switch (this.currentUpdateStatusEvent_.status) {
171 case UpdateStatus.CHECKING:
172 case UpdateStatus.UPDATING:
173 return 'chrome://resources/images/throbber_small.svg';
174 default: 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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698