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