Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2901)

Unified Diff: chrome/browser/resources/settings/people_page/password_prompt_dialog.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/people_page/password_prompt_dialog.js
diff --git a/chrome/browser/resources/settings/people_page/password_prompt_dialog.js b/chrome/browser/resources/settings/people_page/password_prompt_dialog.js
index 0ff12bbb62bfcd541e3a35df50a34ad42d94609b..594e2a845acc85e3172bef0bf07b40f0351a7174 100644
--- a/chrome/browser/resources/settings/people_page/password_prompt_dialog.js
+++ b/chrome/browser/resources/settings/people_page/password_prompt_dialog.js
@@ -25,189 +25,185 @@
*/
(function() {
-'use strict';
-
-/** @const */ var PASSWORD_ACTIVE_DURATION_MS = 10 * 60 * 1000; // Ten minutes.
-
-Polymer({
- is: 'settings-password-prompt-dialog',
-
- properties: {
- /**
- * A wrapper around chrome.quickUnlockPrivate.setModes with the account
- * password already supplied. If this is null, the authentication screen
- * needs to be redisplayed. This property will be cleared after
- * |this.passwordActiveDurationMs_| milliseconds.
- */
- setModes: {
- type: Object,
- notify: true
+ 'use strict';
+
+ /** @const */ var PASSWORD_ACTIVE_DURATION_MS =
+ 10 * 60 * 1000; // Ten minutes.
+
+ Polymer({
+ is: 'settings-password-prompt-dialog',
+
+ properties: {
+ /**
+ * A wrapper around chrome.quickUnlockPrivate.setModes with the account
+ * password already supplied. If this is null, the authentication screen
+ * needs to be redisplayed. This property will be cleared after
+ * |this.passwordActiveDurationMs_| milliseconds.
+ */
+ setModes: {type: Object, notify: true},
+
+ /**
+ * The actual value of the password field. This is cleared whenever the
+ * authentication screen is not displayed so that the user's password is
+ * not
+ * easily available to an attacker. The actual password is stored as an
+ * captured closure variable inside of setModes.
+ * @private
+ */
+ password_: {type: String, observer: 'onPasswordChanged_'},
+
+ /**
+ * Helper property which marks password as valid/invalid.
+ * @private
+ */
+ passwordInvalid_: Boolean,
+
+ /**
+ * Interface for chrome.quickUnlockPrivate calls. May be overriden by
+ * tests.
+ * @private
+ */
+ quickUnlockPrivate_: {type: Object, value: chrome.quickUnlockPrivate},
+
+ /**
+ * writeUma_ is a function that handles writing uma stats. It may be
+ * overridden for tests.
+ *
+ * @type {Function}
+ * @private
+ */
+ writeUma_: {
+ type: Object,
+ value: function() {
+ return settings.recordLockScreenProgress;
+ }
+ },
+
+ /**
+ * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests.
+ * @private
+ */
+ passwordActiveDurationMs_:
+ {type: Number, value: PASSWORD_ACTIVE_DURATION_MS},
},
/**
- * The actual value of the password field. This is cleared whenever the
- * authentication screen is not displayed so that the user's password is not
- * easily available to an attacker. The actual password is stored as an
- * captured closure variable inside of setModes.
- * @private
+ * Open up the dialog. This will wait until the dialog has loaded before
+ * opening it.
*/
- password_: {
- type: String,
- observer: 'onPasswordChanged_'
+ open: function() {
+ // Wait until the dialog is attached to the DOM before trying to open it.
+ var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog);
+ if (!dialog.isConnected) {
+ setTimeout(this.open.bind(this));
+ return;
+ }
+
+ if (this.$.dialog.open)
+ return;
+
+ this.writeUma_(LockScreenProgress.START_SCREEN_LOCK);
+ this.$.dialog.showModal();
},
- /**
- * Helper property which marks password as valid/invalid.
- * @private
- */
- passwordInvalid_: Boolean,
+ /** @private */
+ onCancelTap_: function() {
+ if (this.$.dialog.open)
+ this.$.dialog.close();
+ },
/**
- * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests.
+ * Called whenever the dialog is closed.
* @private
*/
- quickUnlockPrivate_: {
- type: Object,
- value: chrome.quickUnlockPrivate
+ onClose_: function() {
+ this.password_ = '';
},
- /**
- * writeUma_ is a function that handles writing uma stats. It may be
- * overridden for tests.
- *
- * @type {Function}
- * @private
- */
- writeUma_: {
- type: Object,
- value: function() { return settings.recordLockScreenProgress; }
+ /** @private */
+ onKeydown_: function(e) {
+ if (e.key == 'Enter')
+ this.submitPassword_();
},
/**
- * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests.
+ * Run the account password check.
* @private
*/
- passwordActiveDurationMs_: {
- type: Number,
- value: PASSWORD_ACTIVE_DURATION_MS
- },
- },
-
- /**
- * Open up the dialog. This will wait until the dialog has loaded before
- * opening it.
- */
- open: function() {
- // Wait until the dialog is attached to the DOM before trying to open it.
- var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog);
- if (!dialog.isConnected) {
- setTimeout(this.open.bind(this));
- return;
- }
-
- if (this.$.dialog.open)
- return;
-
- this.writeUma_(LockScreenProgress.START_SCREEN_LOCK);
- this.$.dialog.showModal();
- },
-
- /** @private */
- onCancelTap_: function() {
- if (this.$.dialog.open)
- this.$.dialog.close();
- },
-
- /**
- * Called whenever the dialog is closed.
- * @private
- */
- onClose_: function() {
- this.password_ = '';
- },
-
- /** @private */
- onKeydown_: function(e) {
- if (e.key == 'Enter')
- this.submitPassword_();
- },
-
- /**
- * Run the account password check.
- * @private
- */
- submitPassword_: function() {
- clearTimeout(this.clearAccountPasswordTimeout_);
-
- // The user might have started entering a password and then deleted it all.
- // Do not submit/show an error in this case.
- if (!this.password_) {
- this.passwordInvalid_ = false;
- return;
- }
+ submitPassword_: function() {
+ clearTimeout(this.clearAccountPasswordTimeout_);
+
+ // The user might have started entering a password and then deleted it
+ // all.
+ // Do not submit/show an error in this case.
+ if (!this.password_) {
+ this.passwordInvalid_ = false;
+ return;
+ }
- function onPasswordChecked(valid) {
- // The password might have been cleared during the duration of the
- // getActiveModes call.
- this.passwordInvalid_ = !valid && !!this.password_;
-
- if (valid) {
- // Create the |this.setModes| closure and automatically clear it after
- // |this.passwordActiveDurationMs_|.
- var password = this.password_;
- this.password_ = '';
-
- this.setModes = function(modes, credentials, onComplete) {
- this.quickUnlockPrivate_.setModes(
- password, modes, credentials, onComplete);
- }.bind(this);
-
- function clearSetModes() {
- // Reset the password so that any cached references to this.setModes
- // will fail.
- password = '';
- this.setModes = null;
+ function onPasswordChecked(valid) {
+ // The password might have been cleared during the duration of the
+ // getActiveModes call.
+ this.passwordInvalid_ = !valid && !!this.password_;
+
+ if (valid) {
+ // Create the |this.setModes| closure and automatically clear it after
+ // |this.passwordActiveDurationMs_|.
+ var password = this.password_;
+ this.password_ = '';
+
+ this.setModes = function(modes, credentials, onComplete) {
+ this.quickUnlockPrivate_.setModes(
+ password, modes, credentials, onComplete);
+ }.bind(this);
+
+ function clearSetModes() {
+ // Reset the password so that any cached references to this.setModes
+ // will fail.
+ password = '';
+ this.setModes = null;
+ }
+
+ this.clearAccountPasswordTimeout_ = setTimeout(
+ clearSetModes.bind(this), this.passwordActiveDurationMs_);
+
+ // Clear stored password state and close the dialog.
+ this.password_ = '';
+ if (this.$.dialog.open)
+ this.$.dialog.close();
+
+ this.writeUma_(LockScreenProgress.ENTER_PASSWORD_CORRECTLY);
}
+ }
- this.clearAccountPasswordTimeout_ = setTimeout(
- clearSetModes.bind(this), this.passwordActiveDurationMs_);
+ this.checkAccountPassword_(onPasswordChecked.bind(this));
+ },
- // Clear stored password state and close the dialog.
- this.password_ = '';
- if (this.$.dialog.open)
- this.$.dialog.close();
+ /** @private */
+ onPasswordChanged_: function() {
+ this.passwordInvalid_ = false;
+ },
- this.writeUma_(LockScreenProgress.ENTER_PASSWORD_CORRECTLY);
- }
- }
+ /** @private */
+ enableConfirm_: function() {
+ return !!this.password_ && !this.passwordInvalid_;
+ },
- this.checkAccountPassword_(onPasswordChecked.bind(this));
- },
-
- /** @private */
- onPasswordChanged_: function() {
- this.passwordInvalid_ = false;
- },
-
- /** @private */
- enableConfirm_: function() {
- return !!this.password_ && !this.passwordInvalid_;
- },
-
- /**
- * Helper method that checks if the current password is valid.
- * @param {function(boolean):void} onCheck
- */
- checkAccountPassword_: function(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(
- this.password_, modes, credentials, onCheck);
- }.bind(this));
- }
-});
+ /**
+ * Helper method that checks if the current password is valid.
+ * @param {function(boolean):void} onCheck
+ */
+ checkAccountPassword_: function(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(
+ this.password_, modes, credentials, onCheck);
+ }.bind(this));
+ }
+ });
})();

Powered by Google App Engine
This is Rietveld 408576698