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

Unified Diff: chrome/browser/resources/gaia_auth_host/authenticator.js

Issue 1102793003: bootstrap: Make Eafe work in webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for #1 Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43bf4fa93b3d6d3ec6f667e3f13e64a62724f327..0253f54047bf565d56f12c7c32684fac1c9c77ef 100644
--- a/chrome/browser/resources/gaia_auth_host/authenticator.js
+++ b/chrome/browser/resources/gaia_auth_host/authenticator.js
@@ -76,6 +76,7 @@ cr.define('cr.login', function() {
'constrained', // Whether the extension is loaded in a constrained
// window.
'clientId', // Chrome client id.
+ 'useEafe', // Whether to use EAFE.
'needPassword', // Whether the host is interested in getting a password.
// If this set to |false|, |confirmPasswordCallback| is
// not called before dispatching |authCopleted|.
@@ -118,6 +119,9 @@ cr.define('cr.login', function() {
this.sessionIsEphemeral_ = null;
this.onBeforeSetHeadersSet_ = false;
+ this.useEafe_ = false;
+ this.clientId_ = null;
+
this.samlHandler_ = new cr.login.SamlHandler(this.webview_);
this.confirmPasswordCallback = null;
this.noPasswordCallback = null;
@@ -193,6 +197,8 @@ cr.define('cr.login', function() {
this.continueUrl_;
this.isConstrainedWindow_ = data.constrained == '1';
this.isNewGaiaFlowChromeOS = data.isNewGaiaFlowChromeOS;
+ this.useEafe_ = data.useEafe || false;
+ this.clientId_ = data.clientId;
this.initialFrameUrl_ = this.constructInitialFrameUrl_(data);
this.reloadUrl_ = data.frameUrl || this.initialFrameUrl_;
@@ -432,6 +438,23 @@ cr.define('cr.login', function() {
return;
}
+ // EAFE passes back auth code via message.
+ if (this.useEafe_ &&
+ typeof e.data == 'object' &&
+ e.data.hasOwnProperty('authorizationCode')) {
+ assert(!this.oauth_code_);
+ this.oauth_code_ = e.data.authorizationCode;
+ this.dispatchEvent(
+ new CustomEvent('authCompleted',
+ {
+ detail: {
+ authCodeOnly: true,
+ authCode: this.oauth_code_
+ }
+ }));
+ return;
+ }
+
// Gaia messages must be an object with 'method' property.
if (typeof e.data != 'object' || !e.data.hasOwnProperty('method')) {
return;
@@ -630,6 +653,21 @@ cr.define('cr.login', function() {
// Focus webview after dispatching event when webview is already visible.
this.webview_.focus();
}
+
+ // Sends client id to EAFE on every loadstop after a small timeout. This is
+ // needed because EAFE sits behind SSO and initialize asynchrounouly
+ // and we don't know for sure when it is loaded and ready to listen
+ // for message. The postMessage is guarded by EAFE's origin.
+ if (this.useEafe_) {
+ // An arbitrary small timeout for delivering the initial message.
+ var EAFE_INITIAL_MESSAGE_DELAY_IN_MS = 500;
+ window.setTimeout((function() {
+ var msg = {
+ 'clientId': this.clientId_
+ };
+ this.webview_.contentWindow.postMessage(msg, this.idpOrigin_);
+ }).bind(this), EAFE_INITIAL_MESSAGE_DELAY_IN_MS);
+ }
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698