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

Unified Diff: chrome/browser/resources/cryptotoken/usbenrollhandler.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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/cryptotoken/usbenrollhandler.js
diff --git a/chrome/browser/resources/cryptotoken/usbenrollhandler.js b/chrome/browser/resources/cryptotoken/usbenrollhandler.js
index cf113d2ae22442283eab1dd0a19163cf6a3d6531..e9bdcc11385f3d65898a58826ff02ed52f445fbc 100644
--- a/chrome/browser/resources/cryptotoken/usbenrollhandler.js
+++ b/chrome/browser/resources/cryptotoken/usbenrollhandler.js
@@ -37,21 +37,18 @@ UsbEnrollHandler.DEFAULT_TIMEOUT_MILLIS = 30 * 1000;
* @return {boolean} Whether this handler could be run.
*/
UsbEnrollHandler.prototype.run = function(cb) {
- var timeoutMillis =
- this.request_.timeoutSeconds ?
+ var timeoutMillis = this.request_.timeoutSeconds ?
this.request_.timeoutSeconds * 1000 :
UsbEnrollHandler.DEFAULT_TIMEOUT_MILLIS;
/** @private {Countdown} */
- this.timer_ = DEVICE_FACTORY_REGISTRY.getCountdownFactory().createTimer(
- timeoutMillis);
+ this.timer_ =
+ DEVICE_FACTORY_REGISTRY.getCountdownFactory().createTimer(timeoutMillis);
this.enrollChallenges = this.request_.enrollChallenges;
/** @private {RequestHandlerCallback} */
this.cb_ = cb;
this.signer_ = new MultipleGnubbySigner(
- true /* forEnroll */,
- this.signerCompleted_.bind(this),
- this.signerFoundGnubby_.bind(this),
- timeoutMillis,
+ true /* forEnroll */, this.signerCompleted_.bind(this),
+ this.signerFoundGnubby_.bind(this), timeoutMillis,
this.request_.logMsgUrl);
return this.signer_.doSign(this.request_.signData);
};
@@ -91,15 +88,15 @@ UsbEnrollHandler.prototype.signerCompleted_ = function(anyPending) {
* results from more gnubbies.
* @private
*/
-UsbEnrollHandler.prototype.signerFoundGnubby_ =
- function(signResult, moreExpected) {
+UsbEnrollHandler.prototype.signerFoundGnubby_ = function(
+ signResult, moreExpected) {
if (!signResult.code) {
// If the signer reports a gnubby can sign, report this immediately to the
// caller, as the gnubby is already enrolled. Map ok to WRONG_DATA, so the
// caller knows what to do.
this.notifyError_(DeviceStatusCodes.WRONG_DATA_STATUS);
} else if (SingleGnubbySigner.signErrorIndicatesInvalidKeyHandle(
- signResult.code)) {
+ signResult.code)) {
var gnubby = signResult['gnubby'];
// A valid helper request contains at least one enroll challenge, so use
// the app id hash from the first challenge.
@@ -118,8 +115,8 @@ UsbEnrollHandler.prototype.signerFoundGnubby_ =
* @param {Gnubby=} opt_gnubby The gnubby whose prerequisites were checked.
* @private
*/
-UsbEnrollHandler.prototype.gnubbyPrerequisitesChecked_ =
- function(rc, opt_gnubby) {
+UsbEnrollHandler.prototype.gnubbyPrerequisitesChecked_ = function(
+ rc, opt_gnubby) {
if (rc || this.timer_.expired()) {
// Do nothing:
// If the timer is expired, the signerCompleted_ callback will indicate
@@ -212,10 +209,10 @@ UsbEnrollHandler.prototype.tryEnroll_ = function(gnubby, version) {
}
var challengeValue = B64_decode(challenge['challengeHash']);
var appIdHash = challenge['appIdHash'];
- var individualAttest =
- DEVICE_FACTORY_REGISTRY.getIndividualAttestation().
- requestIndividualAttestation(appIdHash);
- gnubby.enroll(challengeValue, B64_decode(appIdHash),
+ var individualAttest = DEVICE_FACTORY_REGISTRY.getIndividualAttestation()
+ .requestIndividualAttestation(appIdHash);
+ gnubby.enroll(
+ challengeValue, B64_decode(appIdHash),
this.enrollCallback_.bind(this, gnubby, version), individualAttest);
};
@@ -242,25 +239,25 @@ UsbEnrollHandler.prototype.getChallengeOfVersion_ = function(version) {
* @param {ArrayBuffer=} infoArray Returned data
* @private
*/
-UsbEnrollHandler.prototype.enrollCallback_ =
- function(gnubby, version, code, infoArray) {
+UsbEnrollHandler.prototype.enrollCallback_ = function(
+ gnubby, version, code, infoArray) {
if (this.notified_) {
// Enroll completed after previous success or failure. Disregard.
return;
}
switch (code) {
case -GnubbyDevice.GONE:
- // Close this gnubby.
- this.removeWaitingGnubby_(gnubby);
- if (!this.waitingForTouchGnubbies_.length) {
- // Last enroll attempt is complete and last gnubby is gone.
- this.anyGnubbiesFound_ = false;
- if (this.timer_.expired()) {
- this.notifyError_(DeviceStatusCodes.TIMEOUT_STATUS);
- } else if (this.signer_) {
- this.signer_.reScanDevices();
- }
+ // Close this gnubby.
+ this.removeWaitingGnubby_(gnubby);
+ if (!this.waitingForTouchGnubbies_.length) {
+ // Last enroll attempt is complete and last gnubby is gone.
+ this.anyGnubbiesFound_ = false;
+ if (this.timer_.expired()) {
+ this.notifyError_(DeviceStatusCodes.TIMEOUT_STATUS);
+ } else if (this.signer_) {
+ this.signer_.reScanDevices();
}
+ }
break;
case DeviceStatusCodes.WAIT_TOUCH_STATUS:
@@ -275,8 +272,8 @@ UsbEnrollHandler.prototype.enrollCallback_ =
this.removeWaitingGnubby_(gnubby);
if (!this.waitingForTouchGnubbies_.length) {
// Last enroll attempt is complete: return this error.
- console.log(UTIL_fmt('timeout (' + code.toString(16) +
- ') enrolling'));
+ console.log(
+ UTIL_fmt('timeout (' + code.toString(16) + ') enrolling'));
this.notifyError_(DeviceStatusCodes.TIMEOUT_STATUS);
}
} else {
@@ -314,10 +311,7 @@ UsbEnrollHandler.prototype.notifyError_ = function(code) {
return;
this.notified_ = true;
this.close();
- var reply = {
- 'type': 'enroll_helper_reply',
- 'code': code
- };
+ var reply = {'type': 'enroll_helper_reply', 'code': code};
this.cb_(reply);
};

Powered by Google App Engine
This is Rietveld 408576698