| 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', |
| 25 'doReload', | 26 'doReload', |
| 26 'onFrameError', | 27 'onFrameError', |
| 27 'updateCancelButtonState' | 28 'updateCancelButtonState' |
| 28 ], | 29 ], |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * Frame loading error code (0 - no error). | 32 * Frame loading error code (0 - no error). |
| 32 * @type {number} | 33 * @type {number} |
| 33 * @private | 34 * @private |
| 34 */ | 35 */ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 * SAML password confirmation attempt count. | 87 * SAML password confirmation attempt count. |
| 87 * @type {number} | 88 * @type {number} |
| 88 */ | 89 */ |
| 89 samlPasswordConfirmAttempt_: 0, | 90 samlPasswordConfirmAttempt_: 0, |
| 90 | 91 |
| 91 /** @override */ | 92 /** @override */ |
| 92 decorate: function() { | 93 decorate: function() { |
| 93 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); | 94 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); |
| 94 this.gaiaAuthHost_.addEventListener( | 95 this.gaiaAuthHost_.addEventListener( |
| 95 'ready', this.onAuthReady_.bind(this)); | 96 'ready', this.onAuthReady_.bind(this)); |
| 97 this.gaiaAuthHost_.retrieveAuthenticatedUserEmailCallback = |
| 98 this.onRetrieveAuthenticatedUserEmail_.bind(this); |
| 96 this.gaiaAuthHost_.confirmPasswordCallback = | 99 this.gaiaAuthHost_.confirmPasswordCallback = |
| 97 this.onAuthConfirmPassword_.bind(this); | 100 this.onAuthConfirmPassword_.bind(this); |
| 98 this.gaiaAuthHost_.noPasswordCallback = | 101 this.gaiaAuthHost_.noPasswordCallback = |
| 99 this.onAuthNoPassword_.bind(this); | 102 this.onAuthNoPassword_.bind(this); |
| 100 this.gaiaAuthHost_.insecureContentBlockedCallback = | 103 this.gaiaAuthHost_.insecureContentBlockedCallback = |
| 101 this.onInsecureContentBlocked_.bind(this); | 104 this.onInsecureContentBlocked_.bind(this); |
| 102 this.gaiaAuthHost_.missingGaiaInfoCallback = | |
| 103 this.missingGaiaInfo_.bind(this); | |
| 104 this.gaiaAuthHost_.samlApiUsedCallback = | |
| 105 this.samlApiUsed_.bind(this); | |
| 106 this.gaiaAuthHost_.addEventListener('authFlowChange', | 105 this.gaiaAuthHost_.addEventListener('authFlowChange', |
| 107 this.onAuthFlowChange_.bind(this)); | 106 this.onAuthFlowChange_.bind(this)); |
| 108 | 107 |
| 109 $('enterprise-info-hint-link').addEventListener('click', function(e) { | 108 $('enterprise-info-hint-link').addEventListener('click', function(e) { |
| 110 chrome.send('launchHelpApp', [HELP_TOPIC_ENTERPRISE_REPORTING]); | 109 chrome.send('launchHelpApp', [HELP_TOPIC_ENTERPRISE_REPORTING]); |
| 111 e.preventDefault(); | 110 e.preventDefault(); |
| 112 }); | 111 }); |
| 113 | 112 |
| 114 | 113 |
| 115 this.updateLocalizedContent(); | 114 this.updateLocalizedContent(); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 $('createAccount').hidden && | 331 $('createAccount').hidden && |
| 333 $('guestSignin').hidden && | 332 $('guestSignin').hidden && |
| 334 $('createSupervisedUserPane').hidden && | 333 $('createSupervisedUserPane').hidden && |
| 335 $('consumerManagementEnrollment').hidden; | 334 $('consumerManagementEnrollment').hidden; |
| 336 this.classList.toggle('no-right-panel', noRightPanel); | 335 this.classList.toggle('no-right-panel', noRightPanel); |
| 337 if (Oobe.getInstance().currentScreen === this) | 336 if (Oobe.getInstance().currentScreen === this) |
| 338 Oobe.getInstance().updateScreenSize(this); | 337 Oobe.getInstance().updateScreenSize(this); |
| 339 }, | 338 }, |
| 340 | 339 |
| 341 /** | 340 /** |
| 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 /** |
| 342 * Updates [Cancel] button state. Allow cancellation of screen only when | 356 * Updates [Cancel] button state. Allow cancellation of screen only when |
| 343 * user pods can be displayed. | 357 * user pods can be displayed. |
| 344 */ | 358 */ |
| 345 updateCancelButtonState: function() { | 359 updateCancelButtonState: function() { |
| 346 this.cancelAllowed_ = this.isShowUsers_ && $('pod-row').pods.length; | 360 this.cancelAllowed_ = this.isShowUsers_ && $('pod-row').pods.length; |
| 347 $('login-header-bar').allowCancel = this.cancelAllowed_; | 361 $('login-header-bar').allowCancel = this.cancelAllowed_; |
| 348 }, | 362 }, |
| 349 | 363 |
| 350 /** | 364 /** |
| 351 * Whether the current auth flow is SAML. | 365 * Whether the current auth flow is SAML. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 406 } |
| 393 | 407 |
| 394 chrome.send('loginWebuiReady'); | 408 chrome.send('loginWebuiReady'); |
| 395 chrome.send('loginVisible', ['gaia-signin']); | 409 chrome.send('loginVisible', ['gaia-signin']); |
| 396 | 410 |
| 397 // Warm up the user images screen. | 411 // Warm up the user images screen. |
| 398 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); | 412 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); |
| 399 }, | 413 }, |
| 400 | 414 |
| 401 /** | 415 /** |
| 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 /** |
| 402 * Invoked when the user has successfully authenticated via SAML, the | 437 * Invoked when the user has successfully authenticated via SAML, the |
| 403 * principals API was not used and the auth host needs the user to confirm | 438 * principals API was not used and the auth host needs the user to confirm |
| 404 * the scraped password. | 439 * the scraped password. |
| 405 * @param {number} passwordCount The number of passwords that were scraped. | 440 * @param {number} passwordCount The number of passwords that were scraped. |
| 406 * @private | 441 * @private |
| 407 */ | 442 */ |
| 408 onAuthConfirmPassword_: function(passwordCount) { | 443 onAuthConfirmPassword_: function(passwordCount) { |
| 409 this.loading = true; | 444 this.loading = true; |
| 410 Oobe.getInstance().headerHidden = false; | 445 Oobe.getInstance().headerHidden = false; |
| 411 | 446 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 496 |
| 462 /** | 497 /** |
| 463 * Shows the fatal auth error. | 498 * Shows the fatal auth error. |
| 464 * @param {string} message The error message to show. | 499 * @param {string} message The error message to show. |
| 465 */ | 500 */ |
| 466 showFatalAuthError: function(message) { | 501 showFatalAuthError: function(message) { |
| 467 login.FatalErrorScreen.show(message, Oobe.showSigninUI); | 502 login.FatalErrorScreen.show(message, Oobe.showSigninUI); |
| 468 }, | 503 }, |
| 469 | 504 |
| 470 /** | 505 /** |
| 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 /** | |
| 486 * Invoked when auth is completed successfully. | 506 * Invoked when auth is completed successfully. |
| 487 * @param {!Object} credentials Credentials of the completed authentication. | 507 * @param {!Object} credentials Credentials of the completed authentication. |
| 488 * @private | 508 * @private |
| 489 */ | 509 */ |
| 490 onAuthCompleted_: function(credentials) { | 510 onAuthCompleted_: function(credentials) { |
| 491 if (credentials.useOffline) { | 511 if (credentials.useOffline) { |
| 492 this.email = credentials.email; | 512 this.email = credentials.email; |
| 493 chrome.send('authenticateUser', | 513 chrome.send('authenticateUser', |
| 494 [credentials.gaiaId, | 514 [credentials.email, credentials.password]); |
| 495 credentials.email, | |
| 496 credentials.password]); | |
| 497 } else if (credentials.authCode) { | 515 } else if (credentials.authCode) { |
| 498 chrome.send('completeAuthentication', | 516 chrome.send('completeAuthentication', |
| 499 [credentials.gaiaId, | 517 [credentials.email, |
| 500 credentials.email, | |
| 501 credentials.password, | 518 credentials.password, |
| 502 credentials.authCode]); | 519 credentials.authCode]); |
| 503 } else { | 520 } else { |
| 504 chrome.send('completeLogin', | 521 chrome.send('completeLogin', |
| 505 [credentials.gaiaId, | 522 [credentials.email, |
| 506 credentials.email, | |
| 507 credentials.password, | 523 credentials.password, |
| 508 credentials.usingSAML]); | 524 credentials.usingSAML]); |
| 509 } | 525 } |
| 510 | 526 |
| 511 this.loading = true; | 527 this.loading = true; |
| 512 // Now that we're in logged in state header should be hidden. | 528 // Now that we're in logged in state header should be hidden. |
| 513 Oobe.getInstance().headerHidden = true; | 529 Oobe.getInstance().headerHidden = true; |
| 514 // Clear any error messages that were shown before login. | 530 // Clear any error messages that were shown before login. |
| 515 Oobe.clearErrors(); | 531 Oobe.clearErrors(); |
| 516 }, | 532 }, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 * For more info see C++ class 'WebUILoginView' which calls this method. | 648 * For more info see C++ class 'WebUILoginView' which calls this method. |
| 633 * @param {number} error Error code. | 649 * @param {number} error Error code. |
| 634 * @param {string} url The URL that failed to load. | 650 * @param {string} url The URL that failed to load. |
| 635 */ | 651 */ |
| 636 onFrameError: function(error, url) { | 652 onFrameError: function(error, url) { |
| 637 this.error_ = error; | 653 this.error_ = error; |
| 638 chrome.send('frameLoadingCompleted', [this.error_]); | 654 chrome.send('frameLoadingCompleted', [this.error_]); |
| 639 }, | 655 }, |
| 640 }; | 656 }; |
| 641 }); | 657 }); |
| OLD | NEW |