OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 REVERT_PROMISE: 1, | 35 REVERT_PROMISE: 1, |
36 POWERWASH_PROPOSAL: 2, // supports 2 ui-states | 36 POWERWASH_PROPOSAL: 2, // supports 2 ui-states |
37 ERROR: 3, | 37 ERROR: 3, |
38 }, | 38 }, |
39 | 39 |
40 | 40 |
41 /** @override */ | 41 /** @override */ |
42 decorate: function() { | 42 decorate: function() { |
43 var self = this; | 43 var self = this; |
44 | 44 |
45 this.declareUserAction($('powerwash-help-link'), | 45 this.declareUserAction( |
46 { action_id: USER_ACTION_LEARN_MORE_PRESSED, | 46 $('powerwash-help-link'), |
47 event: 'click' | 47 {action_id: USER_ACTION_LEARN_MORE_PRESSED, event: 'click'}); |
48 }); | 48 this.declareUserAction( |
49 this.declareUserAction($('reset-confirm-dismiss'), | 49 $('reset-confirm-dismiss'), |
50 { action_id: USER_ACTION_RESET_CONFIRM_DISMISSED, | 50 {action_id: USER_ACTION_RESET_CONFIRM_DISMISSED, event: 'click'}); |
51 event: 'click' | 51 this.declareUserAction( |
52 }); | 52 $('reset-confirm-commit'), |
53 this.declareUserAction($('reset-confirm-commit'), | 53 {action_id: USER_ACTION_POWERWASH_PRESSED, event: 'click'}); |
54 { action_id: USER_ACTION_POWERWASH_PRESSED, | 54 |
55 event: 'click' | 55 this.context.addObserver(CONTEXT_KEY_SCREEN_STATE, function(state) { |
56 }); | 56 if (Oobe.getInstance().currentScreen != this) { |
| 57 setTimeout(function() { |
| 58 Oobe.resetSigninUI(false); |
| 59 Oobe.showScreen({id: SCREEN_OOBE_RESET}); |
| 60 }, 0); |
| 61 } |
| 62 if (state == self.RESET_SCREEN_STATE.RESTART_REQUIRED) |
| 63 self.ui_state = self.RESET_SCREEN_UI_STATE.RESTART_REQUIRED; |
| 64 if (state == self.RESET_SCREEN_STATE.REVERT_PROMISE) |
| 65 self.ui_state = self.RESET_SCREEN_UI_STATE.REVERT_PROMISE; |
| 66 else if (state == self.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) |
| 67 self.ui_state = self.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL; |
| 68 self.setDialogView_(); |
| 69 if (state == self.RESET_SCREEN_STATE.REVERT_PROMISE) { |
| 70 announceAccessibleMessage( |
| 71 loadTimeData.getString('resetRevertSpinnerMessage')); |
| 72 } |
| 73 }); |
57 | 74 |
58 this.context.addObserver( | 75 this.context.addObserver( |
59 CONTEXT_KEY_SCREEN_STATE, | 76 CONTEXT_KEY_IS_OFFICIAL_BUILD, function(isOfficial) { |
60 function(state) { | |
61 if (Oobe.getInstance().currentScreen != this) { | |
62 setTimeout(function() { | |
63 Oobe.resetSigninUI(false); | |
64 Oobe.showScreen({id: SCREEN_OOBE_RESET}); | |
65 }, 0); | |
66 } | |
67 if (state == self.RESET_SCREEN_STATE.RESTART_REQUIRED) | |
68 self.ui_state = self.RESET_SCREEN_UI_STATE.RESTART_REQUIRED; | |
69 if (state == self.RESET_SCREEN_STATE.REVERT_PROMISE) | |
70 self.ui_state = self.RESET_SCREEN_UI_STATE.REVERT_PROMISE; | |
71 else if (state == self.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) | |
72 self.ui_state = self.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL; | |
73 self.setDialogView_(); | |
74 if (state == self.RESET_SCREEN_STATE.REVERT_PROMISE) { | |
75 announceAccessibleMessage( | |
76 loadTimeData.getString('resetRevertSpinnerMessage')); | |
77 } | |
78 } | |
79 ); | |
80 | |
81 this.context.addObserver( | |
82 CONTEXT_KEY_IS_OFFICIAL_BUILD, | |
83 function(isOfficial) { | |
84 $('powerwash-help-link').setAttribute('hidden', !isOfficial); | 77 $('powerwash-help-link').setAttribute('hidden', !isOfficial); |
85 $('oobe-reset-md').isOfficial_ = isOfficial; | 78 $('oobe-reset-md').isOfficial_ = isOfficial; |
86 } | 79 }); |
87 ); | |
88 this.context.addObserver( | 80 this.context.addObserver( |
89 CONTEXT_KEY_ROLLBACK_CHECKED, | 81 CONTEXT_KEY_ROLLBACK_CHECKED, function(rollbackChecked) { |
90 function(rollbackChecked) { | |
91 self.setRollbackOptionView(); | 82 self.setRollbackOptionView(); |
92 } | 83 }); |
93 ); | |
94 this.context.addObserver( | 84 this.context.addObserver( |
95 CONTEXT_KEY_ROLLBACK_AVAILABLE, | 85 CONTEXT_KEY_ROLLBACK_AVAILABLE, function(rollbackAvailable) { |
96 function(rollbackAvailable) { | |
97 self.setRollbackOptionView(); | 86 self.setRollbackOptionView(); |
98 } | 87 }); |
99 ); | |
100 this.context.addObserver( | 88 this.context.addObserver( |
101 CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, | 89 CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, function(is_confirmational) { |
102 function(is_confirmational) { | |
103 if (is_confirmational) { | 90 if (is_confirmational) { |
104 console.log(self.context.get(CONTEXT_KEY_SCREEN_STATE, 0)); | 91 console.log(self.context.get(CONTEXT_KEY_SCREEN_STATE, 0)); |
105 if (self.context.get(CONTEXT_KEY_SCREEN_STATE, 0) != | 92 if (self.context.get(CONTEXT_KEY_SCREEN_STATE, 0) != |
106 self.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) | 93 self.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) |
107 return; | 94 return; |
108 console.log(self); | 95 console.log(self); |
109 reset.ConfirmResetOverlay.getInstance().initializePage(); | 96 reset.ConfirmResetOverlay.getInstance().initializePage(); |
110 } else { | 97 } else { |
111 $('overlay-reset').setAttribute('hidden', true); | 98 $('overlay-reset').setAttribute('hidden', true); |
112 } | 99 } |
113 } | 100 }); |
114 ); | |
115 }, | 101 }, |
116 | 102 |
117 /** | 103 /** |
118 * Header text of the screen. | 104 * Header text of the screen. |
119 * @type {string} | 105 * @type {string} |
120 */ | 106 */ |
121 get header() { | 107 get header() { |
122 return loadTimeData.getString('resetScreenTitle'); | 108 return loadTimeData.getString('resetScreenTitle'); |
123 }, | 109 }, |
124 | 110 |
125 /** | 111 /** |
126 * Buttons in oobe wizard's button strip. | 112 * Buttons in oobe wizard's button strip. |
127 * @type {array} Array of Buttons. | 113 * @type {array} Array of Buttons. |
128 */ | 114 */ |
129 get buttons() { | 115 get buttons() { |
130 var buttons = []; | 116 var buttons = []; |
131 var restartButton = this.ownerDocument.createElement('button'); | 117 var restartButton = this.ownerDocument.createElement('button'); |
132 restartButton.id = 'reset-restart-button'; | 118 restartButton.id = 'reset-restart-button'; |
133 restartButton.textContent = loadTimeData.getString('resetButtonRestart'); | 119 restartButton.textContent = loadTimeData.getString('resetButtonRestart'); |
134 this.declareUserAction(restartButton, | 120 this.declareUserAction( |
135 { action_id: USER_ACTION_RESTART_PRESSED, | 121 restartButton, |
136 event: 'click' | 122 {action_id: USER_ACTION_RESTART_PRESSED, event: 'click'}); |
137 }); | |
138 buttons.push(restartButton); | 123 buttons.push(restartButton); |
139 | 124 |
140 // Button that leads to confirmation pop-up dialog. | 125 // Button that leads to confirmation pop-up dialog. |
141 var toConfirmButton = this.ownerDocument.createElement('button'); | 126 var toConfirmButton = this.ownerDocument.createElement('button'); |
142 toConfirmButton.id = 'reset-toconfirm-button'; | 127 toConfirmButton.id = 'reset-toconfirm-button'; |
143 toConfirmButton.textContent = | 128 toConfirmButton.textContent = |
144 loadTimeData.getString('resetButtonPowerwash'); | 129 loadTimeData.getString('resetButtonPowerwash'); |
145 this.declareUserAction(toConfirmButton, | 130 this.declareUserAction( |
146 { action_id: USER_ACTION_SHOW_CONFIRMATION, | 131 toConfirmButton, |
147 event: 'click' | 132 {action_id: USER_ACTION_SHOW_CONFIRMATION, event: 'click'}); |
148 }); | |
149 buttons.push(toConfirmButton); | 133 buttons.push(toConfirmButton); |
150 | 134 |
151 var cancelButton = this.ownerDocument.createElement('button'); | 135 var cancelButton = this.ownerDocument.createElement('button'); |
152 cancelButton.id = 'reset-cancel-button'; | 136 cancelButton.id = 'reset-cancel-button'; |
153 cancelButton.textContent = loadTimeData.getString('cancelButton'); | 137 cancelButton.textContent = loadTimeData.getString('cancelButton'); |
154 this.declareUserAction(cancelButton, | 138 this.declareUserAction( |
155 { action_id: USER_ACTION_CANCEL_RESET, | 139 cancelButton, {action_id: USER_ACTION_CANCEL_RESET, event: 'click'}); |
156 event: 'click' | |
157 }); | |
158 buttons.push(cancelButton); | 140 buttons.push(cancelButton); |
159 | 141 |
160 return buttons; | 142 return buttons; |
161 }, | 143 }, |
162 | 144 |
163 /** | 145 /** |
164 * Returns a control which should receive an initial focus. | 146 * Returns a control which should receive an initial focus. |
165 */ | 147 */ |
166 get defaultControl() { | 148 get defaultControl() { |
167 // choose | 149 // choose |
168 if (this.isMDMode_()) | 150 if (this.isMDMode_()) |
169 return $('oobe-reset-md'); | 151 return $('oobe-reset-md'); |
170 if (this.context.get(CONTEXT_KEY_SCREEN_STATE, | 152 if (this.context.get( |
171 this.RESET_SCREEN_STATE.RESTART_REQUIRED) == | 153 CONTEXT_KEY_SCREEN_STATE, |
| 154 this.RESET_SCREEN_STATE.RESTART_REQUIRED) == |
172 this.RESET_SCREEN_STATE.RESTART_REQUIRED) | 155 this.RESET_SCREEN_STATE.RESTART_REQUIRED) |
173 return $('reset-restart-button'); | 156 return $('reset-restart-button'); |
174 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) | 157 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) |
175 return $('reset-confirm-commit'); | 158 return $('reset-confirm-commit'); |
176 return $('reset-toconfirm-button'); | 159 return $('reset-toconfirm-button'); |
177 }, | 160 }, |
178 | 161 |
179 /** | 162 /** |
180 * Cancels the reset and drops the user back to the login screen. | 163 * Cancels the reset and drops the user back to the login screen. |
181 */ | 164 */ |
182 cancel: function() { | 165 cancel: function() { |
183 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) { | 166 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) { |
184 $('reset').send(login.Screen.CALLBACK_USER_ACTED, | 167 $('reset').send( |
185 USER_ACTION_RESET_CONFIRM_DISMISSED); | 168 login.Screen.CALLBACK_USER_ACTED, |
| 169 USER_ACTION_RESET_CONFIRM_DISMISSED); |
186 return; | 170 return; |
187 } | 171 } |
188 this.send(login.Screen.CALLBACK_USER_ACTED, USER_ACTION_CANCEL_RESET); | 172 this.send(login.Screen.CALLBACK_USER_ACTED, USER_ACTION_CANCEL_RESET); |
189 }, | 173 }, |
190 | 174 |
191 /** | 175 /** |
192 * This method takes care of switching to material-design OOBE. | 176 * This method takes care of switching to material-design OOBE. |
193 * @private | 177 * @private |
194 */ | 178 */ |
195 setMDMode_: function() { | 179 setMDMode_: function() { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 setRollbackOptionView: function() { | 253 setRollbackOptionView: function() { |
270 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) | 254 if (this.context.get(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false)) |
271 return; | 255 return; |
272 if (this.context.get(CONTEXT_KEY_SCREEN_STATE) != | 256 if (this.context.get(CONTEXT_KEY_SCREEN_STATE) != |
273 this.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) | 257 this.RESET_SCREEN_STATE.POWERWASH_PROPOSAL) |
274 return; | 258 return; |
275 | 259 |
276 if (this.context.get(CONTEXT_KEY_ROLLBACK_AVAILABLE, false) && | 260 if (this.context.get(CONTEXT_KEY_ROLLBACK_AVAILABLE, false) && |
277 this.context.get(CONTEXT_KEY_ROLLBACK_CHECKED, false)) { | 261 this.context.get(CONTEXT_KEY_ROLLBACK_CHECKED, false)) { |
278 // show rollback option | 262 // show rollback option |
279 $('reset-toconfirm-button').textContent = loadTimeData.getString( | 263 $('reset-toconfirm-button').textContent = |
280 'resetButtonPowerwashAndRollback'); | 264 loadTimeData.getString('resetButtonPowerwashAndRollback'); |
281 this.ui_state = this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL; | 265 this.ui_state = this.RESET_SCREEN_UI_STATE.ROLLBACK_PROPOSAL; |
282 } else { | 266 } else { |
283 // hide rollback option | 267 // hide rollback option |
284 $('reset-toconfirm-button').textContent = loadTimeData.getString( | 268 $('reset-toconfirm-button').textContent = |
285 'resetButtonPowerwash'); | 269 loadTimeData.getString('resetButtonPowerwash'); |
286 this.ui_state = this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL; | 270 this.ui_state = this.RESET_SCREEN_UI_STATE.POWERWASH_PROPOSAL; |
287 } | 271 } |
288 this.setDialogView_(); | 272 this.setDialogView_(); |
289 } | 273 } |
290 }; | 274 }; |
291 }); | 275 }); |
OLD | NEW |