Chromium Code Reviews| Index: ui/login/account_picker/user_pod_row.js |
| diff --git a/ui/login/account_picker/user_pod_row.js b/ui/login/account_picker/user_pod_row.js |
| index 54df155a8cf1dfdc590cfccf2502624ad46c25ee..213e657cd656dcf22342e44966bf63129a72bc38 100644 |
| --- a/ui/login/account_picker/user_pod_row.js |
| +++ b/ui/login/account_picker/user_pod_row.js |
| @@ -716,6 +716,10 @@ cr.define('login', function() { |
| if (this.pinKeyboard) { |
| this.pinKeyboard.addEventListener('pin-change', |
| this.handlePinChanged_.bind(this)); |
| + this.pinKeyboard.addEventListener('pin-focus', |
| + this.handlePinFocused_.bind(this)); |
| + this.pinKeyboard.addEventListener('pin-clear', |
| + this.handlePinCleared_.bind(this)); |
| } |
| this.actionBoxAreaElement.addEventListener('mousedown', |
| @@ -755,6 +759,8 @@ cr.define('login', function() { |
| this.handlePasswordKeyPress_.bind(this)); |
| this.passwordElement.addEventListener('input', |
| this.handleInputChanged_.bind(this)); |
| + this.passwordElement.addEventListener('mouseup', |
| + this.handleInputMouseUp_.bind(this)); |
| if (this.submitButton) { |
| this.submitButton.addEventListener('click', |
| @@ -1167,6 +1173,8 @@ cr.define('login', function() { |
| // Change the password placeholder based on pin keyboard visibility. |
| this.passwordElement.placeholder = loadTimeData.getString(visible ? |
| 'pinKeyboardPlaceholderPinPassword' : 'passwordHint'); |
| + |
| + chrome.send('setForceDisableVirtualKeyboard', [visible]); |
| }, |
| isPinShown: function() { |
| @@ -1876,18 +1884,59 @@ cr.define('login', function() { |
| }, |
| /** |
| + * Handles pin focus event from the pin keyboard. |
| + * @param {Event} e Pin focus event. |
| + */ |
| + handlePinFocused_: function(e) { |
| + this.mainInput.focus(); |
| + }, |
| + |
| + /** |
| + * Handles pin clear event from the pin keyboard. |
| + * @param {Event} e Pin clear event. |
| + */ |
| + handlePinCleared_: function(e) { |
|
jdufault
2016/10/31 22:28:49
Could this be handled by the pin-change event?
Wh
sammiequon
2016/11/02 18:08:41
Done.
|
| + // Clear the text based on the caret location or selected region of the |
|
jdufault
2016/10/31 22:28:49
Add these comments in the other implementation.
sammiequon
2016/11/02 18:07:54
Done.
|
| + // password element. |
| + var selectionStart = this.passwordElement.selectionStart; |
| + var selectionEnd = this.passwordElement.selectionEnd; |
| + |
| + // If it is just a caret, remove the character in front of the caret. |
| + if (selectionStart == selectionEnd) |
| + selectionStart--; |
| + this.passwordElement.value = |
| + this.passwordElement.value.substring(0, selectionStart) + |
| + this.passwordElement.value.substring(selectionEnd); |
| + |
| + // Move the caret or selected region to the correct new place. |
| + this.passwordElement.setSelectionRange(selectionStart, selectionStart); |
| + this.handleInputChanged_(e); |
| + }, |
| + |
| + /** |
| * Handles input event on the password element. |
| * @param {Event} e Input event. |
| */ |
| handleInputChanged_: function(e) { |
| if (this.pinKeyboard) |
| this.pinKeyboard.value = this.passwordElement.value; |
| - if (this.submitButton) |
| - this.submitButton.disabled = this.passwordElement.value.length <= 0; |
| this.updateInput_(); |
| }, |
| /** |
| + * Handles mouse up event on the password element. |
| + * @param {Event} e Mouse up event. |
| + */ |
| + handleInputMouseUp_: function(e) { |
| + // If the PIN keyboard is shown and the user clicks on the password |
| + // element, the virtual keyboard should pop up if it is enabled, so we |
| + // must disable the virtual keyboard override. |
| + if (this.isPinShown()) { |
| + chrome.send('setForceDisableVirtualKeyboard', [false]); |
| + } |
| + }, |
| + |
| + /** |
| * Handles click event on a user pod. |
| * @param {Event} e Click event. |
| */ |