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..fcab819e3979d4b6b8418fc7b815b9d6fa5ab934 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('enableVirtualKeyboardOverride', [visible]); |
}, |
isPinShown: function() { |
@@ -1871,23 +1879,66 @@ cr.define('login', function() { |
* @param {Event} e Pin change event. |
*/ |
handlePinChanged_: function(e) { |
- this.passwordElement.value = e.detail.pin; |
+ if (this.passwordElement.value != e.detail.pin) |
+ this.passwordElement.value = e.detail.pin; |
this.updateInput_(); |
}, |
/** |
+ * 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) { |
+ // Clear the text based on the caret location or selected region of the |
+ // password element. |
+ var selectionStart = this.passwordElement.selectionStart; |
+ var selectionEnd = this.passwordElement.selectionEnd; |
+ |
+ // If it is just a caret, remove the character infront of the caret. |
+ if (selectionStart == selectionEnd) |
+ selectionStart--; |
jdufault
2016/10/26 17:56:16
Like above, can we just send a backspace key event
sammiequon
2016/10/27 00:22:40
As per offline, this cannot be achieved.
|
+ this.passwordElement.value = |
+ this.passwordElement.value.substring(0, selectionStart) + |
+ this.passwordElement.value.substring(selectionEnd, |
+ this.passwordElement.value.length); |
+ |
+ // 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('enableVirtualKeyboardOverride', [false]); |
+ } |
+ }, |
+ |
+ /** |
* Handles click event on a user pod. |
* @param {Event} e Click event. |
*/ |