| 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 46f919eea0fd871c54b04797da71d2137af5dcb9..7709657948de1f70ff455e615244daea43b83158 100644
|
| --- a/chrome/browser/resources/gaia_auth_host/authenticator.js
|
| +++ b/chrome/browser/resources/gaia_auth_host/authenticator.js
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -<include src="saml_handler.js">
|
| +// <include src="saml_handler.js">
|
|
|
| /**
|
| * @fileoverview An UI component to authenciate to Chrome. The component hosts
|
| @@ -44,20 +44,13 @@ cr.define('cr.login', function() {
|
| * chrome/browser/ui/webui/inline_login_ui.cc.
|
| * @enum {number}
|
| */
|
| - var AuthMode = {
|
| - DEFAULT: 0,
|
| - OFFLINE: 1,
|
| - DESKTOP: 2
|
| - };
|
| + var AuthMode = {DEFAULT: 0, OFFLINE: 1, DESKTOP: 2};
|
|
|
| /**
|
| * Enum for the authorization type.
|
| * @enum {number}
|
| */
|
| - var AuthFlow = {
|
| - DEFAULT: 0,
|
| - SAML: 1
|
| - };
|
| + var AuthFlow = {DEFAULT: 0, SAML: 1};
|
|
|
| /**
|
| * Supported Authenticator params.
|
| @@ -83,15 +76,15 @@ cr.define('cr.login', function() {
|
| // not called before dispatching |authCopleted|.
|
| // Default is |true|.
|
| 'flow', // One of 'default', 'enterprise', or 'theftprotection'.
|
| - 'enterpriseDomain', // Domain in which hosting device is (or should be)
|
| - // enrolled.
|
| - 'emailDomain', // Value used to prefill domain for email.
|
| - 'chromeType', // Type of Chrome OS device, e.g. "chromebox".
|
| - 'clientVersion', // Version of the Chrome build.
|
| - 'platformVersion', // Version of the OS build.
|
| - 'releaseChannel', // Installation channel.
|
| - 'endpointGen', // Current endpoint generation.
|
| - 'gapsCookie', // GAPS cookie
|
| + 'enterpriseDomain', // Domain in which hosting device is (or should be)
|
| + // enrolled.
|
| + 'emailDomain', // Value used to prefill domain for email.
|
| + 'chromeType', // Type of Chrome OS device, e.g. "chromebox".
|
| + 'clientVersion', // Version of the Chrome build.
|
| + 'platformVersion', // Version of the OS build.
|
| + 'releaseChannel', // Installation channel.
|
| + 'endpointGen', // Current endpoint generation.
|
| + 'gapsCookie', // GAPS cookie
|
|
|
| // The email fields allow for the following possibilities:
|
| //
|
| @@ -125,8 +118,7 @@ cr.define('cr.login', function() {
|
| this.isLoaded_ = false;
|
| this.email_ = null;
|
| this.password_ = null;
|
| - this.gaiaId_ = null,
|
| - this.sessionIndex_ = null;
|
| + this.gaiaId_ = null, this.sessionIndex_ = null;
|
| this.chooseWhatToSync_ = false;
|
| this.skipForNow_ = false;
|
| this.authFlow = AuthFlow.DEFAULT;
|
| @@ -155,43 +147,32 @@ cr.define('cr.login', function() {
|
| this.missingGaiaInfoCallback = null;
|
| this.needPassword = true;
|
| this.samlHandler_.addEventListener(
|
| - 'insecureContentBlocked',
|
| - this.onInsecureContentBlocked_.bind(this));
|
| + 'insecureContentBlocked', this.onInsecureContentBlocked_.bind(this));
|
| this.samlHandler_.addEventListener(
|
| - 'authPageLoaded',
|
| - this.onAuthPageLoaded_.bind(this));
|
| + 'authPageLoaded', this.onAuthPageLoaded_.bind(this));
|
| this.samlHandler_.addEventListener(
|
| - 'videoEnabled',
|
| - this.onVideoEnabled_.bind(this));
|
| + 'videoEnabled', this.onVideoEnabled_.bind(this));
|
| this.samlHandler_.addEventListener(
|
| - 'apiPasswordAdded',
|
| - this.onSamlApiPasswordAdded_.bind(this));
|
| + 'apiPasswordAdded', this.onSamlApiPasswordAdded_.bind(this));
|
|
|
| this.webview_.addEventListener('droplink', this.onDropLink_.bind(this));
|
| - this.webview_.addEventListener(
|
| - 'newwindow', this.onNewWindow_.bind(this));
|
| + this.webview_.addEventListener('newwindow', this.onNewWindow_.bind(this));
|
| this.webview_.addEventListener(
|
| 'contentload', this.onContentLoad_.bind(this));
|
| - this.webview_.addEventListener(
|
| - 'loadabort', this.onLoadAbort_.bind(this));
|
| - this.webview_.addEventListener(
|
| - 'loadstop', this.onLoadStop_.bind(this));
|
| - this.webview_.addEventListener(
|
| - 'loadcommit', this.onLoadCommit_.bind(this));
|
| + this.webview_.addEventListener('loadabort', this.onLoadAbort_.bind(this));
|
| + this.webview_.addEventListener('loadstop', this.onLoadStop_.bind(this));
|
| + this.webview_.addEventListener('loadcommit', this.onLoadCommit_.bind(this));
|
| this.webview_.request.onCompleted.addListener(
|
| this.onRequestCompleted_.bind(this),
|
| - {urls: ['<all_urls>'], types: ['main_frame']},
|
| - ['responseHeaders']);
|
| + {urls: ['<all_urls>'], types: ['main_frame']}, ['responseHeaders']);
|
| this.webview_.request.onHeadersReceived.addListener(
|
| this.onHeadersReceived_.bind(this),
|
| {urls: ['<all_urls>'], types: ['main_frame', 'xmlhttprequest']},
|
| ['responseHeaders']);
|
| window.addEventListener(
|
| 'message', this.onMessageFromWebview_.bind(this), false);
|
| - window.addEventListener(
|
| - 'focus', this.onFocus_.bind(this), false);
|
| - window.addEventListener(
|
| - 'popstate', this.onPopState_.bind(this), false);
|
| + window.addEventListener('focus', this.onFocus_.bind(this), false);
|
| + window.addEventListener('popstate', this.onPopState_.bind(this), false);
|
| }
|
|
|
| Authenticator.prototype = Object.create(cr.EventTarget.prototype);
|
| @@ -254,8 +235,8 @@ cr.define('cr.login', function() {
|
| this.reloadUrl_ = data.frameUrl || this.initialFrameUrl_;
|
| // Don't block insecure content for desktop flow because it lands on
|
| // http. Otherwise, block insecure content as long as gaia is https.
|
| - this.samlHandler_.blockInsecureContent = authMode != AuthMode.DESKTOP &&
|
| - this.idpOrigin_.startsWith('https://');
|
| + this.samlHandler_.blockInsecureContent =
|
| + authMode != AuthMode.DESKTOP && this.idpOrigin_.startsWith('https://');
|
| this.needPassword = !('needPassword' in data) || data.needPassword;
|
|
|
| if (this.isNewGaiaFlow) {
|
| @@ -291,11 +272,12 @@ cr.define('cr.login', function() {
|
| if (data.doSamlRedirect) {
|
| var url = this.idpOrigin_ + SAML_REDIRECTION_PATH;
|
| url = appendParam(url, 'domain', data.enterpriseDomain);
|
| - url = appendParam(url, 'continue', data.gaiaUrl +
|
| - 'o/oauth2/programmatic_auth?hl=' + data.hl +
|
| - '&scope=https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthLogin&' +
|
| - 'client_id=' + encodeURIComponent(data.clientId) +
|
| - '&access_type=offline');
|
| + url = appendParam(
|
| + url, 'continue', data.gaiaUrl + 'o/oauth2/programmatic_auth?hl=' +
|
| + data.hl +
|
| + '&scope=https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthLogin&' +
|
| + 'client_id=' + encodeURIComponent(data.clientId) +
|
| + '&access_type=offline');
|
|
|
| return url;
|
| }
|
| @@ -468,8 +450,7 @@ cr.define('cr.login', function() {
|
| // URL will contain a source=3 field.
|
| var location = decodeURIComponent(header.value);
|
| this.chooseWhatToSync_ = !!location.match(/(\?|&)source=3($|&)/);
|
| - } else if (
|
| - this.isNewGaiaFlow && headerName == SET_COOKIE_HEADER) {
|
| + } else if (this.isNewGaiaFlow && headerName == SET_COOKIE_HEADER) {
|
| var headerValue = header.value;
|
| if (headerValue.startsWith(OAUTH_CODE_COOKIE + '=')) {
|
| this.oauthCode_ =
|
| @@ -524,8 +505,8 @@ cr.define('cr.login', function() {
|
|
|
| for (var i = 0, l = headers.length; i < l; ++i) {
|
| if (headers[i].name == COOKIE_HEADER) {
|
| - headers[i].value = this.updateCookieValue_(headers[i].value,
|
| - GAPS_COOKIE, gapsCookie);
|
| + headers[i].value = this.updateCookieValue_(
|
| + headers[i].value, GAPS_COOKIE, gapsCookie);
|
| found = true;
|
| break;
|
| }
|
| @@ -536,9 +517,7 @@ cr.define('cr.login', function() {
|
| }
|
| this.gapsCookieSent_ = true;
|
| }
|
| - return {
|
| - requestHeaders: details.requestHeaders
|
| - };
|
| + return {requestHeaders: details.requestHeaders};
|
| };
|
|
|
| /**
|
| @@ -555,19 +534,13 @@ cr.define('cr.login', function() {
|
| }
|
|
|
| // EAFE passes back auth code via message.
|
| - if (this.useEafe_ &&
|
| - typeof e.data == 'object' &&
|
| + if (this.useEafe_ && typeof e.data == 'object' &&
|
| e.data.hasOwnProperty('authorizationCode')) {
|
| assert(!this.oauthCode_);
|
| this.oauthCode_ = e.data.authorizationCode;
|
| - this.dispatchEvent(
|
| - new CustomEvent('authCompleted',
|
| - {
|
| - detail: {
|
| - authCodeOnly: true,
|
| - authCode: this.oauthCode_
|
| - }
|
| - }));
|
| + this.dispatchEvent(new CustomEvent(
|
| + 'authCompleted',
|
| + {detail: {authCodeOnly: true, authCode: this.oauthCode_}}));
|
| return;
|
| }
|
|
|
| @@ -595,8 +568,7 @@ cr.define('cr.login', function() {
|
|
|
| this.chooseWhatToSync_ = msg.chooseWhatToSync;
|
| // We need to dispatch only first event, before user enters password.
|
| - this.dispatchEvent(
|
| - new CustomEvent('attemptLogin', {detail: msg.email}));
|
| + this.dispatchEvent(new CustomEvent('attemptLogin', {detail: msg.email}));
|
| } else if (msg.method == 'dialogShown') {
|
| this.dispatchEvent(new Event('dialogShown'));
|
| } else if (msg.method == 'dialogHidden') {
|
| @@ -624,10 +596,11 @@ cr.define('cr.login', function() {
|
| // does not expect it to be called immediately.
|
| // TODO(xiyuan): Change to synchronous call when iframe based code
|
| // is removed.
|
| - var invokeConfirmPassword = (function() {
|
| - this.confirmPasswordCallback(this.email_,
|
| - this.samlHandler_.scrapedPasswordCount);
|
| - }).bind(this);
|
| + var invokeConfirmPassword =
|
| + (function() {
|
| + this.confirmPasswordCallback(
|
| + this.email_, this.samlHandler_.scrapedPasswordCount);
|
| + }).bind(this);
|
| window.setTimeout(invokeConfirmPassword, 0);
|
| return;
|
| }
|
| @@ -682,8 +655,8 @@ cr.define('cr.login', function() {
|
| if (this.confirmPasswordCallback) {
|
| // Confirm scraped password. The flow follows in
|
| // verifyConfirmedPassword.
|
| - this.confirmPasswordCallback(this.email_,
|
| - this.samlHandler_.scrapedPasswordCount);
|
| + this.confirmPasswordCallback(
|
| + this.email_, this.samlHandler_.scrapedPasswordCount);
|
| return;
|
| }
|
| }
|
| @@ -706,8 +679,9 @@ cr.define('cr.login', function() {
|
| * @private
|
| */
|
| Authenticator.prototype.onAuthCompleted_ = function() {
|
| - assert(this.skipForNow_ ||
|
| - (this.email_ && this.gaiaId_ && this.sessionIndex_));
|
| + assert(
|
| + this.skipForNow_ ||
|
| + (this.email_ && this.gaiaId_ && this.sessionIndex_));
|
| this.dispatchEvent(new CustomEvent(
|
| 'authCompleted',
|
| // TODO(rsorokin): get rid of the stub values.
|
| @@ -830,8 +804,8 @@ cr.define('cr.login', function() {
|
| * @private
|
| */
|
| Authenticator.prototype.onLoadAbort_ = function(e) {
|
| - this.dispatchEvent(new CustomEvent('loadAbort',
|
| - {detail: {error: e.reason, src: e.url}}));
|
| + this.dispatchEvent(
|
| + new CustomEvent('loadAbort', {detail: {error: e.reason, src: e.url}}));
|
| };
|
|
|
| /**
|
| @@ -846,12 +820,12 @@ cr.define('cr.login', function() {
|
| 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);
|
| + window.setTimeout(
|
| + (function() {
|
| + var msg = {'clientId': this.clientId_};
|
| + this.webview_.contentWindow.postMessage(msg, this.idpOrigin_);
|
| + }).bind(this),
|
| + EAFE_INITIAL_MESSAGE_DELAY_IN_MS);
|
| }
|
| };
|
|
|
|
|