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 13a1c64d1ef3afee5b957db7f01ca5408c119855..d5191f570f437251fc33f5a9c1bb1ac17605178e 100644 |
--- a/ui/login/account_picker/user_pod_row.js |
+++ b/ui/login/account_picker/user_pod_row.js |
@@ -744,6 +744,13 @@ cr.define('login', function() { |
*/ |
fingerprintAuthenticated_: false, |
+ /** |
+ * True iff the pod can display the pin keyboard. The pin keyboard may not |
+ * always be displayed even if this is true, ie, if the virtual keyboard is |
+ * also being displayed. |
+ */ |
+ pinEnabled: false, |
+ |
/** @override */ |
decorate: function() { |
this.tabIndex = UserPodTabOrder.POD_INPUT; |
@@ -1225,10 +1232,6 @@ cr.define('login', function() { |
this.submitButton.classList.toggle('error-shown', visible); |
}, |
- toggleTransitions: function(enable) { |
- this.classList.toggle('flying-pin-pod', enable); |
- }, |
- |
updatePinClass_: function(element, enable) { |
element.classList.toggle('pin-enabled', enable); |
element.classList.toggle('pin-disabled', !enable); |
@@ -1242,6 +1245,10 @@ cr.define('login', function() { |
if (visible && Oobe.getInstance().virtualKeyboardShown) |
return; |
+ // Do not show pin keyboard if the pod does not have pin enabled. |
+ if (visible && !this.pinEnabled) |
+ return; |
+ |
var elements = this.getElementsByClassName('pin-tag'); |
for (var i = 0; i < elements.length; ++i) |
this.updatePinClass_(elements[i], visible); |
@@ -2850,15 +2857,6 @@ cr.define('login', function() { |
}, |
/** |
- * Enables or disables transitions on every pod instance. |
- * @param {boolean} enable |
- */ |
- toggleTransitions: function(enable) { |
- for (var i = 0; i < this.pods.length; ++i) |
- this.pods[i].toggleTransitions(enable); |
- }, |
- |
- /** |
* Performs visual changes on the user pod if there is an error. |
* @param {boolean} visible Whether to show or hide the display. |
*/ |
@@ -2872,7 +2870,7 @@ cr.define('login', function() { |
* @param {boolean} visible |
*/ |
setFocusedPodPinVisibility: function(visible) { |
- if (this.focusedPod_ && this.focusedPod_.user.showPin) |
+ if (this.focusedPod_) |
this.focusedPod_.setPinVisibility(visible); |
}, |
@@ -2894,21 +2892,60 @@ cr.define('login', function() { |
}, |
/** |
- * Remove the pin keyboard from the pod with the given |username|. |
+ * Enables or disables the pin keyboard for the given user. A disabled pin |
+ * keyboard will never be displayed. |
+ * |
+ * If the user's pod is focused, then enabling the pin keyboard will display |
+ * it; disabling the pin keyboard will hide it. |
+ * @param {!user} username |
xiyuan
2017/04/03 21:21:43
nit: {!user} -> {!string}
jdufault
2017/04/10 21:06:31
Done.
|
+ * @param {boolean} enabled |
+ */ |
+ setPinEnabled: function(username, enabled) { |
+ var pod = this.getPodWithUsername_(username); |
+ if (!pod) { |
+ console.error('Attempt to enable/disable pin keyboard of missing pod.'); |
+ return; |
+ } |
+ |
+ // Make sure to set |pinEnabled| before toggling visiblity to avoid |
+ // validation errors. |
+ pod.pinEnabled = enabled; |
+ |
+ if (this.focusedPod_ == pod) { |
+ if (enabled) { |
+ ensurePinKeyboardLoaded( |
+ this.setPinVisibility.bind(this, username, true)); |
+ } else { |
+ this.setPinVisibility(username, false); |
+ } |
+ } |
+ }, |
+ |
+ /** |
+ * Shows or hides the pin keyboard from the pod with the given |username|. |
+ * This is only a visibility change; the pin keyboard can be reshown. |
+ * |
+ * Use setPinEnabled if the pin keyboard should be disabled for the given |
+ * user. |
* @param {!user} username |
* @param {boolean} visible |
*/ |
- removePinKeyboard: function(username) { |
+ setPinVisibility: function(username, visible) { |
var pod = this.getPodWithUsername_(username); |
if (!pod) { |
- console.warn('Attempt to remove pin keyboard of missing pod.'); |
+ console.error('Attempt to show/hide pin keyboard of missing pod.'); |
+ return; |
+ } |
+ if (visible && pod.pinEnabled === false) { |
+ console.error('Attempt to show disabled pin keyboard'); |
return; |
} |
- // Remove the child, so that the virtual keyboard cannot bring it up |
- // again after three tries. |
- if (pod.pinContainer) |
- pod.removeChild(pod.pinContainer); |
- pod.setPinVisibility(false); |
+ if (visible && this.focusedPod_ != pod) { |
+ console.error('Attempt to show pin keyboard on non-focused pod'); |
+ return; |
+ } |
+ |
+ pod.setPinVisibility(visible); |
}, |
/** |