OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 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. | |
4 | |
5 /** | |
6 * @fileoverview Enable developer features screen implementation. | |
7 */ | |
8 | |
9 login.createScreen('EnableDebuggingScreen', 'debugging', function() { | |
10 return { | |
11 | |
12 /* Possible UI states of the reset screen. */ | |
Nikita (slow)
2014/11/05 17:51:27
nit: debugging screen
zel
2014/11/11 01:02:28
Done.
| |
13 UI_STATE: { | |
14 ERROR: -1, | |
15 NONE: 0, | |
16 REMOVE_PROTECTION: 1, | |
17 SETUP: 2, | |
18 WAIT: 3, | |
19 DONE: 4 | |
20 }, | |
21 | |
22 EXTERNAL_API: [ | |
23 'updateState' | |
24 ], | |
25 | |
26 /** @override */ | |
27 decorate: function() { | |
28 $('enable-debugging-help-link').addEventListener('click', | |
29 function(event) { | |
30 chrome.send('enableDebuggingOnLearnMore'); | |
31 }); | |
32 | |
33 var password = $('enable-debugging-password'); | |
34 var password2 = $('enable-debugging-password2'); | |
35 $('enable-debugging-password').addEventListener( | |
36 'input', this.onPasswordChanged_.bind(this)); | |
37 $('enable-debugging-password2').addEventListener( | |
38 'input', this.onPasswordChanged_.bind(this)); | |
39 password.placeholder = | |
40 loadTimeData.getString('enableDebuggingPasswordLabel'); | |
Nikita (slow)
2014/11/05 17:51:27
nit: 4 spaces indent
zel
2014/11/11 01:02:28
Done.
| |
41 password2.placeholder = | |
42 loadTimeData.getString('enableDebuggingConfirmPasswordLabel'); | |
Nikita (slow)
2014/11/05 17:51:27
nit: 4 spaces indent
zel
2014/11/11 01:02:28
Done.
| |
43 }, | |
44 | |
45 /** | |
46 * Header text of the screen. | |
47 * @type {string} | |
48 */ | |
49 get header() { | |
50 return loadTimeData.getString('enableDebuggingScreenTitle'); | |
51 }, | |
52 | |
53 /** | |
54 * Buttons in oobe wizard's button strip. | |
55 * @type {array} Array of Buttons. | |
56 */ | |
57 get buttons() { | |
58 var buttons = []; | |
59 var rootfsRemoveButton = this.ownerDocument.createElement('button'); | |
60 rootfsRemoveButton.id = 'debugging-remove-protection-button'; | |
61 rootfsRemoveButton.textContent = | |
62 loadTimeData.getString('enableDebuggingRemoveButton'); | |
63 rootfsRemoveButton.addEventListener('click', function(e) { | |
64 chrome.send('enableDebuggingOnRemoveRootFSProtection'); | |
65 e.stopPropagation(); | |
66 }); | |
67 buttons.push(rootfsRemoveButton); | |
68 | |
69 var enableButton = this.ownerDocument.createElement('button'); | |
70 enableButton.id = 'debugging-enable-button'; | |
71 enableButton.textContent = | |
72 loadTimeData.getString('enableDebuggingEnableButton'); | |
73 enableButton.addEventListener('click', function(e) { | |
74 chrome.send('enableDebuggingOnSetup', | |
75 [$('enable-debugging-password').value]); | |
76 e.stopPropagation(); | |
77 }); | |
78 buttons.push(enableButton); | |
79 | |
80 var cancelButton = this.ownerDocument.createElement('button'); | |
81 cancelButton.id = 'debugging-cancel-button'; | |
82 cancelButton.textContent = | |
83 loadTimeData.getString('enableDebuggingCancelButton'); | |
Nikita (slow)
2014/11/05 17:51:27
nit: 4 spaces indent
zel
2014/11/11 01:02:28
Done.
| |
84 cancelButton.addEventListener('click', function(e) { | |
85 chrome.send('enableDebuggingOnCancel'); | |
86 e.stopPropagation(); | |
87 }); | |
88 buttons.push(cancelButton); | |
89 | |
90 var okButton = this.ownerDocument.createElement('button'); | |
91 okButton.id = 'debugging-ok-button'; | |
92 okButton.textContent = | |
93 loadTimeData.getString('enableDebuggingOKButton'); | |
94 okButton.addEventListener('click', function(e) { | |
95 chrome.send('enableDebuggingOnDone'); | |
96 e.stopPropagation(); | |
97 }); | |
98 buttons.push(okButton); | |
99 | |
100 return buttons; | |
101 }, | |
102 | |
103 /** | |
104 * Returns a control which should receive an initial focus. | |
105 */ | |
106 get defaultControl() { | |
107 if (this.state_ == this.UI_STATE.REMOVE_PROTECTION) | |
108 return $('debugging-remove-protection-button'); | |
109 else if (this.state_ == this.UI_STATE.SETUP) | |
110 return $('enable-debugging-password'); | |
111 else if (this.state_ == this.UI_STATE.DONE) | |
112 return $('debugging-ok-button'); | |
113 | |
114 return $('debugging-cancel-button'); | |
115 }, | |
116 | |
117 /** | |
118 * Cancels the reset and drops the user back to the login screen. | |
Nikita (slow)
2014/11/05 17:51:27
nit: Cancels the debugging screen
zel
2014/11/11 01:02:28
Done.
| |
119 */ | |
120 cancel: function() { | |
121 chrome.send('enableDebuggingOnCancel'); | |
122 }, | |
123 | |
124 /** | |
125 * Event handler that is invoked just before the screen in shown. | |
126 * @param {Object} data Screen init payload. | |
127 */ | |
128 onBeforeShow: function(data) { | |
129 this.setDialogView_(this.UI_STATE.NONE); | |
130 | |
131 if (data === undefined) | |
132 return; | |
133 | |
134 if (!('isOfficialBuild' in data && data['isOfficialBuild'])) | |
135 $('enable-debugging-help-link').hidden = true; | |
136 }, | |
137 | |
138 onPasswordChanged_: function() { | |
139 var enableButton = $('debugging-enable-button'); | |
140 var password = $('enable-debugging-password'); | |
141 var password2 = $('enable-debugging-password2'); | |
142 var pwd = password.value; | |
143 var pwd2 = password2.value; | |
144 enableButton.disabled = !((pwd.length == 0 && pwd2.length == 0) || | |
145 (pwd == pwd2 && pwd.length >= 4)); | |
146 }, | |
147 | |
148 /** | |
149 * Sets css style for corresponding state of the screen. | |
150 * @param {number} state. | |
151 * @private | |
152 */ | |
153 setDialogView_: function(state) { | |
154 this.state_ = state; | |
155 this.classList.toggle('remove-protection-view', | |
156 state == this.UI_STATE.REMOVE_PROTECTION); | |
157 this.classList.toggle('setup-view', state == this.UI_STATE.SETUP); | |
158 this.classList.toggle('wait-view', state == this.UI_STATE.WAIT); | |
159 this.classList.toggle('done-view', state == this.UI_STATE.DONE); | |
160 this.classList.toggle('error-view', state == this.UI_STATE.ERROR); | |
161 }, | |
162 | |
163 updateState: function(state) { | |
164 this.setDialogView_(state); | |
165 } | |
166 }; | |
167 }); | |
OLD | NEW |