Index: chrome/browser/resources/gaia_auth_host/authenticator.js |
diff --git a/chrome/browser/resources/gaia_auth_host/authenticator.js b/chrome/browser/resources/gaia_auth_host/authenticator.js |
index 6492781c36c103aac1675b5e131f054451d7a216..cef63cd031c0d4ed8624e50b5122c1c23d556cf0 100644 |
--- a/chrome/browser/resources/gaia_auth_host/authenticator.js |
+++ b/chrome/browser/resources/gaia_auth_host/authenticator.js |
@@ -116,6 +116,8 @@ cr.define('cr.login', function() { |
this.webview_.addEventListener( |
'newwindow', this.onNewWindow_.bind(this)); |
this.webview_.addEventListener( |
+ 'contentload', this.onContentLoad_.bind(this)); |
+ this.webview_.addEventListener( |
'loadstop', this.onLoadStop_.bind(this)); |
this.webview_.request.onCompleted.addListener( |
this.onRequestCompleted_.bind(this), |
@@ -196,9 +198,6 @@ cr.define('cr.login', function() { |
this.updateHistoryState_(currentUrl); |
- // Posts a message to IdP pages to initiate communication. |
- if (currentUrl.lastIndexOf(this.idpOrigin_) == 0) |
- this.webview_.contentWindow.postMessage({}, currentUrl); |
}; |
/** |
@@ -254,12 +253,7 @@ cr.define('cr.login', function() { |
signinDetails[pair[0].trim()] = pair[1].trim(); |
}); |
// Removes "" around. |
- var email = signinDetails['email'].slice(1, -1); |
- if (this.email_ != email) { |
- this.email_ = email; |
- // Clears the scraped password if the email has changed. |
- this.password_ = null; |
- } |
+ this.email_ = signinDetails['email'].slice(1, -1); |
this.gaiaId_ = signinDetails['obfuscatedid'].slice(1, -1); |
this.sessionIndex_ = signinDetails['sessionindex']; |
} else if (headerName == SAML_HEADER) { |
@@ -318,6 +312,18 @@ cr.define('cr.login', function() { |
}; |
/** |
+ * Invoked when a new document is loaded. |
+ * @private |
+ */ |
+ Authenticator.prototype.onContentLoad_ = function(e) { |
+ // Posts a message to IdP pages to initiate communication. |
+ var currentUrl = this.webview_.src; |
+ if (currentUrl.lastIndexOf(this.idpOrigin_) == 0) { |
+ this.webview_.contentWindow.postMessage({}, currentUrl); |
+ } |
+ }; |
+ |
+ /** |
* Invoked when the webview finishes loading a page. |
* @private |
*/ |