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 return { | 10 return { |
11 | 11 |
12 EXTERNAL_API: [ | 12 EXTERNAL_API: [ |
13 'hideRollbackOption', | |
14 'showRollbackOption', | |
13 'updateViewOnRollbackCall' | 15 'updateViewOnRollbackCall' |
14 ], | 16 ], |
15 | 17 |
16 /** @override */ | 18 /** @override */ |
17 decorate: function() { | 19 decorate: function() { |
18 $('reset-powerwash-help-link-on-rollback').addEventListener( | 20 $('powerwash-help-link').addEventListener('click', function(event) { |
19 'click', function(event) { | |
20 chrome.send('resetOnLearnMore'); | |
21 }); | |
22 $('powerwash-help-link').addEventListener( | |
23 'click', function(event) { | |
24 chrome.send('resetOnLearnMore'); | 21 chrome.send('resetOnLearnMore'); |
25 }); | 22 }); |
26 }, | 23 }, |
27 | 24 |
28 /** | 25 /** |
29 * Header text of the screen. | 26 * Header text of the screen. |
30 * @type {string} | 27 * @type {string} |
31 */ | 28 */ |
32 get header() { | 29 get header() { |
33 return loadTimeData.getString('resetScreenTitle'); | 30 return loadTimeData.getString('resetScreenTitle'); |
34 }, | 31 }, |
35 | 32 |
36 /** | 33 /** |
37 * Buttons in oobe wizard's button strip. | 34 * Buttons in oobe wizard's button strip. |
38 * @type {array} Array of Buttons. | 35 * @type {array} Array of Buttons. |
39 */ | 36 */ |
40 get buttons() { | 37 get buttons() { |
41 var buttons = []; | 38 var buttons = []; |
39 var restartButton = this.ownerDocument.createElement('button'); | |
40 restartButton.id = 'reset-restart-button'; | |
41 restartButton.textContent = loadTimeData.getString('resetButtonRestart'); | |
42 restartButton.addEventListener('click', function(e) { | |
43 chrome.send('restartOnReset'); | |
44 e.stopPropagation(); | |
45 }); | |
46 buttons.push(restartButton); | |
47 | |
48 // Button that initiates actual powerwash or powerwash with rollback. | |
42 var resetButton = this.ownerDocument.createElement('button'); | 49 var resetButton = this.ownerDocument.createElement('button'); |
43 resetButton.id = 'reset-button'; | 50 resetButton.id = 'reset-button'; |
44 resetButton.textContent = ''; | 51 resetButton.textContent = loadTimeData.getString('resetButtonReset'); |
45 resetButton.addEventListener('click', function(e) { | 52 resetButton.addEventListener('click', function(e) { |
46 if ($('reset').needRestart) | 53 chrome.send('powerwashOnReset', [$('reset').rollbackChecked]); |
47 chrome.send('restartOnReset', [$('reset-rollback-checkbox').checked]); | |
48 else | |
49 chrome.send('powerwashOnReset', | |
50 [$('reset-rollback-checkbox').checked]); | |
51 e.stopPropagation(); | 54 e.stopPropagation(); |
52 }); | 55 }); |
53 buttons.push(resetButton); | 56 buttons.push(resetButton); |
54 | 57 |
58 // Button that leads to confirmation dialog. | |
59 var toConfirmButton = this.ownerDocument.createElement('button'); | |
60 toConfirmButton.id = 'reset-toconfirm-button'; | |
61 toConfirmButton.textContent = | |
62 loadTimeData.getString('resetButtonPowerwash'); | |
63 toConfirmButton.addEventListener('click', function(e) { | |
64 // change view to confirmational | |
65 $('reset').isConfirmational = true; | |
66 if ($('reset').rollbackChecked && $('reset').rollbackAvailable) | |
67 $('reset').setDialogView_('rollbackConfirmationalDialog'); | |
68 else | |
69 $('reset').setDialogView_('powerwashConfirmationalDialog'); | |
70 chrome.send('showConfirmationOnReset'); | |
71 e.stopPropagation(); | |
72 }); | |
73 buttons.push(toConfirmButton); | |
74 | |
55 var cancelButton = this.ownerDocument.createElement('button'); | 75 var cancelButton = this.ownerDocument.createElement('button'); |
56 cancelButton.id = 'reset-cancel-button'; | 76 cancelButton.id = 'reset-cancel-button'; |
57 cancelButton.textContent = loadTimeData.getString('cancelButton'); | 77 cancelButton.textContent = loadTimeData.getString('cancelButton'); |
58 cancelButton.addEventListener('click', function(e) { | 78 cancelButton.addEventListener('click', function(e) { |
59 chrome.send('cancelOnReset'); | 79 chrome.send('cancelOnReset'); |
60 e.stopPropagation(); | 80 e.stopPropagation(); |
61 }); | 81 }); |
62 buttons.push(cancelButton); | 82 buttons.push(cancelButton); |
63 | 83 |
64 return buttons; | 84 return buttons; |
65 }, | 85 }, |
66 | 86 |
67 /** | 87 /** |
68 * Returns a control which should receive an initial focus. | 88 * Returns a control which should receive an initial focus. |
69 */ | 89 */ |
70 get defaultControl() { | 90 get defaultControl() { |
91 // choose | |
92 if (this.needRestart) | |
93 return $('reset-restart-button'); | |
94 if (this.isConfirmational) | |
95 if (this.rollbackChecked) | |
96 return $('reset-button'); | |
97 else | |
98 return $('reset-toconfirm-button'); | |
71 return $('reset-button'); | 99 return $('reset-button'); |
72 }, | 100 }, |
73 | 101 |
74 /** | 102 /** |
75 * Cancels the reset and drops the user back to the login screen. | 103 * Cancels the reset and drops the user back to the login screen. |
76 */ | 104 */ |
77 cancel: function() { | 105 cancel: function() { |
78 chrome.send('cancelOnReset'); | 106 chrome.send('cancelOnReset'); |
79 }, | 107 }, |
80 | 108 |
81 /** | 109 /** |
82 * Event handler that is invoked just before the screen in shown. | 110 * Event handler that is invoked just before the screen in shown. |
83 * @param {Object} data Screen init payload. | 111 * @param {Object} data Screen init payload. |
84 */ | 112 */ |
85 onBeforeShow: function(data) { | 113 onBeforeShow: function(data) { |
86 if (data === undefined) | 114 if (data === undefined) |
87 return; | 115 return; |
88 this.classList.remove('revert-promise'); | 116 |
89 if ('showRestartMsg' in data) | 117 this.rollbackChecked = false; |
90 this.setRestartMsg_(data['showRestartMsg']); | 118 this.rollbackAvailable = false; |
91 if ('showRollbackOption' in data) | 119 this.isConfirmational = false; |
92 this.setRollbackAvailable_(data['showRollbackOption']); | 120 |
93 if ('simpleConfirm' in data) { | 121 if ('rollbackAvailable' in data) |
94 this.isConfirmational = data['simpleConfirm']; | 122 this.rollbackAvailable = data['rollbackAvailable']; |
95 this.confirmRollback = false; | 123 |
124 if ('restartRequired' in data && data['restartRequired']) { | |
125 this.restartRequired = true; | |
126 this.setDialogView_('restartRequiredDialog'); | |
96 } | 127 } |
97 if ('rollbackConfirm' in data) { | 128 else { |
dzhioev (left Google)
2014/08/26 12:08:18
Put 'else' on the same line as '}'
merkulova
2014/08/27 08:54:48
Done.
| |
98 this.isConfirmational = data['rollbackConfirm']; | 129 this.restartRequired = false; |
99 this.confirmRollback = true; | 130 this.setDialogView_('powerwashProposalDialog'); |
100 } | |
101 | |
102 if (this.isConfirmational) { | |
103 // Exec after reboot initiated by reset screen. | |
104 // Confirmational form of screen. | |
105 $('reset-button').textContent = loadTimeData.getString( | |
106 'resetButtonReset'); | |
107 if (this.confirmRollback) { | |
108 $('reset-warning-msg').textContent = loadTimeData.getString( | |
109 'resetAndRollbackWarningTextConfirmational'); | |
110 $('reset-warning-details').textContent = loadTimeData.getString( | |
111 'resetAndRollbackWarningDetailsConfirmational'); | |
112 } else { | |
113 $('reset-warning-msg').textContent = loadTimeData.getString( | |
114 'resetWarningTextConfirmational'); | |
115 $('reset-warning-details').textContent = loadTimeData.getString( | |
116 'resetWarningDetailsConfirmational'); | |
117 } | |
118 } else { | |
119 $('reset-warning-msg').textContent = loadTimeData.getString( | |
120 'resetWarningTextInitial'); | |
121 $('reset-warning-details').textContent = loadTimeData.getString( | |
122 'resetWarningDetailsInitial'); | |
123 if (this.needRestart) { | |
124 $('reset-button').textContent = loadTimeData.getString( | |
125 'resetButtonRelaunch'); | |
126 } else { | |
127 $('reset-button').textContent = loadTimeData.getString( | |
128 'resetButtonPowerwash'); | |
129 } | |
130 } | 131 } |
131 }, | 132 }, |
132 | 133 |
133 /** | 134 /** |
134 * Sets restart necessity for the screen. | 135 * Sets css style for corresponding state of the screen. |
135 * @param {bool} need_restart. If restart required before reset. | 136 * @param {string} state. |
136 * @private | 137 * @private |
137 */ | 138 */ |
138 setRestartMsg_: function(need_restart) { | 139 setDialogView_: function(state) { |
139 this.classList.toggle('norestart', !need_restart); | 140 this.classList.remove('revert-promise-view'); |
140 this.needRestart = need_restart; | 141 this.classList.remove('restart-required-view'); |
141 }, | 142 this.classList.remove('powerwash-proposal-view'); |
142 | 143 this.classList.remove('powerwash-confirm-view'); |
143 /** | 144 this.classList.remove('rollback-confirm-view'); |
144 * Sets rollback availability for the screen. | 145 if (state == 'revertPromiseDialog') |
145 * @param {bool} can_rollback. If Rollback is available on reset screen. | 146 this.classList.add('revert-promise-view'); |
146 * @private | 147 else if (state == 'restartRequiredDialog') |
147 */ | 148 this.classList.add('restart-required-view'); |
148 setRollbackAvailable_: function(show_rollback) { | 149 else if (state == 'powerwashProposalDialog') |
149 this.classList.toggle('norollback', !show_rollback); | 150 this.classList.add('powerwash-proposal-view'); |
150 this.showRollback = show_rollback; | 151 else if (state == 'powerwashConfirmationalDialog') |
dzhioev (left Google)
2014/08/26 12:08:18
I think it will be better if you create constants
merkulova
2014/08/27 08:54:48
Done.
| |
152 this.classList.add('powerwash-confirm-view'); | |
153 else if (state == 'rollbackConfirmationalDialog') | |
154 this.classList.add('rollback-confirm-view'); | |
155 else // default view is powerwashProposal | |
dzhioev (left Google)
2014/08/26 12:08:18
Check that it is really "powerwashProposal"
merkulova
2014/08/27 08:54:48
Not sure what you mean?
dzhioev (left Google)
2014/08/28 15:22:49
Check that in the last "else" |state == 'powerwash
merkulova
2014/08/29 07:26:54
Not like that. There's already a special case proc
dzhioev (left Google)
2014/08/29 15:44:31
I don't see a place where you call setDialogView_
merkulova
2014/09/03 08:48:20
Done.
| |
156 this.classList.add('powerwash-proposal-view'); | |
151 }, | 157 }, |
152 | 158 |
153 updateViewOnRollbackCall: function() { | 159 updateViewOnRollbackCall: function() { |
154 this.classList.add('revert-promise'); | 160 this.setDialogView_('revertPromiseDialog'); |
155 announceAccessibleMessage( | 161 announceAccessibleMessage( |
156 loadTimeData.getString('resetRevertSpinnerMessage')); | 162 loadTimeData.getString('resetRevertSpinnerMessage')); |
163 }, | |
164 | |
165 showRollbackOption: function() { | |
166 $('reset-toconfirm-button').textContent = loadTimeData.getString( | |
167 'resetButtonPowerwashAndRollback'); | |
168 this.rollbackChecked = true; | |
169 }, | |
170 | |
171 hideRollbackOption: function() { | |
172 $('reset-toconfirm-button').textContent = loadTimeData.getString( | |
173 'resetButtonPowerwash'); | |
174 this.rollbackChecked = false; | |
157 } | 175 } |
158 }; | 176 }; |
159 }); | 177 }); |
OLD | NEW |