| 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"></include> | 9 <include src="../../gaia_auth_host/gaia_auth_host.js"></include> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 */ | 61 */ |
| 62 loadingTimer_: undefined, | 62 loadingTimer_: undefined, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Whether user can cancel Gaia screen. | 65 * Whether user can cancel Gaia screen. |
| 66 * @type {boolean} | 66 * @type {boolean} |
| 67 * @private | 67 * @private |
| 68 */ | 68 */ |
| 69 cancelAllowed_: undefined, | 69 cancelAllowed_: undefined, |
| 70 | 70 |
| 71 /** |
| 72 * SAML password confirmation attempt count. |
| 73 * @type {number} |
| 74 */ |
| 75 samlPasswordConfirmAttempt_: 0, |
| 76 |
| 71 /** @override */ | 77 /** @override */ |
| 72 decorate: function() { | 78 decorate: function() { |
| 73 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); | 79 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); |
| 74 this.gaiaAuthHost_.addEventListener( | 80 this.gaiaAuthHost_.addEventListener( |
| 75 'ready', this.onAuthReady_.bind(this)); | 81 'ready', this.onAuthReady_.bind(this)); |
| 76 this.gaiaAuthHost_.retrieveAuthenticatedUserEmailCallback = | 82 this.gaiaAuthHost_.retrieveAuthenticatedUserEmailCallback = |
| 77 this.onRetrieveAuthenticatedUserEmail_.bind(this); | 83 this.onRetrieveAuthenticatedUserEmail_.bind(this); |
| 78 this.gaiaAuthHost_.confirmPasswordCallback = | 84 this.gaiaAuthHost_.confirmPasswordCallback = |
| 79 this.onAuthConfirmPassword_.bind(this); | 85 this.onAuthConfirmPassword_.bind(this); |
| 80 this.gaiaAuthHost_.noPasswordCallback = | 86 this.gaiaAuthHost_.noPasswordCallback = |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 }, | 226 }, |
| 221 | 227 |
| 222 /** | 228 /** |
| 223 * Loads the authentication extension into the iframe. | 229 * Loads the authentication extension into the iframe. |
| 224 * @param {Object} data Extension parameters bag. | 230 * @param {Object} data Extension parameters bag. |
| 225 * @private | 231 * @private |
| 226 */ | 232 */ |
| 227 loadAuthExtension: function(data) { | 233 loadAuthExtension: function(data) { |
| 228 this.isLocal = data.isLocal; | 234 this.isLocal = data.isLocal; |
| 229 this.email = ''; | 235 this.email = ''; |
| 236 |
| 237 // Reset SAML |
| 230 this.classList.toggle('saml', false); | 238 this.classList.toggle('saml', false); |
| 239 this.samlPasswordConfirmAttempt_ = 0; |
| 231 | 240 |
| 232 this.updateAuthExtension(data); | 241 this.updateAuthExtension(data); |
| 233 | 242 |
| 234 var params = {}; | 243 var params = {}; |
| 235 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) { | 244 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) { |
| 236 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i]; | 245 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i]; |
| 237 if (data[name]) | 246 if (data[name]) |
| 238 params[name] = data[name]; | 247 params[name] = data[name]; |
| 239 } | 248 } |
| 240 | 249 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 }, | 380 }, |
| 372 | 381 |
| 373 /** | 382 /** |
| 374 * Invoked when the auth host needs the user to confirm password. | 383 * Invoked when the auth host needs the user to confirm password. |
| 375 * @private | 384 * @private |
| 376 */ | 385 */ |
| 377 onAuthConfirmPassword_: function() { | 386 onAuthConfirmPassword_: function() { |
| 378 this.loading = true; | 387 this.loading = true; |
| 379 Oobe.getInstance().headerHidden = false; | 388 Oobe.getInstance().headerHidden = false; |
| 380 | 389 |
| 381 login.ConfirmPasswordScreen.show( | 390 if (this.samlPasswordConfirmAttempt_ <= 1) { |
| 382 this.onConfirmPasswordCollected_.bind(this)); | 391 login.ConfirmPasswordScreen.show( |
| 392 this.samlPasswordConfirmAttempt_, |
| 393 this.onConfirmPasswordCollected_.bind(this)); |
| 394 } else { |
| 395 this.showFatalAuthError(); |
| 396 } |
| 383 }, | 397 }, |
| 384 | 398 |
| 385 /** | 399 /** |
| 386 * Invoked when the confirm password screen is dismissed. | 400 * Invoked when the confirm password screen is dismissed. |
| 387 * @private | 401 * @private |
| 388 */ | 402 */ |
| 389 onConfirmPasswordCollected_: function(password) { | 403 onConfirmPasswordCollected_: function(password) { |
| 404 this.samlPasswordConfirmAttempt_++; |
| 390 this.gaiaAuthHost_.verifyConfirmedPassword(password); | 405 this.gaiaAuthHost_.verifyConfirmedPassword(password); |
| 391 | 406 |
| 392 // Shows signin UI again without changing states. | 407 // Shows signin UI again without changing states. |
| 393 Oobe.showScreen({id: SCREEN_GAIA_SIGNIN}); | 408 Oobe.showScreen({id: SCREEN_GAIA_SIGNIN}); |
| 394 }, | 409 }, |
| 395 | 410 |
| 396 /** | 411 /** |
| 397 * Inovked when the auth flow completes but no password is available. | 412 * Inovked when the auth flow completes but no password is available. |
| 398 * @param {string} email The authenticated user email. | 413 * @param {string} email The authenticated user email. |
| 399 */ | 414 */ |
| 400 onAuthNoPassword_: function(email) { | 415 onAuthNoPassword_: function(email) { |
| 401 login.MessageBoxScreen.show( | 416 this.showFatalAuthError(); |
| 402 loadTimeData.getString('noPasswordWarningTitle'), | |
| 403 loadTimeData.getString('noPasswordWarningBody'), | |
| 404 loadTimeData.getString('noPasswordWarningOkButton'), | |
| 405 Oobe.showSigninUI); | |
| 406 }, | 417 }, |
| 407 | 418 |
| 408 /** | 419 /** |
| 420 * Shows the fatal auth error. |
| 421 */ |
| 422 showFatalAuthError: function() { |
| 423 login.FatalErrorScreen.show(Oobe.showSigninUI); |
| 424 }, |
| 425 |
| 426 /** |
| 409 * Invoked when auth is completed successfully. | 427 * Invoked when auth is completed successfully. |
| 410 * @param {!Object} credentials Credentials of the completed authentication. | 428 * @param {!Object} credentials Credentials of the completed authentication. |
| 411 * @private | 429 * @private |
| 412 */ | 430 */ |
| 413 onAuthCompleted_: function(credentials) { | 431 onAuthCompleted_: function(credentials) { |
| 414 if (credentials.useOffline) { | 432 if (credentials.useOffline) { |
| 415 this.email = credentials.email; | 433 this.email = credentials.email; |
| 416 chrome.send('authenticateUser', | 434 chrome.send('authenticateUser', |
| 417 [credentials.email, credentials.password]); | 435 [credentials.email, credentials.password]); |
| 418 } else if (credentials.authCode) { | 436 } else if (credentials.authCode) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 * Handler for iframe's error notification coming from the outside. | 565 * Handler for iframe's error notification coming from the outside. |
| 548 * For more info see C++ class 'SnifferObserver' which calls this method. | 566 * For more info see C++ class 'SnifferObserver' which calls this method. |
| 549 * @param {number} error Error code. | 567 * @param {number} error Error code. |
| 550 */ | 568 */ |
| 551 onFrameError: function(error) { | 569 onFrameError: function(error) { |
| 552 this.error_ = error; | 570 this.error_ = error; |
| 553 chrome.send('frameLoadingCompleted', [this.error_]); | 571 chrome.send('frameLoadingCompleted', [this.error_]); |
| 554 }, | 572 }, |
| 555 }; | 573 }; |
| 556 }); | 574 }); |
| OLD | NEW |