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

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

Issue 2756863002: ChromeOS: Powerwash UI update (Closed)
Patch Set: merge Created 3 years, 8 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 Device reset screen implementation. 6 * @fileoverview Device reset screen implementation.
7 */ 7 */
8 8
9 login.createScreen('ResetScreen', 'reset', function() { 9 login.createScreen('ResetScreen', 'reset', function() {
10 var USER_ACTION_CANCEL_RESET = 'cancel-reset'; 10 var USER_ACTION_CANCEL_RESET = 'cancel-reset';
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 announceAccessibleMessage( 75 announceAccessibleMessage(
76 loadTimeData.getString('resetRevertSpinnerMessage')); 76 loadTimeData.getString('resetRevertSpinnerMessage'));
77 } 77 }
78 } 78 }
79 ); 79 );
80 80
81 this.context.addObserver( 81 this.context.addObserver(
82 CONTEXT_KEY_IS_OFFICIAL_BUILD, 82 CONTEXT_KEY_IS_OFFICIAL_BUILD,
83 function(isOfficial) { 83 function(isOfficial) {
84 $('powerwash-help-link').setAttribute('hidden', !isOfficial); 84 $('powerwash-help-link').setAttribute('hidden', !isOfficial);
85 $('oobe-reset-md').isOfficial_ = isOfficial;
85 } 86 }
86 ); 87 );
87 this.context.addObserver( 88 this.context.addObserver(
88 CONTEXT_KEY_ROLLBACK_CHECKED, 89 CONTEXT_KEY_ROLLBACK_CHECKED,
89 function(rollbackChecked) { 90 function(rollbackChecked) {
90 self.setRollbackOptionView(); 91 self.setRollbackOptionView();
91 } 92 }
92 ); 93 );
93 this.context.addObserver( 94 this.context.addObserver(
94 CONTEXT_KEY_ROLLBACK_AVAILABLE, 95 CONTEXT_KEY_ROLLBACK_AVAILABLE,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 buttons.push(cancelButton); 158 buttons.push(cancelButton);
158 159
159 return buttons; 160 return buttons;
160 }, 161 },
161 162
162 /** 163 /**
163 * Returns a control which should receive an initial focus. 164 * Returns a control which should receive an initial focus.
164 */ 165 */
165 get defaultControl() { 166 get defaultControl() {
166 // choose 167 // choose
168 if (this.isMDMode_())
169 return $('oobe-reset-md');
167 if (this.context.get(CONTEXT_KEY_SCREEN_STATE, 170 if (this.context.get(CONTEXT_KEY_SCREEN_STATE,
168 this.RESET_SCREEN_STATE.RESTART_REQUIRED) == 171 this.RESET_SCREEN_STATE.RESTART_REQUIRED) ==
169 this.RESET_SCREEN_STATE.RESTART_REQUIRED) 172 this.RESET_SCREEN_STATE.RESTART_REQUIRED)
170 return $('reset-restart-button'); 173 return $('reset-restart-button');
171 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) 174 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false))
172 return $('reset-confirm-commit'); 175 return $('reset-confirm-commit');
173 return $('reset-toconfirm-button'); 176 return $('reset-toconfirm-button');
174 }, 177 },
175 178
176 /** 179 /**
177 * Cancels the reset and drops the user back to the login screen. 180 * Cancels the reset and drops the user back to the login screen.
178 */ 181 */
179 cancel: function() { 182 cancel: function() {
180 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) { 183 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) {
181 $('reset').send(login.Screen.CALLBACK_USER_ACTED, 184 $('reset').send(login.Screen.CALLBACK_USER_ACTED,
182 USER_ACTION_RESET_CONFIRM_DISMISSED); 185 USER_ACTION_RESET_CONFIRM_DISMISSED);
183 return; 186 return;
184 } 187 }
185 this.send(login.Screen.CALLBACK_USER_ACTED, USER_ACTION_CANCEL_RESET); 188 this.send(login.Screen.CALLBACK_USER_ACTED, USER_ACTION_CANCEL_RESET);
186 }, 189 },
187 190
188 /** 191 /**
192 * This method takes care of switching to material-design OOBE.
193 * @private
194 */
195 setMDMode_: function() {
196 var useMDOobe = this.isMDMode_();
197 $('oobe-reset-md').hidden = !useMDOobe;
198 $('reset-confirm-overlay-md').hidden = !useMDOobe;
199 $('oobe-reset').hidden = useMDOobe;
200 $('reset-confirm-overlay').hidden = useMDOobe;
201 if (useMDOobe) {
202 $('reset').setAttribute('md-mode', 'true');
203 $('overlay-reset').setAttribute('md-mode', 'true');
204 } else {
205 $('reset').removeAttribute('md-mode');
206 $('overlay-reset').removeAttribute('md-mode');
207 }
208 },
209
210 /**
211 * Returns if material-design flag is used.
212 * @private
213 */
214 isMDMode_: function() {
215 return loadTimeData.getString('newOobeUI') == 'on';
216 },
217
218 /**
189 * Event handler that is invoked just before the screen in shown. 219 * Event handler that is invoked just before the screen in shown.
190 * @param {Object} data Screen init payload. 220 * @param {Object} data Screen init payload.
191 */ 221 */
192 onBeforeShow: function(data) { 222 onBeforeShow: function(data) {
223 this.setMDMode_();
193 }, 224 },
194 225
195 /** 226 /**
196 * Sets css style for corresponding state of the screen. 227 * Sets css style for corresponding state of the screen.
197 * @private 228 * @private
198 */ 229 */
199 setDialogView_: function(state) { 230 setDialogView_: function(state) {
200 state = this.ui_state; 231 state = this.ui_state;
201 var resetOverlay = $('reset-confirm-overlay'); 232 var resetOverlay = $('reset-confirm-overlay');
202 this.classList.toggle( 233 this.classList.toggle(
203 'revert-promise-view', 234 'revert-promise-view',
204 state == this.RESET_SCREEN_UI_STATE.REVERT_PROMISE); 235 state == this.RESET_SCREEN_UI_STATE.REVERT_PROMISE);
205 this.classList.toggle( 236 this.classList.toggle(
206 'restart-required-view', 237 'restart-required-view',
207 state == this.RESET_SCREEN_UI_STATE.RESTART_REQUIRED); 238 state == this.RESET_SCREEN_UI_STATE.RESTART_REQUIRED);
208 this.classList.toggle( 239 this.classList.toggle(
209 'powerwash-proposal-view', 240 'powerwash-proposal-view',
210 state == this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL); 241 state == this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL);
211 resetOverlay.classList.toggle( 242 resetOverlay.classList.toggle(
212 'powerwash-proposal-view', 243 'powerwash-proposal-view',
213 state == this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL); 244 state == this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL);
214 this.classList.toggle( 245 this.classList.toggle(
215 'rollback-proposal-view', 246 'rollback-proposal-view',
216 state == this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL); 247 state == this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL);
217 resetOverlay.classList.toggle( 248 resetOverlay.classList.toggle(
218 'rollback-proposal-view', 249 'rollback-proposal-view',
219 state == this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL); 250 state == this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL);
251 var resetMd = $('oobe-reset-md');
252 var resetOverlayMd = $('reset-confirm-overlay-md');
253 if (state == this.RESET_SCREEN_UI_STATE.RESTART_REQUIRED) {
254 resetMd.uiState_ = 'restart-required-view';
255 }
256 if (state == this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL) {
257 resetMd.uiState_ = 'powerwash-proposal-view';
258 resetOverlayMd.isPowerwashView_ = true;
259 }
260 if (state == this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL) {
261 resetMd.uiState_ = 'rollback-proposal-view';
262 resetOverlayMd.isPowerwashView_ = false;
263 }
264 if (state == this.RESET_SCREEN_UI_STATE.REVERT_PROMISE) {
265 resetMd.uiState_ = 'revert-promise-view';
266 }
220 }, 267 },
221 268
222 setRollbackOptionView: function() { 269 setRollbackOptionView: function() {
223 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) 270 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false))
224 return; 271 return;
225 if (this.context.get(CONTEXT_KEY_SCREEN_STATE) != 272 if (this.context.get(CONTEXT_KEY_SCREEN_STATE) !=
226 this.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) 273 this.RESET_SCREEN_STATE.POWERWASH_PROPOSAL)
227 return; 274 return;
228 275
229 if (this.context.get(CONTEXT_KEY_ROLLBACK_AVAILABLE, false) && 276 if (this.context.get(CONTEXT_KEY_ROLLBACK_AVAILABLE, false) &&
230 this.context.get(CONTEXT_KEY_ROLLBACK_CHECKED, false)) { 277 this.context.get(CONTEXT_KEY_ROLLBACK_CHECKED, false)) {
231 // show rollback option 278 // show rollback option
232 $('reset-toconfirm-button').textContent = loadTimeData.getString( 279 $('reset-toconfirm-button').textContent = loadTimeData.getString(
233 'resetButtonPowerwashAndRollback'); 280 'resetButtonPowerwashAndRollback');
234 this.ui_state = this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL; 281 this.ui_state = this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL;
235 } else { 282 } else {
236 // hide rollback option 283 // hide rollback option
237 $('reset-toconfirm-button').textContent = loadTimeData.getString( 284 $('reset-toconfirm-button').textContent = loadTimeData.getString(
238 'resetButtonPowerwash'); 285 'resetButtonPowerwash');
239 this.ui_state = this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL; 286 this.ui_state = this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL;
240 } 287 }
241 this.setDialogView_(); 288 this.setDialogView_();
242 } 289 }
243 }; 290 };
244 }); 291 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698