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 894085e0fef64d45bd641c763bb9c143cfb599d8..91c6098e8f9696b1a0cc5f5ebd8eb37a72fce837 100644 |
--- a/chrome/browser/resources/gaia_auth/main.js |
+++ b/chrome/browser/resources/gaia_auth/main.js |
@@ -201,6 +201,8 @@ Authenticator.prototype = { |
this.samlSupportChannel_.connect('authMain'); |
this.samlSupportChannel_.registerMessage( |
'onAuthPageLoaded', this.onAuthPageLoaded_.bind(this)); |
+ this.samlSupportChannel_.registerMessage( |
+ 'apiCall', this.onAPICall_.bind(this)); |
this.samlSupportChannel_.send({ |
name: 'setGaiaUrl', |
gaiaUrl: this.gaiaUrl_ |
@@ -230,6 +232,25 @@ Authenticator.prototype = { |
}, this.parentPage_); |
}, |
+ /** |
+ * Invoked when one of the credential passing API methods is called by a SAML |
+ * provider. |
+ * @param {!Object} msg Details of the API call. |
+ */ |
+ onAPICall_: function(msg) { |
+ var call = msg.call; |
+ if (call.method == 'add') { |
+ this.apiToken_ = call.token; |
+ this.email_ = call.user; |
+ this.password_ = call.password; |
+ } else if (call.method == 'confirm') { |
+ if (call.token != this.apiToken_) |
+ console.error('Authenticator.onAPICall_: token mismatch'); |
+ } else { |
+ console.error('Authenticator.onAPICall_: unknown message'); |
+ } |
+ }, |
+ |
onLoginUILoaded: function() { |
var msg = { |
'method': 'loginUILoaded' |
@@ -258,19 +279,21 @@ Authenticator.prototype = { |
attemptToken: this.attemptToken_}, |
this.parentPage_); |
- this.samlSupportChannel_.sendWithCallback( |
- {name: 'getScrapedPasswords'}, |
- function(passwords) { |
- if (passwords.length == 0) { |
- window.parent.postMessage( |
- {method: 'noPassword', email: this.email_}, |
- this.parentPage_); |
- } else { |
- window.parent.postMessage( |
- {method: 'confirmPassword', email: this.email_}, |
- this.parentPage_); |
- } |
- }.bind(this)); |
+ if (!this.password_) { |
+ this.samlSupportChannel_.sendWithCallback( |
+ {name: 'getScrapedPasswords'}, |
+ function(passwords) { |
+ if (passwords.length == 0) { |
+ window.parent.postMessage( |
+ {method: 'noPassword', email: this.email_}, |
+ this.parentPage_); |
+ } else { |
+ window.parent.postMessage( |
+ {method: 'confirmPassword', email: this.email_}, |
+ this.parentPage_); |
+ } |
+ }.bind(this)); |
+ } |
}, |
maybeCompleteSAMLLogin_: function() { |