Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1618)

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_enable_debugging.js

Issue 539273002: Added UI to enable debugging features on CrOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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. */
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 },
40
41 /**
42 * Header text of the screen.
43 * @type {string}
44 */
45 get header() {
46 return loadTimeData.getString('enableDebuggingScreenTitle');
47 },
48
49 /**
50 * Buttons in oobe wizard's button strip.
51 * @type {array} Array of Buttons.
52 */
53 get buttons() {
54 var buttons = [];
55 var rootfsRemoveButton = this.ownerDocument.createElement('button');
56 rootfsRemoveButton.id = 'debugging-remove-protection-button';
57 rootfsRemoveButton.textContent =
58 loadTimeData.getString('enableDebuggingRemoveButton');
59 rootfsRemoveButton.addEventListener('click', function(e) {
60 chrome.send('enableDebuggingOnRemoveRootFSProtection');
61 e.stopPropagation();
62 });
63 buttons.push(rootfsRemoveButton);
64
65 var enableButton = this.ownerDocument.createElement('button');
66 enableButton.id = 'debugging-enable-button';
67 enableButton.textContent =
68 loadTimeData.getString('enableDebuggingEnableButton');
69 enableButton.addEventListener('click', function(e) {
70 chrome.send('enableDebuggingOnSetup',
71 [$('enable-debugging-password').value]);
72 e.stopPropagation();
73 });
74 buttons.push(enableButton);
75
76 var cancelButton = this.ownerDocument.createElement('button');
77 cancelButton.id = 'debugging-cancel-button';
78 cancelButton.textContent =
79 loadTimeData.getString('enableDebuggingCancelButton');
80 cancelButton.addEventListener('click', function(e) {
81 chrome.send('enableDebuggingOnCancel');
82 e.stopPropagation();
83 });
84 buttons.push(cancelButton);
85
86 var okButton = this.ownerDocument.createElement('button');
87 okButton.id = 'debugging-ok-button';
88 okButton.textContent =
89 loadTimeData.getString('enableDebuggingOKButton');
90 okButton.addEventListener('click', function(e) {
91 chrome.send('enableDebuggingOnDone');
92 e.stopPropagation();
93 });
94 buttons.push(okButton);
95
96 return buttons;
97 },
98
99 /**
100 * Returns a control which should receive an initial focus.
101 */
102 get defaultControl() {
103 if (this.state_ == this.UI_STATE.REMOVE_PROTECTION)
104 return $('debugging-remove-protection-button');
105 else if (this.state_ == this.UI_STATE.SETUP)
106 return $('enable-debugging-password');
107 else if (this.state_ == this.UI_STATE.DONE)
108 return $('debugging-ok-button');
109
110 return $('debugging-cancel-button');
111 },
112
113 /**
114 * Cancels the reset and drops the user back to the login screen.
115 */
116 cancel: function() {
117 chrome.send('enableDebuggingOnCancel');
118 },
119
120 /**
121 * Event handler that is invoked just before the screen in shown.
122 * @param {Object} data Screen init payload.
123 */
124 onBeforeShow: function(data) {
125 this.setDialogView_(this.UI_STATE.NONE);
126
127 if (data === undefined)
128 return;
129
130 if (!('isOfficialBuild' in data && data['isOfficialBuild']))
131 $('enable-debugging-help-link').hidden = true;
132 },
133
134 onPasswordChanged_: function() {
135 var enableButton = $('debugging-enable-button');
136 var password = $('enable-debugging-password');
137 var password2 = $('enable-debugging-password2');
138 var pwd = password.value;
139 var pwd2 = password2.value;
140 enableButton.disabled = !((pwd.length == 0 && pwd2.length == 0) ||
141 (pwd == pwd2 && pwd.length >= 4));
142 },
143
144 /**
145 * Sets css style for corresponding state of the screen.
146 * @param {number} state.
147 * @private
148 */
149 setDialogView_: function(state) {
150 this.state_ = state;
151 this.classList.toggle('remove-protection-view',
152 state == this.UI_STATE.REMOVE_PROTECTION);
153 this.classList.toggle('setup-view', state == this.UI_STATE.SETUP);
154 this.classList.toggle('wait-view', state == this.UI_STATE.WAIT);
155 this.classList.toggle('done-view', state == this.UI_STATE.DONE);
156 this.classList.toggle('error-view', state == this.UI_STATE.ERROR);
157 },
158
159 updateState: function(state) {
160 this.setDialogView_(state);
161 }
162 };
163 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698