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

Unified Diff: chrome/browser/resources/settings/people_page/setup_pin_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/setup_pin_dialog.js
diff --git a/chrome/browser/resources/settings/people_page/setup_pin_dialog.js b/chrome/browser/resources/settings/people_page/setup_pin_dialog.js
index 428b5ae7f98093be157898f23b5dfa1c5939158d..3fb4f4a28ef97fd271ca5671dbac22217197bac9 100644
--- a/chrome/browser/resources/settings/people_page/setup_pin_dialog.js
+++ b/chrome/browser/resources/settings/people_page/setup_pin_dialog.js
@@ -13,307 +13,301 @@
*/
(function() {
-'use strict';
+ 'use strict';
-/**
- * Keep in sync with the string keys provided by settings.
- * @enum {string}
- */
-var MessageType = {
- TOO_SHORT: 'configurePinTooShort',
- TOO_LONG: 'configurePinTooLong',
- TOO_WEAK: 'configurePinWeakPin',
- MISMATCH: 'configurePinMismatched'
-};
+ /**
+ * Keep in sync with the string keys provided by settings.
+ * @enum {string}
+ */
+ var MessageType = {
+ TOO_SHORT: 'configurePinTooShort',
+ TOO_LONG: 'configurePinTooLong',
+ TOO_WEAK: 'configurePinWeakPin',
+ MISMATCH: 'configurePinMismatched'
+ };
+
+ /** @enum {string} */
+ var ProblemType = {WARNING: 'warning', ERROR: 'error'};
+
+ Polymer({
+ is: 'settings-setup-pin-dialog',
+
+ behaviors: [I18nBehavior],
+
+ properties: {
+ /**
+ * The current PIN keyboard value.
+ * @private
+ */
+ pinKeyboardValue_: String,
+
+ /**
+ * Stores the initial PIN value so it can be confirmed.
+ * @private
+ */
+ initialPin_: String,
+
+ /**
+ * The actual problem message to display.
+ * @private
+ */
+ problemMessage_: String,
+
+ /**
+ * The type of problem class to show (warning or error).
+ */
+ problemClass_: String,
+
+ /**
+ * Should the step-specific submit button be displayed?
+ * @private
+ */
+ enableSubmit_: Boolean,
+
+ /**
+ * 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;
+ }
+ },
+
+ /**
+ * The current step/subpage we are on.
+ * @private
+ */
+ isConfirmStep_: {type: Boolean, value: false},
+
+ /**
+ * Interface for chrome.quickUnlockPrivate calls. May be overriden by
+ * tests.
+ * @private
+ */
+ quickUnlockPrivate_: {type: Object, value: chrome.quickUnlockPrivate},
+ },
-/** @enum {string} */
-var ProblemType = {
- WARNING: 'warning',
- ERROR: 'error'
-};
+ /** @override */
+ attached: function() {
+ this.resetState_();
+ },
-Polymer({
- is: 'settings-setup-pin-dialog',
+ open: function() {
+ this.$.dialog.showModal();
+ this.$.pinKeyboard.focus();
+ },
- behaviors: [I18nBehavior],
+ close: function() {
+ if (this.$.dialog.open)
+ this.$.dialog.close();
- properties: {
- /**
- * The current PIN keyboard value.
- * @private
- */
- pinKeyboardValue_: String,
+ this.resetState_();
+ },
/**
- * Stores the initial PIN value so it can be confirmed.
+ * Resets the element to the initial state.
* @private
*/
- initialPin_: String,
+ resetState_: function() {
+ this.initialPin_ = '';
+ this.pinKeyboardValue_ = '';
+ this.enableSubmit_ = false;
+ this.isConfirmStep_ = false;
+ this.hideProblem_();
+ this.onPinChange_();
+ },
- /**
- * The actual problem message to display.
- * @private
- */
- problemMessage_: String,
+ /** @private */
+ onCancelTap_: function() {
+ this.resetState_();
+ this.$.dialog.close();
+ },
/**
- * The type of problem class to show (warning or error).
- */
- problemClass_: String,
+ * Returns true if the PIN is ready to be changed to a new value.
+ * @private
+ * @return {boolean}
+ */
+ canSubmit_: function() {
+ return this.initialPin_ == this.pinKeyboardValue_;
+ },
/**
- * Should the step-specific submit button be displayed?
+ * Handles writting the appropriate message to |problemMessage_|.
* @private
+ * @param {string} messageId
+ * @param {chrome.quickUnlockPrivate.CredentialRequirements} requirements
+ * The requirements received from getCredentialRequirements.
*/
- enableSubmit_: Boolean,
+ processPinRequirements_: function(messageId, requirements) {
+ var additionalInformation = '';
+ switch (messageId) {
+ case MessageType.TOO_SHORT:
+ additionalInformation = requirements.minLength.toString();
+ break;
+ case MessageType.TOO_LONG:
+ additionalInformation = requirements.maxLength.toString();
+ break;
+ case MessageType.TOO_WEAK:
+ case MessageType.MISMATCH:
+ break;
+ default:
+ assertNotReached();
+ break;
+ }
+ this.problemMessage_ = this.i18n(messageId, additionalInformation);
+ },
/**
- * writeUma_ is a function that handles writing uma stats. It may be
- * overridden for tests.
- *
- * @type {Function}
+ * Notify the user about a problem.
* @private
+ * @param {string} messageId
+ * @param {string} problemClass
*/
- writeUma_: {
- type: Object,
- value: function() { return settings.recordLockScreenProgress; }
+ showProblem_: function(messageId, problemClass) {
+ this.quickUnlockPrivate_.getCredentialRequirements(
+ chrome.quickUnlockPrivate.QuickUnlockMode.PIN,
+ this.processPinRequirements_.bind(this, messageId));
+ this.problemClass_ = problemClass;
+ this.updateStyles();
+ this.enableSubmit_ = problemClass != ProblemType.ERROR &&
+ messageId != MessageType.MISMATCH;
},
- /**
- * The current step/subpage we are on.
- * @private
- */
- isConfirmStep_: {
- type: Boolean,
- value: false
+ /** @private */
+ hideProblem_: function() {
+ this.problemMessage_ = '';
+ this.problemClass_ = '';
},
/**
- * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests.
+ * Processes the message received from the quick unlock api and hides/shows
+ * the problem based on the message.
* @private
+ * @param {chrome.quickUnlockPrivate.CredentialCheck} message The message
+ * received from checkCredential.
*/
- quickUnlockPrivate_: {
- type: Object,
- value: chrome.quickUnlockPrivate
- },
- },
-
- /** @override */
- attached: function() {
- this.resetState_();
- },
-
- open: function() {
- this.$.dialog.showModal();
- this.$.pinKeyboard.focus();
- },
+ processPinProblems_: function(message) {
+ if (!message.errors.length && !message.warnings.length) {
+ this.hideProblem_();
+ this.enableSubmit_ = true;
+ return;
+ }
- close: function() {
- if (this.$.dialog.open)
- this.$.dialog.close();
+ if (message.warnings.length) {
+ assert(
+ message.warnings[0] ==
+ chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK);
+ this.showProblem_(MessageType.TOO_WEAK, ProblemType.WARNING);
+ }
- this.resetState_();
- },
+ if (message.errors.length) {
+ switch (message.errors[0]) {
+ case chrome.quickUnlockPrivate.CredentialProblem.TOO_SHORT:
+ this.showProblem_(MessageType.TOO_SHORT, ProblemType.ERROR);
+ break;
+ case chrome.quickUnlockPrivate.CredentialProblem.TOO_LONG:
+ this.showProblem_(MessageType.TOO_LONG, ProblemType.ERROR);
+ break;
+ case chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK:
+ this.showProblem_(MessageType.TOO_WEAK, ProblemType.ERROR);
+ break;
+ default:
+ assertNotReached();
+ break;
+ }
+ }
- /**
- * Resets the element to the initial state.
- * @private
- */
- resetState_: function() {
- this.initialPin_ = '';
- this.pinKeyboardValue_ = '';
- this.enableSubmit_ = false;
- this.isConfirmStep_ = false;
- this.hideProblem_();
- this.onPinChange_();
- },
-
- /** @private */
- onCancelTap_: function() {
- this.resetState_();
- this.$.dialog.close();
- },
+ },
- /**
- * Returns true if the PIN is ready to be changed to a new value.
- * @private
- * @return {boolean}
- */
- canSubmit_: function() {
- return this.initialPin_ == this.pinKeyboardValue_;
- },
+ /** @private */
+ onPinChange_: function() {
+ if (!this.isConfirmStep_) {
+ if (this.pinKeyboardValue_) {
+ this.quickUnlockPrivate_.checkCredential(
+ chrome.quickUnlockPrivate.QuickUnlockMode.PIN,
+ this.pinKeyboardValue_, this.processPinProblems_.bind(this));
+ }
+ return;
+ }
- /**
- * Handles writting the appropriate message to |problemMessage_|.
- * @private
- * @param {string} messageId
- * @param {chrome.quickUnlockPrivate.CredentialRequirements} requirements
- * The requirements received from getCredentialRequirements.
- */
- processPinRequirements_: function(messageId, requirements) {
- var additionalInformation = '';
- switch (messageId) {
- case MessageType.TOO_SHORT:
- additionalInformation = requirements.minLength.toString();
- break;
- case MessageType.TOO_LONG:
- additionalInformation = requirements.maxLength.toString();
- break;
- case MessageType.TOO_WEAK:
- case MessageType.MISMATCH:
- break;
- default:
- assertNotReached();
- break;
- }
- this.problemMessage_ = this.i18n(messageId, additionalInformation);
- },
+ if (this.canSubmit_()) {
+ this.hideProblem_();
+ this.enableSubmit_ = true;
+ return;
+ }
- /**
- * Notify the user about a problem.
- * @private
- * @param {string} messageId
- * @param {string} problemClass
- */
- showProblem_: function(messageId, problemClass) {
- this.quickUnlockPrivate_.getCredentialRequirements(
- chrome.quickUnlockPrivate.QuickUnlockMode.PIN,
- this.processPinRequirements_.bind(this, messageId));
- this.problemClass_ = problemClass;
- this.updateStyles();
- this.enableSubmit_ = problemClass != ProblemType.ERROR &&
- messageId != MessageType.MISMATCH;
- },
-
- /** @private */
- hideProblem_: function() {
- this.problemMessage_ = '';
- this.problemClass_ = '';
- },
+ this.showProblem_(MessageType.MISMATCH, ProblemType.WARNING);
+ },
- /**
- * Processes the message received from the quick unlock api and hides/shows
- * the problem based on the message.
- * @private
- * @param {chrome.quickUnlockPrivate.CredentialCheck} message The message
- * received from checkCredential.
- */
- processPinProblems_: function(message) {
- if (!message.errors.length && !message.warnings.length) {
- this.hideProblem_();
- this.enableSubmit_ = true;
- return;
- }
-
- if (message.warnings.length) {
- assert(message.warnings[0] ==
- chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK);
- this.showProblem_(MessageType.TOO_WEAK, ProblemType.WARNING);
- }
-
- if (message.errors.length) {
- switch (message.errors[0]) {
- case chrome.quickUnlockPrivate.CredentialProblem.TOO_SHORT:
- this.showProblem_(MessageType.TOO_SHORT, ProblemType.ERROR);
- break;
- case chrome.quickUnlockPrivate.CredentialProblem.TOO_LONG:
- this.showProblem_(MessageType.TOO_LONG, ProblemType.ERROR);
- break;
- case chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK:
- this.showProblem_(MessageType.TOO_WEAK, ProblemType.ERROR);
- break;
- default:
- assertNotReached();
- break;
+ /** @private */
+ onPinSubmit_: function() {
+ if (!this.isConfirmStep_) {
+ this.initialPin_ = this.pinKeyboardValue_;
+ this.pinKeyboardValue_ = '';
+ this.isConfirmStep_ = true;
+ this.onPinChange_();
+ this.$.pinKeyboard.focus();
+ this.writeUma_(LockScreenProgress.ENTER_PIN);
+ return;
}
- }
-
- },
-
- /** @private */
- onPinChange_: function() {
- if (!this.isConfirmStep_) {
- if (this.pinKeyboardValue_) {
- this.quickUnlockPrivate_.checkCredential(
- chrome.quickUnlockPrivate.QuickUnlockMode.PIN,
- this.pinKeyboardValue_,
- this.processPinProblems_.bind(this));
+ // onPinSubmit_ gets called if the user hits enter on the PIN keyboard.
+ // The PIN is not guaranteed to be valid in that case.
+ if (!this.canSubmit_()) {
+ this.showProblem_(MessageType.MISMATCH, ProblemType.ERROR);
+ return;
}
- return;
- }
- if (this.canSubmit_()) {
- this.hideProblem_();
- this.enableSubmit_ = true;
- return;
- }
-
- this.showProblem_(MessageType.MISMATCH, ProblemType.WARNING);
- },
+ function onSetModesCompleted(didSet) {
+ if (!didSet) {
+ console.error('Failed to update pin');
+ return;
+ }
- /** @private */
- onPinSubmit_: function() {
- if (!this.isConfirmStep_) {
- this.initialPin_ = this.pinKeyboardValue_;
- this.pinKeyboardValue_ = '';
- this.isConfirmStep_ = true;
- this.onPinChange_();
- this.$.pinKeyboard.focus();
- this.writeUma_(LockScreenProgress.ENTER_PIN);
- return;
- }
- // onPinSubmit_ gets called if the user hits enter on the PIN keyboard.
- // The PIN is not guaranteed to be valid in that case.
- if (!this.canSubmit_()) {
- this.showProblem_(MessageType.MISMATCH, ProblemType.ERROR);
- return;
- }
-
- function onSetModesCompleted(didSet) {
- if (!didSet) {
- console.error('Failed to update pin');
- return;
+ this.resetState_();
+ this.fire('done');
}
- this.resetState_();
- this.fire('done');
- }
-
- this.setModes.call(
- null,
- [chrome.quickUnlockPrivate.QuickUnlockMode.PIN],
- [this.pinKeyboardValue_],
- onSetModesCompleted.bind(this));
- this.writeUma_(LockScreenProgress.CONFIRM_PIN);
- },
+ this.setModes.call(
+ null, [chrome.quickUnlockPrivate.QuickUnlockMode.PIN],
+ [this.pinKeyboardValue_], onSetModesCompleted.bind(this));
+ this.writeUma_(LockScreenProgress.CONFIRM_PIN);
+ },
- /**
+ /**
* @private
* @param {string} problemMessage
* @return {boolean}
*/
- hasProblem_: function(problemMessage) {
- return !!problemMessage;
- },
+ hasProblem_: function(problemMessage) {
+ return !!problemMessage;
+ },
- /**
+ /**
* @private
* @param {boolean} isConfirmStep
* @return {string}
*/
- getTitleMessage_: function(isConfirmStep) {
- return this.i18n(isConfirmStep ? 'configurePinConfirmPinTitle' :
- 'configurePinChoosePinTitle');
- },
+ getTitleMessage_: function(isConfirmStep) {
+ return this.i18n(
+ isConfirmStep ? 'configurePinConfirmPinTitle' :
+ 'configurePinChoosePinTitle');
+ },
- /**
+ /**
* @private
* @param {boolean} isConfirmStep
* @return {string}
*/
- getContinueMessage_: function(isConfirmStep) {
- return this.i18n(isConfirmStep ? 'confirm' : 'configurePinContinueButton');
- },
-});
+ getContinueMessage_: function(isConfirmStep) {
+ return this.i18n(
+ isConfirmStep ? 'confirm' : 'configurePinContinueButton');
+ },
+ });
})();

Powered by Google App Engine
This is Rietveld 408576698