OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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('options', function() { | 5 cr.define('extensions', function() { |
6 /** @const */ var OptionsPage = options.OptionsPage; | |
7 | |
8 /** | 6 /** |
9 * A confirmation overlay for disabling kiosk app bailout shortcut. | 7 * A confirmation overlay for disabling kiosk app bailout shortcut. |
10 * @extends {options.OptionsPage} | |
11 * @constructor | 8 * @constructor |
12 */ | 9 */ |
13 function KioskDisableBailoutConfirm() { | 10 function KioskDisableBailoutConfirm() { |
14 OptionsPage.call(this, | |
15 'kioskDisableBailoutConfirm', | |
16 '', | |
17 'kiosk-disable-bailout-confirm-overlay'); | |
18 } | 11 } |
19 | 12 |
20 cr.addSingletonGetter(KioskDisableBailoutConfirm); | 13 cr.addSingletonGetter(KioskDisableBailoutConfirm); |
21 | 14 |
22 KioskDisableBailoutConfirm.prototype = { | 15 KioskDisableBailoutConfirm.prototype = { |
23 __proto__: OptionsPage.prototype, | 16 /** |
24 | 17 * Initialize the page. |
25 /** @override */ | 18 */ |
26 initializePage: function() { | 19 initializePage: function() { |
Dan Beam
2013/05/30 21:14:55
nit: I would maybe consider renaming this to avoid
xiyuan
2013/05/30 23:03:38
Done.
| |
27 OptionsPage.prototype.initializePage.call(this); | 20 var overlay = $('kiosk-disable-bailout-confirm-overlay'); |
21 cr.ui.overlay.setupOverlay(overlay); | |
22 overlay.addEventListener('cancelOverlay', this.handleCancel); | |
28 | 23 |
29 var el = $('kiosk-disable-bailout-shortcut'); | 24 var el = $('kiosk-disable-bailout-shortcut'); |
30 el.customChangeHandler = this.handleDisableBailoutShortcutChange_; | 25 el.addEventListener('change', this.handleDisableBailoutShortcutChange_); |
31 | 26 |
32 $('kiosk-disable-bailout-confirm-button').onclick = function(e) { | 27 $('kiosk-disable-bailout-confirm-button').onclick = function(e) { |
33 OptionsPage.closeOverlay(); | 28 ExtensionSettings.showOverlay($('kiosk-apps-page')); |
34 Preferences.setBooleanPref( | 29 chrome.send('setDisableBailoutShortcut', [true]); |
35 'cros.accounts.deviceLocalAccountAutoLoginBailoutEnabled', | |
36 false, true); | |
37 }; | 30 }; |
38 $('kiosk-disable-bailout-cancel-button').onclick = this.handleCancel; | 31 $('kiosk-disable-bailout-cancel-button').onclick = this.handleCancel; |
39 }, | 32 }, |
40 | 33 |
41 /** @override */ | 34 /** Handles overlay being canceled. */ |
42 handleCancel: function() { | 35 handleCancel: function() { |
43 OptionsPage.closeOverlay(); | 36 ExtensionSettings.showOverlay($('kiosk-apps-page')); |
44 $('kiosk-disable-bailout-shortcut').checked = false; | 37 $('kiosk-disable-bailout-shortcut').checked = false; |
45 }, | 38 }, |
46 | 39 |
47 /** | 40 /** |
48 * Custom change handler for the disable bailout shortcut checkbox. | 41 * Custom change handler for the disable bailout shortcut checkbox. |
49 * It blocks the underlying pref being changed and brings up confirmation | 42 * It blocks the underlying pref being changed and brings up confirmation |
50 * alert to user. | 43 * alert to user. |
51 * @private | 44 * @private |
52 */ | 45 */ |
53 handleDisableBailoutShortcutChange_: function() { | 46 handleDisableBailoutShortcutChange_: function() { |
54 // Let default processing happening if user un-checks the box. | 47 // Just set the pref if user un-checks the box. |
55 if (!$('kiosk-disable-bailout-shortcut').checked) | 48 if (!$('kiosk-disable-bailout-shortcut').checked) { |
49 chrome.send('setDisableBailoutShortcut', [false]); | |
56 return false; | 50 return false; |
51 } | |
57 | 52 |
58 // Otherwise, show the confirmation overlay. | 53 // Otherwise, show the confirmation overlay. |
59 OptionsPage.showPageByName('kioskDisableBailoutConfirm', false); | 54 ExtensionSettings.showOverlay($('kiosk-disable-bailout-confirm-overlay')); |
60 return true; | 55 return true; |
61 } | 56 } |
62 }; | 57 }; |
63 | 58 |
64 // Export | 59 // Export |
65 return { | 60 return { |
66 KioskDisableBailoutConfirm: KioskDisableBailoutConfirm | 61 KioskDisableBailoutConfirm: KioskDisableBailoutConfirm |
67 }; | 62 }; |
68 }); | 63 }); |
69 | 64 |
OLD | NEW |