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

Side by Side Diff: chrome/browser/resources/gaia_auth_host/authenticator.js

Issue 789353004: Host Chrome OS GAIA signin page in webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove changes from https://codereview.chromium.org/812513003 Created 5 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview An UI component to authenciate to Chrome. The component hosts 6 * @fileoverview An UI component to authenciate to Chrome. The component hosts
7 * IdP web pages in a webview. A client who is interested in monitoring 7 * IdP web pages in a webview. A client who is interested in monitoring
8 * authentication events should pass a listener object of type 8 * authentication events should pass a listener object of type
9 * cr.login.GaiaAuthHost.Listener as defined in this file. After initialization, 9 * cr.login.GaiaAuthHost.Listener as defined in this file. After initialization,
10 * call {@code load} to start the authentication flow. 10 * call {@code load} to start the authentication flow.
11 */ 11 */
12 cr.define('cr.login', function() { 12 cr.define('cr.login', function() {
13 'use strict'; 13 'use strict';
14 14
15 var IDP_ORIGIN = 'https://accounts.google.com/'; 15 var IDP_ORIGIN = 'https://accounts.google.com/';
16 var IDP_PATH = 'ServiceLogin?skipvpage=true&sarp=1&rm=hide'; 16 var IDP_PATH = 'ServiceLogin?skipvpage=true&sarp=1&rm=hide';
17 var CONTINUE_URL = 17 var CONTINUE_URL =
18 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/success.html'; 18 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/success.html';
19 var SIGN_IN_HEADER = 'google-accounts-signin'; 19 var SIGN_IN_HEADER = 'google-accounts-signin';
20 var EMBEDDED_FORM_HEADER = 'google-accounts-embedded'; 20 var EMBEDDED_FORM_HEADER = 'google-accounts-embedded';
21 var SAML_HEADER = 'google-accounts-saml'; 21 var SAML_HEADER = 'google-accounts-saml';
22 var SERVICE_ID = 'chromeoslogin';
22 23
23 /** 24 /**
24 * The source URL parameter for the constrained signin flow. 25 * The source URL parameter for the constrained signin flow.
25 */ 26 */
26 var CONSTRAINED_FLOW_SOURCE = 'chrome'; 27 var CONSTRAINED_FLOW_SOURCE = 'chrome';
27 28
28 /** 29 /**
29 * Enum for the authorization mode, must match AuthMode defined in 30 * Enum for the authorization mode, must match AuthMode defined in
30 * chrome/browser/ui/webui/inline_login_ui.cc. 31 * chrome/browser/ui/webui/inline_login_ui.cc.
31 * @enum {number} 32 * @enum {number}
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 */ 160 */
160 Authenticator.prototype.reload = function() { 161 Authenticator.prototype.reload = function() {
161 this.webview_.src = this.reloadUrl_; 162 this.webview_.src = this.reloadUrl_;
162 this.authFlow_ = AuthFlow.DEFAULT; 163 this.authFlow_ = AuthFlow.DEFAULT;
163 }; 164 };
164 165
165 Authenticator.prototype.constructInitialFrameUrl_ = function(data) { 166 Authenticator.prototype.constructInitialFrameUrl_ = function(data) {
166 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH); 167 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH);
167 168
168 url = appendParam(url, 'continue', this.continueUrl_); 169 url = appendParam(url, 'continue', this.continueUrl_);
169 url = appendParam(url, 'service', data.service); 170 url = appendParam(url, 'service', data.service || SERVICE_ID);
170 if (data.hl) 171 if (data.hl)
171 url = appendParam(url, 'hl', data.hl); 172 url = appendParam(url, 'hl', data.hl);
172 if (data.email) 173 if (data.email)
173 url = appendParam(url, 'Email', data.email); 174 url = appendParam(url, 'Email', data.email);
174 if (this.isConstrainedWindow_) 175 if (this.isConstrainedWindow_)
175 url = appendParam(url, 'source', CONSTRAINED_FLOW_SOURCE); 176 url = appendParam(url, 'source', CONSTRAINED_FLOW_SOURCE);
176 return url; 177 return url;
177 }; 178 };
178 179
179 /** 180 /**
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return; 282 return;
282 } 283 }
283 284
284 if (!this.email_ && !this.skipForNow_) { 285 if (!this.email_ && !this.skipForNow_) {
285 this.webview_.src = this.initialFrameUrl_; 286 this.webview_.src = this.initialFrameUrl_;
286 return; 287 return;
287 } 288 }
288 289
289 this.listener_.onSuccess({email: this.email_, 290 this.listener_.onSuccess({email: this.email_,
290 gaiaId: this.gaiaId_, 291 gaiaId: this.gaiaId_,
291 password: this.password_, 292 password: this.password_ || '',
292 usingSAML: this.authFlow_ == AuthFlow.SAML, 293 usingSAML: this.authFlow_ == AuthFlow.SAML,
293 chooseWhatToSync: this.chooseWhatToSync_, 294 chooseWhatToSync: this.chooseWhatToSync_,
294 skipForNow: this.skipForNow_, 295 skipForNow: this.skipForNow_,
295 sessionIndex: this.sessionIndex_ || ''}); 296 sessionIndex: this.sessionIndex_ || ''});
296 }; 297 };
297 298
298 /** 299 /**
299 * Invoked when the webview attempts to open a new window. 300 * Invoked when the webview attempts to open a new window.
300 * @private 301 * @private
301 */ 302 */
302 Authenticator.prototype.onNewWindow_ = function(e) { 303 Authenticator.prototype.onNewWindow_ = function(e) {
303 if (!this.listener_) { 304 if (!this.listener_) {
304 return; 305 return;
305 } 306 }
306 307
307 this.listener_.onNewWindow(e); 308 this.listener_.onNewWindow(e);
308 }; 309 };
309 310
310 Authenticator.AuthFlow = AuthFlow; 311 Authenticator.AuthFlow = AuthFlow;
311 Authenticator.AuthMode = AuthMode; 312 Authenticator.AuthMode = AuthMode;
312 313
313 return { 314 return {
314 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old 315 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old
315 // iframe-based flow is deprecated. 316 // iframe-based flow is deprecated.
316 GaiaAuthHost: Authenticator 317 GaiaAuthHost: Authenticator
317 }; 318 };
318 }); 319 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698