Index: chrome/browser/resources/settings/people_page/quick_unlock_authenticate.js |
diff --git a/chrome/browser/resources/settings/people_page/quick_unlock_authenticate.js b/chrome/browser/resources/settings/people_page/quick_unlock_authenticate.js |
index 97d3e664c5422eaf43310249d8959cd27fec6dda..f54b1087c0e3163b229ca6bcef86afb094ce32da 100644 |
--- a/chrome/browser/resources/settings/people_page/quick_unlock_authenticate.js |
+++ b/chrome/browser/resources/settings/people_page/quick_unlock_authenticate.js |
@@ -28,21 +28,6 @@ |
/** @const */ var PASSWORD_ACTIVE_DURATION_MS = 10 * 60 * 1000; // Ten minutes. |
/** @const */ var AUTOSUBMIT_DELAY_MS = 500; // .5 seconds |
-/** |
- * Helper method that checks if |password| is valid. |
- * @param {string} password |
- * @param {function(boolean):void} onCheck |
- */ |
-function checkAccountPassword_(password, onCheck) { |
- // We check the account password by trying to update the active set of quick |
- // unlock modes without changing any credentials. |
- chrome.quickUnlockPrivate.getActiveModes(function(modes) { |
- var credentials = |
- /** @type {!Array<string>} */ (Array(modes.length).fill('')); |
- chrome.quickUnlockPrivate.setModes(password, modes, credentials, onCheck); |
- }); |
-} |
- |
Polymer({ |
is: 'settings-quick-unlock-authenticate', |
@@ -80,7 +65,35 @@ Polymer({ |
* Helper property which marks password as valid/invalid. |
* @private |
*/ |
- passwordInvalid_: Boolean |
+ passwordInvalid_: Boolean, |
+ |
+ /** |
+ * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests. |
+ * @private |
+ * @type {QuickUnlockPrivate} |
+ */ |
+ quickUnlockPrivate_: { |
+ type: Object, |
+ value: chrome.quickUnlockPrivate |
+ }, |
+ |
+ /** |
+ * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests. |
+ * @private |
+ */ |
+ passwordActiveDurationMs_: { |
+ type: Number, |
+ value: PASSWORD_ACTIVE_DURATION_MS |
+ }, |
+ |
+ /** |
+ * AUTOSUBMIT_DELAY_MS value. May be overridden by tests. |
+ * @private |
+ */ |
+ autosubmitDelayMs_: { |
+ type: Number, |
+ value: AUTOSUBMIT_DELAY_MS |
+ } |
}, |
observers: [ |
@@ -105,7 +118,7 @@ Polymer({ |
startDelayedPasswordCheck_: function() { |
clearTimeout(this.delayedPasswordCheckTimeout_); |
this.delayedPasswordCheckTimeout_ = |
- setTimeout(this.checkPasswordNow_.bind(this), AUTOSUBMIT_DELAY_MS); |
+ setTimeout(this.checkPasswordNow_.bind(this), this.autosubmitDelayMs_); |
}, |
/** |
@@ -131,14 +144,14 @@ Polymer({ |
if (valid) { |
// Create the |this.setModes| closure and automatically clear it after |
- // |PASSWORD_ACTIVE_DURATION_MS|. |
+ // |this.passwordActiveDurationMs_|. |
var password = this.password_; |
this.password_ = ''; |
this.setModes = function(modes, credentials, onComplete) { |
- chrome.quickUnlockPrivate.setModes( |
+ this.quickUnlockPrivate_.setModes( |
password, modes, credentials, onComplete); |
- }; |
+ }.bind(this); |
function clearSetModes() { |
// Reset the password so that any cached references to this.setModes |
@@ -148,7 +161,7 @@ Polymer({ |
} |
this.clearAccountPasswordTimeout_ = setTimeout( |
- clearSetModes.bind(this), PASSWORD_ACTIVE_DURATION_MS); |
+ clearSetModes.bind(this), this.passwordActiveDurationMs_); |
this.currentRoute = { |
page: 'basic', |
@@ -158,7 +171,22 @@ Polymer({ |
} |
} |
- checkAccountPassword_(this.password_, onPasswordChecked.bind(this)); |
+ this.checkAccountPassword_(this.password_, onPasswordChecked.bind(this)); |
tommycli
2016/07/18 20:47:24
Is this only called in one place? If so, why not i
jdufault
2016/07/19 00:11:07
The way we check for account password is a bit con
tommycli
2016/07/19 21:27:12
Okay that makes sense.
|
+ }, |
+ |
+ /** |
+ * Helper method that checks if |password| is valid. |
+ * @param {string} password |
+ * @param {function(boolean):void} onCheck |
+ */ |
+ checkAccountPassword_: function(password, onCheck) { |
+ // We check the account password by trying to update the active set of quick |
+ // unlock modes without changing any credentials. |
+ this.quickUnlockPrivate_.getActiveModes(function(modes) { |
+ var credentials = |
+ /** @type {!Array<string>} */ (Array(modes.length).fill('')); |
+ this.quickUnlockPrivate_.setModes(password, modes, credentials, onCheck); |
+ }.bind(this)); |
} |
}); |