OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 Oobe signin screen implementation. | 6 * @fileoverview Oobe signin screen implementation. |
7 */ | 7 */ |
8 | 8 |
9 <include src="../../gaia_auth_host/gaia_auth_host.js"> | 9 <include src="../../gaia_auth_host/gaia_auth_host.js"> |
10 | 10 |
11 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { | 11 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { |
12 // Gaia loading time after which error message must be displayed and | 12 // Gaia loading time after which error message must be displayed and |
13 // lazy portal check should be fired. | 13 // lazy portal check should be fired. |
14 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; | 14 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; |
15 | 15 |
16 // Maximum Gaia loading time in seconds. | 16 // Maximum Gaia loading time in seconds. |
17 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; | 17 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; |
18 | 18 |
19 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; | 19 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; |
20 | 20 |
21 return { | 21 return { |
22 EXTERNAL_API: [ | 22 EXTERNAL_API: [ |
23 'loadAuthExtension', | 23 'loadAuthExtension', |
24 'updateAuthExtension', | 24 'updateAuthExtension', |
25 'setAuthenticatedUserEmail', | |
26 'doReload', | 25 'doReload', |
27 'onFrameError', | 26 'onFrameError', |
28 'updateCancelButtonState' | 27 'updateCancelButtonState' |
29 ], | 28 ], |
30 | 29 |
31 /** | 30 /** |
32 * Frame loading error code (0 - no error). | 31 * Frame loading error code (0 - no error). |
33 * @type {number} | 32 * @type {number} |
34 * @private | 33 * @private |
35 */ | 34 */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 * SAML password confirmation attempt count. | 86 * SAML password confirmation attempt count. |
88 * @type {number} | 87 * @type {number} |
89 */ | 88 */ |
90 samlPasswordConfirmAttempt_: 0, | 89 samlPasswordConfirmAttempt_: 0, |
91 | 90 |
92 /** @override */ | 91 /** @override */ |
93 decorate: function() { | 92 decorate: function() { |
94 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); | 93 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); |
95 this.gaiaAuthHost_.addEventListener( | 94 this.gaiaAuthHost_.addEventListener( |
96 'ready', this.onAuthReady_.bind(this)); | 95 'ready', this.onAuthReady_.bind(this)); |
97 this.gaiaAuthHost_.retrieveAuthenticatedUserEmailCallback = | |
98 this.onRetrieveAuthenticatedUserEmail_.bind(this); | |
99 this.gaiaAuthHost_.confirmPasswordCallback = | 96 this.gaiaAuthHost_.confirmPasswordCallback = |
100 this.onAuthConfirmPassword_.bind(this); | 97 this.onAuthConfirmPassword_.bind(this); |
101 this.gaiaAuthHost_.noPasswordCallback = | 98 this.gaiaAuthHost_.noPasswordCallback = |
102 this.onAuthNoPassword_.bind(this); | 99 this.onAuthNoPassword_.bind(this); |
103 this.gaiaAuthHost_.insecureContentBlockedCallback = | 100 this.gaiaAuthHost_.insecureContentBlockedCallback = |
104 this.onInsecureContentBlocked_.bind(this); | 101 this.onInsecureContentBlocked_.bind(this); |
| 102 this.gaiaAuthHost_.missingGaiaInfoCallback = |
| 103 this.missingGaiaInfo_.bind(this); |
| 104 this.gaiaAuthHost_.samlApiUsedCallback = |
| 105 this.samlApiUsed_.bind(this); |
105 this.gaiaAuthHost_.addEventListener('authFlowChange', | 106 this.gaiaAuthHost_.addEventListener('authFlowChange', |
106 this.onAuthFlowChange_.bind(this)); | 107 this.onAuthFlowChange_.bind(this)); |
107 | 108 |
108 $('enterprise-info-hint-link').addEventListener('click', function(e) { | 109 $('enterprise-info-hint-link').addEventListener('click', function(e) { |
109 chrome.send('launchHelpApp', [HELP_TOPIC_ENTERPRISE_REPORTING]); | 110 chrome.send('launchHelpApp', [HELP_TOPIC_ENTERPRISE_REPORTING]); |
110 e.preventDefault(); | 111 e.preventDefault(); |
111 }); | 112 }); |
112 | 113 |
113 | 114 |
114 this.updateLocalizedContent(); | 115 this.updateLocalizedContent(); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 $('createAccount').hidden && | 332 $('createAccount').hidden && |
332 $('guestSignin').hidden && | 333 $('guestSignin').hidden && |
333 $('createSupervisedUserPane').hidden && | 334 $('createSupervisedUserPane').hidden && |
334 $('consumerManagementEnrollment').hidden; | 335 $('consumerManagementEnrollment').hidden; |
335 this.classList.toggle('no-right-panel', noRightPanel); | 336 this.classList.toggle('no-right-panel', noRightPanel); |
336 if (Oobe.getInstance().currentScreen === this) | 337 if (Oobe.getInstance().currentScreen === this) |
337 Oobe.getInstance().updateScreenSize(this); | 338 Oobe.getInstance().updateScreenSize(this); |
338 }, | 339 }, |
339 | 340 |
340 /** | 341 /** |
341 * Sends the authenticated user's e-mail address to the auth extension. | |
342 * @param {number} attemptToken The opaque token provided to | |
343 * onRetrieveAuthenticatedUserEmail_. | |
344 * @param {string} email The authenticated user's e-mail address. | |
345 */ | |
346 setAuthenticatedUserEmail: function(attemptToken, email) { | |
347 if (!email) { | |
348 this.showFatalAuthError( | |
349 loadTimeData.getString('fatalErrorMessageNoEmail')); | |
350 } else { | |
351 this.gaiaAuthHost_.setAuthenticatedUserEmail(attemptToken, email); | |
352 } | |
353 }, | |
354 | |
355 /** | |
356 * Updates [Cancel] button state. Allow cancellation of screen only when | 342 * Updates [Cancel] button state. Allow cancellation of screen only when |
357 * user pods can be displayed. | 343 * user pods can be displayed. |
358 */ | 344 */ |
359 updateCancelButtonState: function() { | 345 updateCancelButtonState: function() { |
360 this.cancelAllowed_ = this.isShowUsers_ && $('pod-row').pods.length; | 346 this.cancelAllowed_ = this.isShowUsers_ && $('pod-row').pods.length; |
361 $('login-header-bar').allowCancel = this.cancelAllowed_; | 347 $('login-header-bar').allowCancel = this.cancelAllowed_; |
362 }, | 348 }, |
363 | 349 |
364 /** | 350 /** |
365 * Whether the current auth flow is SAML. | 351 * Whether the current auth flow is SAML. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 392 } |
407 | 393 |
408 chrome.send('loginWebuiReady'); | 394 chrome.send('loginWebuiReady'); |
409 chrome.send('loginVisible', ['gaia-signin']); | 395 chrome.send('loginVisible', ['gaia-signin']); |
410 | 396 |
411 // Warm up the user images screen. | 397 // Warm up the user images screen. |
412 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); | 398 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); |
413 }, | 399 }, |
414 | 400 |
415 /** | 401 /** |
416 * Invoked when the user has successfully authenticated via SAML and the | |
417 * auth host needs to retrieve the user's e-mail. | |
418 * @param {number} attemptToken Opaque token to be passed to | |
419 * setAuthenticatedUserEmail along with the e-mail address. | |
420 * @param {boolean} apiUsed Whether the principals API was used during | |
421 * authentication. | |
422 * @private | |
423 */ | |
424 onRetrieveAuthenticatedUserEmail_: function(attemptToken, apiUsed) { | |
425 if (apiUsed) { | |
426 // If the principals API was used, report this to the C++ backend so | |
427 // that statistics can be kept. If password scraping was used instead, | |
428 // there is no need to inform the C++ backend at this point: Either | |
429 // onAuthNoPassword_ or onAuthConfirmPassword_ will be called in a | |
430 // moment, both of which imply to the backend that the API was not used. | |
431 chrome.send('usingSAMLAPI'); | |
432 } | |
433 chrome.send('retrieveAuthenticatedUserEmail', [attemptToken]); | |
434 }, | |
435 | |
436 /** | |
437 * Invoked when the user has successfully authenticated via SAML, the | 402 * Invoked when the user has successfully authenticated via SAML, the |
438 * principals API was not used and the auth host needs the user to confirm | 403 * principals API was not used and the auth host needs the user to confirm |
439 * the scraped password. | 404 * the scraped password. |
440 * @param {number} passwordCount The number of passwords that were scraped. | 405 * @param {number} passwordCount The number of passwords that were scraped. |
441 * @private | 406 * @private |
442 */ | 407 */ |
443 onAuthConfirmPassword_: function(passwordCount) { | 408 onAuthConfirmPassword_: function(passwordCount) { |
444 this.loading = true; | 409 this.loading = true; |
445 Oobe.getInstance().headerHidden = false; | 410 Oobe.getInstance().headerHidden = false; |
446 | 411 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 461 |
497 /** | 462 /** |
498 * Shows the fatal auth error. | 463 * Shows the fatal auth error. |
499 * @param {string} message The error message to show. | 464 * @param {string} message The error message to show. |
500 */ | 465 */ |
501 showFatalAuthError: function(message) { | 466 showFatalAuthError: function(message) { |
502 login.FatalErrorScreen.show(message, Oobe.showSigninUI); | 467 login.FatalErrorScreen.show(message, Oobe.showSigninUI); |
503 }, | 468 }, |
504 | 469 |
505 /** | 470 /** |
| 471 * Show fatal auth error when information is missing from GAIA. |
| 472 */ |
| 473 missingGaiaInfo_: function() { |
| 474 this.showFatalAuthError( |
| 475 loadTimeData.getString('fatalErrorMessageNoAccountDetails')); |
| 476 }, |
| 477 |
| 478 /** |
| 479 * Record that SAML API was used during sign-in. |
| 480 */ |
| 481 samlApiUsed_: function() { |
| 482 chrome.send('usingSAMLAPI'); |
| 483 }, |
| 484 |
| 485 /** |
506 * Invoked when auth is completed successfully. | 486 * Invoked when auth is completed successfully. |
507 * @param {!Object} credentials Credentials of the completed authentication. | 487 * @param {!Object} credentials Credentials of the completed authentication. |
508 * @private | 488 * @private |
509 */ | 489 */ |
510 onAuthCompleted_: function(credentials) { | 490 onAuthCompleted_: function(credentials) { |
511 if (credentials.useOffline) { | 491 if (credentials.useOffline) { |
512 this.email = credentials.email; | 492 this.email = credentials.email; |
513 chrome.send('authenticateUser', | 493 chrome.send('authenticateUser', |
514 [credentials.email, credentials.password]); | 494 [credentials.gaiaId, |
| 495 credentials.email, |
| 496 credentials.password]); |
515 } else if (credentials.authCode) { | 497 } else if (credentials.authCode) { |
516 chrome.send('completeAuthentication', | 498 chrome.send('completeAuthentication', |
517 [credentials.email, | 499 [credentials.gaiaId, |
| 500 credentials.email, |
518 credentials.password, | 501 credentials.password, |
519 credentials.authCode]); | 502 credentials.authCode]); |
520 } else { | 503 } else { |
521 chrome.send('completeLogin', | 504 chrome.send('completeLogin', |
522 [credentials.email, | 505 [credentials.gaiaId, |
| 506 credentials.email, |
523 credentials.password, | 507 credentials.password, |
524 credentials.usingSAML]); | 508 credentials.usingSAML]); |
525 } | 509 } |
526 | 510 |
527 this.loading = true; | 511 this.loading = true; |
528 // Now that we're in logged in state header should be hidden. | 512 // Now that we're in logged in state header should be hidden. |
529 Oobe.getInstance().headerHidden = true; | 513 Oobe.getInstance().headerHidden = true; |
530 // Clear any error messages that were shown before login. | 514 // Clear any error messages that were shown before login. |
531 Oobe.clearErrors(); | 515 Oobe.clearErrors(); |
532 }, | 516 }, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 * For more info see C++ class 'WebUILoginView' which calls this method. | 632 * For more info see C++ class 'WebUILoginView' which calls this method. |
649 * @param {number} error Error code. | 633 * @param {number} error Error code. |
650 * @param {string} url The URL that failed to load. | 634 * @param {string} url The URL that failed to load. |
651 */ | 635 */ |
652 onFrameError: function(error, url) { | 636 onFrameError: function(error, url) { |
653 this.error_ = error; | 637 this.error_ = error; |
654 chrome.send('frameLoadingCompleted', [this.error_]); | 638 chrome.send('frameLoadingCompleted', [this.error_]); |
655 }, | 639 }, |
656 }; | 640 }; |
657 }); | 641 }); |
OLD | NEW |