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"> | |
10 | |
11 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { | 9 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { |
12 // Gaia loading time after which error message must be displayed and | 10 // Gaia loading time after which error message must be displayed and |
13 // lazy portal check should be fired. | 11 // lazy portal check should be fired. |
14 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; | 12 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; |
15 | 13 |
16 // Maximum Gaia loading time in seconds. | 14 // Maximum Gaia loading time in seconds. |
17 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; | 15 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; |
18 | 16 |
19 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; | 17 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; |
20 | 18 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 * @private | 80 * @private |
83 */ | 81 */ |
84 isShowUsers_: undefined, | 82 isShowUsers_: undefined, |
85 | 83 |
86 /** | 84 /** |
87 * SAML password confirmation attempt count. | 85 * SAML password confirmation attempt count. |
88 * @type {number} | 86 * @type {number} |
89 */ | 87 */ |
90 samlPasswordConfirmAttempt_: 0, | 88 samlPasswordConfirmAttempt_: 0, |
91 | 89 |
| 90 /** |
| 91 * Whether we should show webview based signin. |
| 92 * @type {boolean} |
| 93 * @private |
| 94 */ |
| 95 isWebviewSignin: false, |
| 96 |
92 /** @override */ | 97 /** @override */ |
93 decorate: function() { | 98 decorate: function() { |
94 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); | 99 this.isWebviewSignin = loadTimeData.getValue('isWebviewSignin'); |
| 100 if (this.isWebviewSignin) { |
| 101 // Replace iframe with webview. |
| 102 var webview = this.ownerDocument.createElement('webview'); |
| 103 webview.id = 'signin-frame'; |
| 104 webview.name = 'signin-frame'; |
| 105 // TODO(dpolukhin): webview doesn't load page in hidden state, |
| 106 // use curtain instead. |
| 107 $('signin-frame').parentNode.replaceChild(webview, $('signin-frame')); |
| 108 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost(webview); |
| 109 } else { |
| 110 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); |
| 111 } |
95 this.gaiaAuthHost_.addEventListener( | 112 this.gaiaAuthHost_.addEventListener( |
96 'ready', this.onAuthReady_.bind(this)); | 113 'ready', this.onAuthReady_.bind(this)); |
97 this.gaiaAuthHost_.confirmPasswordCallback = | 114 this.gaiaAuthHost_.confirmPasswordCallback = |
98 this.onAuthConfirmPassword_.bind(this); | 115 this.onAuthConfirmPassword_.bind(this); |
99 this.gaiaAuthHost_.noPasswordCallback = | 116 this.gaiaAuthHost_.noPasswordCallback = |
100 this.onAuthNoPassword_.bind(this); | 117 this.onAuthNoPassword_.bind(this); |
101 this.gaiaAuthHost_.insecureContentBlockedCallback = | 118 this.gaiaAuthHost_.insecureContentBlockedCallback = |
102 this.onInsecureContentBlocked_.bind(this); | 119 this.onInsecureContentBlocked_.bind(this); |
103 this.gaiaAuthHost_.missingGaiaInfoCallback = | 120 this.gaiaAuthHost_.missingGaiaInfoCallback = |
104 this.missingGaiaInfo_.bind(this); | 121 this.missingGaiaInfo_.bind(this); |
105 this.gaiaAuthHost_.samlApiUsedCallback = | 122 this.gaiaAuthHost_.samlApiUsedCallback = |
106 this.samlApiUsed_.bind(this); | 123 this.samlApiUsed_.bind(this); |
107 this.gaiaAuthHost_.addEventListener('authFlowChange', | 124 this.gaiaAuthHost_.addEventListener('authFlowChange', |
108 this.onAuthFlowChange_.bind(this)); | 125 this.onAuthFlowChange_.bind(this)); |
| 126 this.gaiaAuthHost_.addEventListener('authCompleted', |
| 127 this.onAuthCompletedMessage_.bind(this)); |
109 | 128 |
110 $('enterprise-info-hint-link').addEventListener('click', function(e) { | 129 $('enterprise-info-hint-link').addEventListener('click', function(e) { |
111 chrome.send('launchHelpApp', [HELP_TOPIC_ENTERPRISE_REPORTING]); | 130 chrome.send('launchHelpApp', [HELP_TOPIC_ENTERPRISE_REPORTING]); |
112 e.preventDefault(); | 131 e.preventDefault(); |
113 }); | 132 }); |
114 | 133 |
115 | |
116 this.updateLocalizedContent(); | 134 this.updateLocalizedContent(); |
117 }, | 135 }, |
118 | 136 |
119 /** | 137 /** |
120 * Header text of the screen. | 138 * Header text of the screen. |
121 * @type {string} | 139 * @type {string} |
122 */ | 140 */ |
123 get header() { | 141 get header() { |
124 return loadTimeData.getString('signinScreenTitle'); | 142 return loadTimeData.getString('signinScreenTitle'); |
125 }, | 143 }, |
(...skipping 15 matching lines...) Expand all Loading... |
141 chrome.send('updateOfflineLogin', [value]); | 159 chrome.send('updateOfflineLogin', [value]); |
142 }, | 160 }, |
143 | 161 |
144 /** | 162 /** |
145 * Shows/hides loading UI. | 163 * Shows/hides loading UI. |
146 * @param {boolean} show True to show loading UI. | 164 * @param {boolean} show True to show loading UI. |
147 * @private | 165 * @private |
148 */ | 166 */ |
149 showLoadingUI_: function(show) { | 167 showLoadingUI_: function(show) { |
150 $('gaia-loading').hidden = !show; | 168 $('gaia-loading').hidden = !show; |
151 this.gaiaAuthHost_.frame.hidden = show; | 169 if (!this.isWebviewSignin) { |
| 170 // TODO(dpolukhin): proper implement curtain for webview signin. |
| 171 this.gaiaAuthHost_.frame.hidden = show; |
| 172 } |
152 $('signin-right').hidden = show; | 173 $('signin-right').hidden = show; |
153 $('enterprise-info-container').hidden = show; | 174 $('enterprise-info-container').hidden = show; |
154 $('gaia-signin-divider').hidden = show; | 175 $('gaia-signin-divider').hidden = show; |
155 }, | 176 }, |
156 | 177 |
157 /** | 178 /** |
158 * Handler for Gaia loading suspiciously long timeout. | 179 * Handler for Gaia loading suspiciously long timeout. |
159 * @private | 180 * @private |
160 */ | 181 */ |
161 onLoadingSuspiciouslyLong_: function() { | 182 onLoadingSuspiciouslyLong_: function() { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 538 } |
518 | 539 |
519 this.loading = true; | 540 this.loading = true; |
520 // Now that we're in logged in state header should be hidden. | 541 // Now that we're in logged in state header should be hidden. |
521 Oobe.getInstance().headerHidden = true; | 542 Oobe.getInstance().headerHidden = true; |
522 // Clear any error messages that were shown before login. | 543 // Clear any error messages that were shown before login. |
523 Oobe.clearErrors(); | 544 Oobe.clearErrors(); |
524 }, | 545 }, |
525 | 546 |
526 /** | 547 /** |
| 548 * Invoked when onAuthCompleted message received. |
| 549 * @param {!Object} e Payload of the received HTML5 message. |
| 550 * @private |
| 551 */ |
| 552 onAuthCompletedMessage_: function(e) { |
| 553 this.onAuthCompleted_(e.detail); |
| 554 }, |
| 555 |
| 556 /** |
527 * Clears input fields and switches to input mode. | 557 * Clears input fields and switches to input mode. |
528 * @param {boolean} takeFocus True to take focus. | 558 * @param {boolean} takeFocus True to take focus. |
529 * @param {boolean} forceOnline Whether online sign-in should be forced. | 559 * @param {boolean} forceOnline Whether online sign-in should be forced. |
530 * If |forceOnline| is false previously used sign-in type will be used. | 560 * If |forceOnline| is false previously used sign-in type will be used. |
531 */ | 561 */ |
532 reset: function(takeFocus, forceOnline) { | 562 reset: function(takeFocus, forceOnline) { |
533 // Reload and show the sign-in UI if needed. | 563 // Reload and show the sign-in UI if needed. |
534 if (takeFocus) { | 564 if (takeFocus) { |
535 if (!forceOnline && this.isLocal) { | 565 if (!forceOnline && this.isLocal) { |
536 // Show 'Cancel' button to allow user to return to the main screen | 566 // Show 'Cancel' button to allow user to return to the main screen |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 * For more info see C++ class 'WebUILoginView' which calls this method. | 670 * For more info see C++ class 'WebUILoginView' which calls this method. |
641 * @param {number} error Error code. | 671 * @param {number} error Error code. |
642 * @param {string} url The URL that failed to load. | 672 * @param {string} url The URL that failed to load. |
643 */ | 673 */ |
644 onFrameError: function(error, url) { | 674 onFrameError: function(error, url) { |
645 this.error_ = error; | 675 this.error_ = error; |
646 chrome.send('frameLoadingCompleted', [this.error_]); | 676 chrome.send('frameLoadingCompleted', [this.error_]); |
647 }, | 677 }, |
648 }; | 678 }; |
649 }); | 679 }); |
OLD | NEW |