| OLD | NEW |
| 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 <include src="saml_handler.js"> | 5 <include src="saml_handler.js"> |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @fileoverview An UI component to authenciate to Chrome. The component hosts | 8 * @fileoverview An UI component to authenciate to Chrome. The component hosts |
| 9 * IdP web pages in a webview. A client who is interested in monitoring | 9 * IdP web pages in a webview. A client who is interested in monitoring |
| 10 * authentication events should pass a listener object of type | 10 * authentication events should pass a listener object of type |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 * @param {object} e Payload of the received HTML5 message. | 505 * @param {object} e Payload of the received HTML5 message. |
| 506 * @private | 506 * @private |
| 507 */ | 507 */ |
| 508 Authenticator.prototype.onMessageFromWebview_ = function(e) { | 508 Authenticator.prototype.onMessageFromWebview_ = function(e) { |
| 509 if (!this.isGaiaMessage(e)) | 509 if (!this.isGaiaMessage(e)) |
| 510 return; | 510 return; |
| 511 | 511 |
| 512 var msg = e.data; | 512 var msg = e.data; |
| 513 if (msg.method == 'attemptLogin') { | 513 if (msg.method == 'attemptLogin') { |
| 514 this.email_ = msg.email; | 514 this.email_ = msg.email; |
| 515 this.password_ = msg.password; | |
| 516 this.chooseWhatToSync_ = msg.chooseWhatToSync; | 515 this.chooseWhatToSync_ = msg.chooseWhatToSync; |
| 517 // We need to dispatch only first event, before user enters password. | 516 // We need to dispatch only first event, before user enters password. |
| 518 if (!msg.password) { | 517 this.dispatchEvent( |
| 519 this.dispatchEvent( | 518 new CustomEvent('attemptLogin', {detail: msg.email})); |
| 520 new CustomEvent('attemptLogin', {detail: msg.email})); | |
| 521 } | |
| 522 } else if (msg.method == 'dialogShown') { | 519 } else if (msg.method == 'dialogShown') { |
| 523 this.dispatchEvent(new Event('dialogShown')); | 520 this.dispatchEvent(new Event('dialogShown')); |
| 524 } else if (msg.method == 'dialogHidden') { | 521 } else if (msg.method == 'dialogHidden') { |
| 525 this.dispatchEvent(new Event('dialogHidden')); | 522 this.dispatchEvent(new Event('dialogHidden')); |
| 526 } else if (msg.method == 'backButton') { | 523 } else if (msg.method == 'backButton') { |
| 527 this.dispatchEvent(new CustomEvent('backButton', {detail: msg.show})); | 524 this.dispatchEvent(new CustomEvent('backButton', {detail: msg.show})); |
| 528 } else if (msg.method == 'showView') { | 525 } else if (msg.method == 'showView') { |
| 529 this.dispatchEvent(new Event('showView')); | 526 this.dispatchEvent(new Event('showView')); |
| 530 } else if (msg.method == 'identifierEntered') { | 527 } else if (msg.method == 'identifierEntered') { |
| 531 this.dispatchEvent(new CustomEvent( | 528 this.dispatchEvent(new CustomEvent( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 572 |
| 576 if (this.samlHandler_.samlApiUsed) { | 573 if (this.samlHandler_.samlApiUsed) { |
| 577 if (this.samlApiUsedCallback) { | 574 if (this.samlApiUsedCallback) { |
| 578 this.samlApiUsedCallback(); | 575 this.samlApiUsedCallback(); |
| 579 } | 576 } |
| 580 this.password_ = this.samlHandler_.apiPasswordBytes; | 577 this.password_ = this.samlHandler_.apiPasswordBytes; |
| 581 this.onAuthCompleted_(); | 578 this.onAuthCompleted_(); |
| 582 return; | 579 return; |
| 583 } | 580 } |
| 584 | 581 |
| 585 // TODO(achuith): Eliminate this branch when credential passing api is | |
| 586 // stable on prod. crbug.com/467778. | |
| 587 if (this.authFlow != AuthFlow.SAML) { | |
| 588 this.onAuthCompleted_(); | |
| 589 return; | |
| 590 } | |
| 591 | |
| 592 if (this.samlHandler_.scrapedPasswordCount == 0) { | 582 if (this.samlHandler_.scrapedPasswordCount == 0) { |
| 593 if (this.noPasswordCallback) { | 583 if (this.noPasswordCallback) { |
| 594 this.noPasswordCallback(this.email_); | 584 this.noPasswordCallback(this.email_); |
| 595 return; | 585 return; |
| 596 } | 586 } |
| 597 | 587 |
| 598 // Fall through to finish the auth flow even if this.needPassword | 588 // Fall through to finish the auth flow even if this.needPassword |
| 599 // is true. This is because the flag is used as an intention to get | 589 // is true. This is because the flag is used as an intention to get |
| 600 // password when it is available but not a mandatory requirement. | 590 // password when it is available but not a mandatory requirement. |
| 601 console.warn('Authenticator: No password scraped for SAML.'); | 591 console.warn('Authenticator: No password scraped for SAML.'); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 Authenticator.AuthMode = AuthMode; | 767 Authenticator.AuthMode = AuthMode; |
| 778 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; | 768 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; |
| 779 | 769 |
| 780 return { | 770 return { |
| 781 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old | 771 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old |
| 782 // iframe-based flow is deprecated. | 772 // iframe-based flow is deprecated. |
| 783 GaiaAuthHost: Authenticator, | 773 GaiaAuthHost: Authenticator, |
| 784 Authenticator: Authenticator | 774 Authenticator: Authenticator |
| 785 }; | 775 }; |
| 786 }); | 776 }); |
| OLD | NEW |