cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / login / oobe_screen_enable_kiosk.js
blob8bb2bb43bc5c6e92532913573da9fc857cd210c5
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 /**
6  * @fileoverview Oobe reset screen implementation.
7  */
9 login.createScreen('KioskEnableScreen', 'kiosk-enable', function() {
10   return {
11     EXTERNAL_API: ['enableKioskForTesting',
12                    'onCompleted'],
13     /**
14      * Header text of the screen.
15      * @type {string}
16      */
17     get header() {
18       return loadTimeData.getString('kioskEnableTitle');
19     },
21     /**
22      * Buttons in oobe wizard's button strip.
23      * @type {array} Array of Buttons.
24      */
25     get buttons() {
26       var buttons = [];
28       var confirmButton = this.ownerDocument.createElement('button');
29       confirmButton.id = 'kiosk-enable-button';
30       confirmButton.textContent =
31         loadTimeData.getString('kioskEnableButton');
32       confirmButton.addEventListener('click', function(e) {
33         chrome.send('kioskOnEnable');
34         e.stopPropagation();
35       });
36       buttons.push(confirmButton);
38       var cancelButton = this.ownerDocument.createElement('button');
39       cancelButton.id = 'kiosk-cancel-button';
40       cancelButton.textContent =
41           loadTimeData.getString('kioskCancelButton');
42       cancelButton.addEventListener('click', function(e) {
43         chrome.send('kioskOnClose');
44         e.stopPropagation();
45       });
46       buttons.push(cancelButton);
48       var okButton = this.ownerDocument.createElement('button');
49       okButton.id = 'kiosk-ok-button';
50       okButton.hidden = true;
51       okButton.textContent =
52           loadTimeData.getString('kioskOKButton');
53       okButton.addEventListener('click', function(e) {
54         chrome.send('kioskOnClose');
55         e.stopPropagation();
56       });
57       buttons.push(okButton);
58       return buttons;
59     },
61     /**
62      * Event handler invoked when the page is shown and ready.
63      */
64     onBeforeShow: function() {
65       $('kiosk-enable-button').hidden = false;
66       $('kiosk-cancel-button').hidden = false;
67       $('kiosk-ok-button').hidden = true;
68       $('kiosk-enable-details').textContent =
69           loadTimeData.getString('kioskEnableWarningDetails');
70     },
72     /**
73      * Returns a control which should receive an initial focus.
74      */
75     get defaultControl() {
76       return $('kiosk-cancel-button');
77     },
79     /**
80      * Cancels the reset and drops the user back to the login screen.
81      */
82     cancel: function() {
83       chrome.send('kioskOnClose');
84     },
86     /**
87      * Initiates enable/cancel response for testing.
88      * @param {boolean} confirm True if the screen should confirm auto-launch.
89      */
90     enableKioskForTesting: function(confirm) {
91       var button = confirm ? $('kiosk-enable-button') :
92                              $('kiosk-cancel-button');
93       var clickEvent = cr.doc.createEvent('Event');
94       clickEvent.initEvent('click', true, true);
95       button.dispatchEvent(clickEvent);
96     },
98     /**
99      * Updates completion message on the screen.
100      * @param {boolean} success True if consumer kiosk was successfully enabled.
101      */
102     onCompleted: function(success) {
103       $('kiosk-enable-button').hidden = true;
104       $('kiosk-cancel-button').hidden = true;
105       $('kiosk-ok-button').hidden = false;
106       $('kiosk-enable-details').textContent =
107         loadTimeData.getString(success ? 'kioskEnableSuccessMsg' :
108                                          'kioskEnableErrorMsg');
109     }
110   };