BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / resources / extensions / chromeos / kiosk_app_disable_bailout_confirm.js
blob89c628b3dc1aa9064b556e6719a835aa9ab4eec2
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
3 // found in the LICENSE file.
5 cr.define('extensions', function() {
6   /**
7    * A confirmation overlay for disabling kiosk app bailout shortcut.
8    * @constructor
9    */
10   function KioskDisableBailoutConfirm() {
11   }
13   cr.addSingletonGetter(KioskDisableBailoutConfirm);
15   KioskDisableBailoutConfirm.prototype = {
16     /**
17      * Initialize the page.
18      */
19     initialize: function() {
20       var overlay = $('kiosk-disable-bailout-confirm-overlay');
21       cr.ui.overlay.setupOverlay(overlay);
22       cr.ui.overlay.globalInitialization();
23       overlay.addEventListener('cancelOverlay', this.handleCancel);
25       var el = $('kiosk-disable-bailout-shortcut');
26       el.addEventListener('change', this.handleDisableBailoutShortcutChange_);
28       $('kiosk-disable-bailout-confirm-button').onclick = function(e) {
29         extensions.ExtensionSettings.showOverlay($('kiosk-apps-page'));
30         chrome.send('setDisableBailoutShortcut', [true]);
31       };
32       $('kiosk-disable-bailout-cancel-button').onclick = this.handleCancel;
33     },
35     /** Handles overlay being canceled. */
36     handleCancel: function() {
37       extensions.ExtensionSettings.showOverlay($('kiosk-apps-page'));
38       $('kiosk-disable-bailout-shortcut').checked = false;
39     },
41     /**
42      * Custom change handler for the disable bailout shortcut checkbox.
43      * It blocks the underlying pref being changed and brings up confirmation
44      * alert to user.
45      * @private
46      */
47     handleDisableBailoutShortcutChange_: function() {
48       // Just set the pref if user un-checks the box.
49       if (!$('kiosk-disable-bailout-shortcut').checked) {
50         chrome.send('setDisableBailoutShortcut', [false]);
51         return false;
52       }
54       // Otherwise, show the confirmation overlay.
55       extensions.ExtensionSettings.showOverlay($(
56           'kiosk-disable-bailout-confirm-overlay'));
57       return true;
58     }
59   };
61   // Export
62   return {
63     KioskDisableBailoutConfirm: KioskDisableBailoutConfirm
64   };
65 });