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

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

Issue 2600683002: Run tools/clang-format-js on some of chrome/browser/resources/ (Closed)
Patch Set: hackhackhack Created 3 years, 11 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
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 fab0ec4b94729fea836c8c76ce60e7b3d25941fd..c2f9ebe9a839941203b8dbd8ab8bc1b0cf10fc4b 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'.
dschuyler 2017/01/06 02:16:33 Could the formatter align the comments in all of S
Dan Beam 2017/01/06 02:36:50 maybe it could but there's style rules that discou
- '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:
//
@@ -126,8 +119,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;
dschuyler 2017/01/06 02:16:33 This looks like a typo in the original file. s/,/
Dan Beam 2017/01/06 02:36:50 yes, it is
this.chooseWhatToSync_ = false;
this.skipForNow_ = false;
this.authFlow = AuthFlow.DEFAULT;
@@ -156,43 +148,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);
@@ -255,8 +236,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) {
@@ -292,11 +273,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;
}
@@ -469,8 +451,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_ =
@@ -525,8 +506,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;
}
@@ -537,9 +518,7 @@ cr.define('cr.login', function() {
}
this.gapsCookieSent_ = true;
}
- return {
- requestHeaders: details.requestHeaders
- };
+ return {requestHeaders: details.requestHeaders};
};
/**
@@ -556,19 +535,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;
}
@@ -596,8 +569,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') {
@@ -625,10 +597,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;
}
@@ -683,8 +656,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;
}
}
@@ -707,8 +680,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.
@@ -831,8 +805,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}}));
};
/**
@@ -847,12 +821,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);
}
};

Powered by Google App Engine
This is Rietveld 408576698