Index: chrome/browser/resources/gaia_auth/main.js |
diff --git a/chrome/browser/resources/gaia_auth/main.js b/chrome/browser/resources/gaia_auth/main.js |
index ba48c65dc9049f2dc8cb453d754480286497b3f8..aad569c6c3d3dc3fab6bb8a6a6b0f51c4be95760 100644 |
--- a/chrome/browser/resources/gaia_auth/main.js |
+++ b/chrome/browser/resources/gaia_auth/main.js |
@@ -48,6 +48,7 @@ Authenticator.getInstance = function() { |
Authenticator.prototype = { |
email_: null, |
+ gaiaId_: null, |
// Depending on the key type chosen, this will contain the plain text password |
// or a credential derived from it along with the information required to |
@@ -56,6 +57,10 @@ Authenticator.prototype = { |
// when support for key types other than plain text password is added. |
passwordBytes_: null, |
+ chooseWhatToSync_: false, |
+ skipForNow_: false, |
+ sessionIndex_: null, |
+ |
attemptToken_: null, |
// Input params from extension initialization URL. |
@@ -165,9 +170,9 @@ Authenticator.prototype = { |
}); |
this.supportChannel_.registerMessage( |
'switchToFullTab', this.switchToFullTab_.bind(this)); |
- this.supportChannel_.registerMessage( |
- 'completeLogin', this.completeLogin_.bind(this)); |
} |
+ this.supportChannel_.registerMessage( |
+ 'completeLogin', this.onCompleteLogin_.bind(this)); |
this.initSAML_(); |
this.maybeInitialized_(); |
}.bind(this)); |
@@ -220,8 +225,11 @@ Authenticator.prototype = { |
this.passwordBytes_, |
'usingSAML': this.isSAMLFlow_, |
'chooseWhatToSync': this.chooseWhatToSync_ || false, |
- 'skipForNow': opt_extraMsg && opt_extraMsg.skipForNow, |
- 'sessionIndex': opt_extraMsg && opt_extraMsg.sessionIndex |
+ 'skipForNow': (opt_extraMsg && opt_extraMsg.skipForNow) || |
+ this.skipForNow_, |
+ 'sessionIndex': (opt_extraMsg && opt_extraMsg.sessionIndex) || |
+ this.sessionIndex_, |
+ 'gaiaId': (opt_extraMsg && opt_extraMsg.gaiaId) || this.gaiaId_ |
}; |
window.parent.postMessage(msg, this.parentPage_); |
this.supportChannel_.send({name: 'resetAuth'}); |
@@ -268,6 +276,7 @@ Authenticator.prototype = { |
// from the GAIA login form are no longer relevant and can be discarded. |
this.isSAMLFlow_ = true; |
this.email_ = null; |
+ this.gaiaId_ = null; |
this.passwordBytes_ = null; |
} |
@@ -318,6 +327,7 @@ Authenticator.prototype = { |
} |
this.apiToken_ = call.token; |
this.email_ = call.user; |
+ this.gaiaId_ = null; // TODO(rogerta): no idea what to do here. |
this.passwordBytes_ = call.passwordBytes; |
} else if (call.method == 'confirm') { |
if (call.token != this.apiToken_) |
@@ -342,12 +352,25 @@ Authenticator.prototype = { |
}); |
}, |
- onConfirmLogin_: function() { |
- if (!this.isSAMLFlow_) { |
- this.completeLogin_(); |
+ /** |
+ * Callback invoked for 'completeLogin' message. |
+ */ |
+ onCompleteLogin_: function(opt_extraMsg) { |
+ // Skip SAML extra steps for desktop flow and non-SAML flow. |
+ if (!this.isSAMLFlow_ || this.desktopMode_) { |
+ this.completeLogin_(opt_extraMsg); |
return; |
} |
+ if (opt_extraMsg) { |
+ this.email_ = opt_extraMsg.email; |
+ this.gaiaId_ = opt_extraMsg.gaiaId; |
+ // Password from |opt_extraMsg| is not used because ChromeOS SAML flow |
+ // gets password by asking user for confirm. |
+ this.skipForNow_ = opt_extraMsg.skipForNow; |
+ this.sessionIndex_ = opt_extraMsg.sessionIndex; |
+ } |
+ |
var apiUsed = !!this.passwordBytes_; |
// Retrieve the e-mail address of the user who just authenticated from GAIA. |
@@ -401,6 +424,7 @@ Authenticator.prototype = { |
onMessage: function(e) { |
var msg = e.data; |
if (msg.method == 'attemptLogin' && this.isGaiaMessage_(e)) { |
+ // At this point GAIA does not yet know the gaiaId, so its not set here. |
this.email_ = msg.email; |
this.passwordBytes_ = msg.password; |
this.attemptToken_ = msg.attemptToken; |
@@ -416,6 +440,7 @@ Authenticator.prototype = { |
this.maybeInitialized_(); |
} |
this.email_ = null; |
+ this.gaiaId_ = null; |
this.passwordBytes_ = null; |
this.attemptToken_ = null; |
this.isSAMLFlow_ = false; |
@@ -427,16 +452,6 @@ Authenticator.prototype = { |
this.email_ = msg.email; |
this.maybeCompleteSAMLLogin_(); |
} |
- } else if (msg.method == 'confirmLogin' && this.isInternalMessage_(e)) { |
- // In the desktop mode, Chrome needs to wait for extra info such as |
- // session index from the background JS. |
- if (this.desktopMode_) |
- return; |
- |
- if (this.attemptToken_ == msg.attemptToken) |
- this.onConfirmLogin_(); |
- else |
- console.error('Authenticator.onMessage: unexpected attemptToken!?'); |
} else if (msg.method == 'verifyConfirmedPassword' && |
this.isParentMessage_(e)) { |
this.onVerifyConfirmedPassword_(msg.password); |