OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 cr.define('reset', function() { | 5 cr.define('reset', function() { |
6 | 6 |
| 7 var USER_ACTION_POWERWASH_PRESSED = 'powerwash-pressed'; |
| 8 var CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW = 'is-confirmational-view'; |
7 /** | 9 /** |
8 * ResetScreenConfirmationOverlay class | 10 * ResetScreenConfirmationOverlay class |
9 * Encapsulated handling of the 'Confirm reset device' overlay OOBE page. | 11 * Encapsulated handling of the 'Confirm reset device' overlay OOBE page. |
10 * @class | 12 * @class |
11 */ | 13 */ |
12 function ConfirmResetOverlay() { | 14 function ConfirmResetOverlay() { |
13 } | 15 } |
14 | 16 |
15 cr.addSingletonGetter(ConfirmResetOverlay); | 17 cr.addSingletonGetter(ConfirmResetOverlay); |
16 | 18 |
17 ConfirmResetOverlay.prototype = { | 19 ConfirmResetOverlay.prototype = { |
18 /** | 20 /** |
19 * Initialize the page. | 21 * Initialize the page. |
20 */ | 22 */ |
21 initializePage: function() { | 23 initializePage: function() { |
22 var overlay = $('reset-confirm-overlay'); | 24 var overlay = $('reset-confirm-overlay'); |
23 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); | 25 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); |
24 | 26 |
25 $('reset-confirm-dismiss').addEventListener('click', this.handleDismiss_); | 27 $('reset-confirm-dismiss').addEventListener('click', this.handleDismiss_); |
26 $('reset-confirm-commit').addEventListener('click', this.handleCommit_); | 28 $('reset-confirm-commit').addEventListener('click', this.handleCommit_); |
27 | 29 |
28 $('overlay-reset').removeAttribute('hidden'); | 30 $('overlay-reset').removeAttribute('hidden'); |
29 }, | 31 }, |
30 | 32 |
31 /** | 33 /** |
32 * Handles a click on the dismiss button. | 34 * Handles a click on the dismiss button. |
33 * @param {Event} e The click event. | 35 * @param {Event} e The click event. |
34 */ | 36 */ |
35 handleDismiss_: function(e) { | 37 handleDismiss_: function(e) { |
36 $('reset').isConfirmational = false; | 38 $('reset').context.set(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false); |
| 39 $('reset').commitContextChanges(); |
37 $('overlay-reset').setAttribute('hidden', true); | 40 $('overlay-reset').setAttribute('hidden', true); |
38 e.stopPropagation(); | 41 e.stopPropagation(); |
39 }, | 42 }, |
40 | 43 |
41 /** | 44 /** |
42 * Handles a click on the commit button. | 45 * Handles a click on the commit button. |
43 * @param {Event} e The click event. | 46 * @param {Event} e The click event. |
44 */ | 47 */ |
45 handleCommit_: function(e) { | 48 handleCommit_: function(e) { |
46 $('reset').isConfirmational = false; | 49 $('reset').context.set(CONTEXT_KEY_IS_CONFIRMATIONAL_VIEW, false); |
47 chrome.send('powerwashOnReset', [$('reset').rollbackChecked]); | 50 $('reset').commitContextChanges(); |
| 51 $('reset').send(login.Screen.CALLBACK_USER_ACTED, |
| 52 USER_ACTION_POWERWASH_PRESSED); |
48 $('overlay-reset').setAttribute('hidden', true); | 53 $('overlay-reset').setAttribute('hidden', true); |
49 e.stopPropagation(); | 54 e.stopPropagation(); |
50 }, | 55 }, |
51 }; | 56 }; |
52 | 57 |
53 // Export | 58 // Export |
54 return { | 59 return { |
55 ConfirmResetOverlay: ConfirmResetOverlay | 60 ConfirmResetOverlay: ConfirmResetOverlay |
56 }; | 61 }; |
57 }); | 62 }); |
OLD | NEW |