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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_update.js

Issue 2392273002: ChromeOS: Implement Update screen of material design OOBE. (Closed)
Patch Set: Update after review. Added new screen name. Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 Oobe update screen implementation. 6 * @fileoverview Oobe update screen implementation.
7 */ 7 */
8 8
9 login.createScreen('UpdateScreen', 'update', function() { 9 login.createScreen('UpdateScreen', 'update', function() {
10 var USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update'; 10 var USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 function(progress) { 48 function(progress) {
49 self.setUpdateProgress(progress); 49 self.setUpdateProgress(progress);
50 }); 50 });
51 this.context.addObserver(CONTEXT_KEY_PROGRESS_MESSAGE, 51 this.context.addObserver(CONTEXT_KEY_PROGRESS_MESSAGE,
52 function(progress_msg) { 52 function(progress_msg) {
53 self.setProgressMessage(progress_msg); 53 self.setProgressMessage(progress_msg);
54 }); 54 });
55 this.context.addObserver(CONTEXT_KEY_CANCEL_UPDATE_SHORTCUT_ENABLED, 55 this.context.addObserver(CONTEXT_KEY_CANCEL_UPDATE_SHORTCUT_ENABLED,
56 function(enabled) { 56 function(enabled) {
57 $('update-cancel-hint').hidden = !enabled; 57 $('update-cancel-hint').hidden = !enabled;
58 $('oobe-update-md').cancelAllowed = enabled;
58 }); 59 });
59 }, 60 },
60 61
61 /** 62 /**
62 * Header text of the screen. 63 * Header text of the screen.
63 * @type {string} 64 * @type {string}
64 */ 65 */
65 get header() { 66 get header() {
66 return loadTimeData.getString('updateScreenTitle'); 67 return loadTimeData.getString('updateScreenTitle');
67 }, 68 },
68 69
69 /** 70 /**
70 * Cancels the screen. 71 * Cancels the screen.
71 */ 72 */
72 cancel: function() { 73 cancel: function() {
73 // It's safe to act on the accelerator even if it's disabled on official 74 // It's safe to act on the accelerator even if it's disabled on official
74 // builds, since Chrome will just ignore this user action in that case. 75 // builds, since Chrome will just ignore this user action in that case.
75 var updateCancelHint = $('update-cancel-hint').firstElementChild; 76 var updateCancelHint = $('update-cancel-hint').firstElementChild;
76 updateCancelHint.textContent = 77 var message = loadTimeData.getString('cancelledUpdateMessage');
77 loadTimeData.getString('cancelledUpdateMessage'); 78 updateCancelHint.textContent = message;
79 $('oobe-update-md').setCancelHint(message);
78 this.send(login.Screen.CALLBACK_USER_ACTED, 80 this.send(login.Screen.CALLBACK_USER_ACTED,
79 USER_ACTION_CANCEL_UPDATE_SHORTCUT); 81 USER_ACTION_CANCEL_UPDATE_SHORTCUT);
80 }, 82 },
81 83
82 /** 84 /**
83 * Sets update's progress bar value. 85 * Sets update's progress bar value.
84 * @param {number} progress Percentage of the progress bar. 86 * @param {number} progress Percentage of the progress bar.
85 */ 87 */
86 setUpdateProgress: function(progress) { 88 setUpdateProgress: function(progress) {
87 $('update-progress-bar').value = progress; 89 $('update-progress-bar').value = progress;
90 $('oobe-update-md').progressValue = progress;
88 }, 91 },
89 92
90 /** 93 /**
91 * Shows or hides downloading ETA message. 94 * Shows or hides downloading ETA message.
92 * @param {boolean} visible Are ETA message visible? 95 * @param {boolean} visible Are ETA message visible?
93 */ 96 */
94 showEstimatedTimeLeft: function(visible) { 97 showEstimatedTimeLeft: function(visible) {
95 $('progress-message').hidden = visible; 98 $('progress-message').hidden = visible;
96 $('estimated-time-left').hidden = !visible; 99 $('estimated-time-left').hidden = !visible;
100 $('oobe-update-md').estimatedTimeLeftShown = visible;
101 $('oobe-update-md').progressMessageShown = !visible;
97 }, 102 },
98 103
99 /** 104 /**
100 * Sets estimated time left until download will complete. 105 * Sets estimated time left until download will complete.
101 * @param {number} seconds Time left in seconds. 106 * @param {number} seconds Time left in seconds.
102 */ 107 */
103 setEstimatedTimeLeft: function(seconds) { 108 setEstimatedTimeLeft: function(seconds) {
104 var minutes = Math.ceil(seconds / 60); 109 var minutes = Math.ceil(seconds / 60);
105 var message = ''; 110 var message = '';
106 if (minutes > 60) { 111 if (minutes > 60) {
107 message = loadTimeData.getString('downloadingTimeLeftLong'); 112 message = loadTimeData.getString('downloadingTimeLeftLong');
108 } else if (minutes > 55) { 113 } else if (minutes > 55) {
109 message = loadTimeData.getString('downloadingTimeLeftStatusOneHour'); 114 message = loadTimeData.getString('downloadingTimeLeftStatusOneHour');
110 } else if (minutes > 20) { 115 } else if (minutes > 20) {
111 message = loadTimeData.getStringF('downloadingTimeLeftStatusMinutes', 116 message = loadTimeData.getStringF('downloadingTimeLeftStatusMinutes',
112 Math.ceil(minutes / 5) * 5); 117 Math.ceil(minutes / 5) * 5);
113 } else if (minutes > 1) { 118 } else if (minutes > 1) {
114 message = loadTimeData.getStringF('downloadingTimeLeftStatusMinutes', 119 message = loadTimeData.getStringF('downloadingTimeLeftStatusMinutes',
115 minutes); 120 minutes);
116 } else { 121 } else {
117 message = loadTimeData.getString('downloadingTimeLeftSmall'); 122 message = loadTimeData.getString('downloadingTimeLeftSmall');
118 } 123 }
119 $('estimated-time-left').textContent = 124 var formattedMessage =
120 loadTimeData.getStringF('downloading', message); 125 loadTimeData.getStringF('downloading', message);
126 $('estimated-time-left').textContent = formattedMessage;
127 $('oobe-update-md').estimatedTimeLeft = formattedMessage;
121 }, 128 },
122 129
123 /** 130 /**
124 * Shows or hides info message below progress bar. 131 * Shows or hides info message below progress bar.
125 * @param {boolean} visible Are message visible? 132 * @param {boolean} visible Are message visible?
126 */ 133 */
127 showProgressMessage: function(visible) { 134 showProgressMessage: function(visible) {
128 $('estimated-time-left').hidden = visible; 135 $('estimated-time-left').hidden = visible;
129 $('progress-message').hidden = !visible; 136 $('progress-message').hidden = !visible;
137 $('oobe-update-md').estimatedTimeLeftShown = !visible;
138 $('oobe-update-md').progressMessageShown = visible;
130 }, 139 },
131 140
132 /** 141 /**
133 * Sets message below progress bar. 142 * Sets message below progress bar.
134 * @param {string} message Message that should be shown. 143 * @param {string} message Message that should be shown.
135 */ 144 */
136 setProgressMessage: function(message) { 145 setProgressMessage: function(message) {
137 $('progress-message').innerText = message; 146 $('progress-message').innerText = message;
147 $('oobe-update-md').progressMessage = message;
138 }, 148 },
139 149
140 /** 150 /**
141 * Sets update message, which is shown above the progress bar. 151 * Sets update message, which is shown above the progress bar.
142 * @param {text} message Message which is shown by the label. 152 * @param {text} message Message which is shown by the label.
143 */ 153 */
144 setUpdateMessage: function(message) { 154 setUpdateMessage: function(message) {
145 $('update-upper-label').textContent = message; 155 $('update-upper-label').textContent = message;
156 $('oobe-update-md').updateUpperLabel = message;
146 }, 157 },
147 158
148 /** 159 /**
149 * Shows or hides update curtain. 160 * Shows or hides update curtain.
150 * @param {boolean} visible Are curtains visible? 161 * @param {boolean} visible Are curtains visible?
151 */ 162 */
152 showUpdateCurtain: function(visible) { 163 showUpdateCurtain: function(visible) {
153 $('update-screen-curtain').hidden = !visible; 164 $('update-screen-curtain').hidden = !visible;
154 $('update-screen-main').hidden = visible; 165 $('update-screen-main').hidden = visible;
155 } 166 $('oobe-update-md').checkingForUpdate = visible;
167 },
168
169 /**
170 * This method takes care of switching to material-design OOBE.
171 * @private
172 */
173 setMDMode_: function() {
174 var useMDOobe = (loadTimeData.getString('newOobeUI') == 'on');
175 $('oobe-update-md').hidden = !useMDOobe;
176 $('oobe-update').hidden = useMDOobe;
177 },
178
179 /**
180 * Event handler that is invoked just before the screen is shown.
181 */
182 onBeforeShow: function() {
183 this.setMDMode_();
184 },
185
186 /**
187 * Updates localized content of the screen that is not updated via template.
188 */
189 updateLocalizedContent: function() {
190 this.setMDMode_();
191 },
156 }; 192 };
157 }); 193 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698