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 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { | 9 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { |
10 // Gaia loading time after which error message must be displayed and | 10 // Gaia loading time after which error message must be displayed and |
11 // lazy portal check should be fired. | 11 // lazy portal check should be fired. |
12 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; | 12 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; |
13 | 13 |
| 14 // GAIA animation guard timer. Started when GAIA page is loaded |
| 15 // (Authenticator 'ready' event) and is intended to guard against edge cases |
| 16 // when 'showView' message is not generated/received. |
| 17 /** @const */ var GAIA_ANIMATION_GUARD_MILLISEC = 300; |
| 18 |
14 // Maximum Gaia loading time in seconds. | 19 // Maximum Gaia loading time in seconds. |
15 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; | 20 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; |
16 | 21 |
17 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; | 22 /** @const */ var HELP_TOPIC_ENTERPRISE_REPORTING = 2535613; |
18 | 23 |
19 // The help topic regarding user not being in the whitelist. | 24 // The help topic regarding user not being in the whitelist. |
20 /** @const */ var HELP_CANT_ACCESS_ACCOUNT = 188036; | 25 /** @const */ var HELP_CANT_ACCESS_ACCOUNT = 188036; |
21 | 26 |
22 return { | 27 return { |
23 EXTERNAL_API: [ | 28 EXTERNAL_API: [ |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 isEnrollingConsumerManagement_: false, | 76 isEnrollingConsumerManagement_: false, |
72 | 77 |
73 /** | 78 /** |
74 * Timer id of pending load. | 79 * Timer id of pending load. |
75 * @type {number} | 80 * @type {number} |
76 * @private | 81 * @private |
77 */ | 82 */ |
78 loadingTimer_: undefined, | 83 loadingTimer_: undefined, |
79 | 84 |
80 /** | 85 /** |
| 86 * Timer id of a guard timer that is fired in case 'showView' message |
| 87 * is not received from GAIA. |
| 88 * @type {number} |
| 89 * @private |
| 90 */ |
| 91 loadAnimationGuardTimer_: undefined, |
| 92 |
| 93 /** |
| 94 * Whether we've processed 'showView' message - either from GAIA or from |
| 95 * guard timer. |
| 96 * @type {boolean} |
| 97 * @private |
| 98 */ |
| 99 showViewProcessed_: undefined, |
| 100 |
| 101 /** |
81 * Whether user can cancel Gaia screen. | 102 * Whether user can cancel Gaia screen. |
82 * @type {boolean} | 103 * @type {boolean} |
83 * @private | 104 * @private |
84 */ | 105 */ |
85 cancelAllowed_: undefined, | 106 cancelAllowed_: undefined, |
86 | 107 |
87 /** | 108 /** |
88 * Whether we should show user pods on the login screen. | 109 * Whether we should show user pods on the login screen. |
89 * @type {boolean} | 110 * @type {boolean} |
90 * @private | 111 * @private |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 $('gaia-loading').hidden = !show; | 234 $('gaia-loading').hidden = !show; |
214 if (this.isNewGaiaFlow && this.isLocal) { | 235 if (this.isNewGaiaFlow && this.isLocal) { |
215 $('newgaia-offline-login').hidden = show; | 236 $('newgaia-offline-login').hidden = show; |
216 } else { | 237 } else { |
217 $('signin-frame').hidden = show; | 238 $('signin-frame').hidden = show; |
218 } | 239 } |
219 $('signin-right').hidden = show; | 240 $('signin-right').hidden = show; |
220 $('enterprise-info-container').hidden = show; | 241 $('enterprise-info-container').hidden = show; |
221 $('gaia-signin-divider').hidden = show; | 242 $('gaia-signin-divider').hidden = show; |
222 this.classList.toggle('loading', show); | 243 this.classList.toggle('loading', show); |
| 244 $('signin-frame').classList.remove('show'); |
223 if (!show) | 245 if (!show) |
224 this.classList.remove('auth-completed'); | 246 this.classList.remove('auth-completed'); |
225 }, | 247 }, |
226 | 248 |
227 /** | 249 /** |
228 * Handler for Gaia loading suspiciously long timeout. | 250 * Handler for Gaia loading suspiciously long timeout. |
229 * @private | 251 * @private |
230 */ | 252 */ |
231 onLoadingSuspiciouslyLong_: function() { | 253 onLoadingSuspiciouslyLong_: function() { |
232 if (this != Oobe.getInstance().currentScreen) | 254 if (this != Oobe.getInstance().currentScreen) |
233 return; | 255 return; |
234 chrome.send('showLoadingTimeoutError'); | 256 chrome.send('showLoadingTimeoutError'); |
235 this.loadingTimer_ = window.setTimeout( | 257 this.loadingTimer_ = setTimeout( |
236 this.onLoadingTimeOut_.bind(this), | 258 this.onLoadingTimeOut_.bind(this), |
237 (MAX_GAIA_LOADING_TIME_SEC - GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC) * | 259 (MAX_GAIA_LOADING_TIME_SEC - GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC) * |
238 1000); | 260 1000); |
239 }, | 261 }, |
240 | 262 |
241 /** | 263 /** |
242 * Handler for Gaia loading timeout. | 264 * Handler for Gaia loading timeout. |
243 * @private | 265 * @private |
244 */ | 266 */ |
245 onLoadingTimeOut_: function() { | 267 onLoadingTimeOut_: function() { |
246 this.loadingTimer_ = undefined; | 268 this.loadingTimer_ = undefined; |
247 chrome.send('showLoadingTimeoutError'); | 269 chrome.send('showLoadingTimeoutError'); |
248 }, | 270 }, |
249 | 271 |
250 /** | 272 /** |
251 * Clears loading timer. | 273 * Clears loading timer. |
252 * @private | 274 * @private |
253 */ | 275 */ |
254 clearLoadingTimer_: function() { | 276 clearLoadingTimer_: function() { |
255 if (this.loadingTimer_) { | 277 if (this.loadingTimer_) { |
256 window.clearTimeout(this.loadingTimer_); | 278 clearTimeout(this.loadingTimer_); |
257 this.loadingTimer_ = undefined; | 279 this.loadingTimer_ = undefined; |
258 } | 280 } |
259 }, | 281 }, |
260 | 282 |
261 /** | 283 /** |
262 * Sets up loading timer. | 284 * Sets up loading timer. |
263 * @private | 285 * @private |
264 */ | 286 */ |
265 startLoadingTimer_: function() { | 287 startLoadingTimer_: function() { |
266 this.clearLoadingTimer_(); | 288 this.clearLoadingTimer_(); |
267 this.loadingTimer_ = window.setTimeout( | 289 this.loadingTimer_ = setTimeout( |
268 this.onLoadingSuspiciouslyLong_.bind(this), | 290 this.onLoadingSuspiciouslyLong_.bind(this), |
269 GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC * 1000); | 291 GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC * 1000); |
270 }, | 292 }, |
271 | 293 |
272 /** | 294 /** |
| 295 * Handler for GAIA animation guard timer. |
| 296 * @private |
| 297 */ |
| 298 onLoadAnimationGuardTimer_: function() { |
| 299 this.loadAnimationGuardTimer_ = undefined; |
| 300 this.onShowView_(); |
| 301 }, |
| 302 |
| 303 /** |
| 304 * Clears GAIA animation guard timer. |
| 305 * @private |
| 306 */ |
| 307 clearLoadAnimationGuardTimer_: function() { |
| 308 if (this.loadAnimationGuardTimer_) { |
| 309 clearTimeout(this.loadAnimationGuardTimer_); |
| 310 this.loadAnimationGuardTimer_ = undefined; |
| 311 } |
| 312 }, |
| 313 |
| 314 /** |
| 315 * Sets up GAIA animation guard timer. |
| 316 * @private |
| 317 */ |
| 318 startLoadAnimationGuardTimer_: function() { |
| 319 this.clearLoadAnimationGuardTimer_(); |
| 320 this.loadAnimationGuardTimer_ = setTimeout( |
| 321 this.onLoadAnimationGuardTimer_.bind(this), |
| 322 GAIA_ANIMATION_GUARD_MILLISEC); |
| 323 }, |
| 324 |
| 325 /** |
273 * Whether Gaia is loading. | 326 * Whether Gaia is loading. |
274 * @type {boolean} | 327 * @type {boolean} |
275 */ | 328 */ |
276 get loading() { | 329 get loading() { |
277 return !$('gaia-loading').hidden; | 330 return !$('gaia-loading').hidden; |
278 }, | 331 }, |
279 set loading(loading) { | 332 set loading(loading) { |
280 if (loading == this.loading) | 333 if (loading == this.loading) |
281 return; | 334 return; |
282 | 335 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 if (this.isNewGaiaFlow) | 542 if (this.isNewGaiaFlow) |
490 $('close-button-item').hidden = !(isSAML || this.cancelAllowed_); | 543 $('close-button-item').hidden = !(isSAML || this.cancelAllowed_); |
491 } | 544 } |
492 }, | 545 }, |
493 | 546 |
494 /** | 547 /** |
495 * Invoked when the auth host emits 'ready' event. | 548 * Invoked when the auth host emits 'ready' event. |
496 * @private | 549 * @private |
497 */ | 550 */ |
498 onAuthReady_: function() { | 551 onAuthReady_: function() { |
| 552 showViewProcessed_ = false; |
| 553 if (this.isNewGaiaFlow) |
| 554 this.startLoadAnimationGuardTimer_(); |
| 555 |
| 556 this.clearLoadingTimer_(); |
499 this.loading = false; | 557 this.loading = false; |
500 this.clearLoadingTimer_(); | |
501 | 558 |
502 // Show deferred error bubble. | 559 if (!this.isNewGaiaFlow) |
503 if (this.errorBubble_) { | 560 this.onLoginUIVisible_(); |
504 this.showErrorBubble(this.errorBubble_[0], this.errorBubble_[1]); | |
505 this.errorBubble_ = undefined; | |
506 } | |
507 | |
508 chrome.send('loginWebuiReady'); | |
509 chrome.send('loginVisible', ['gaia-signin']); | |
510 | 561 |
511 // Warm up the user images screen. | 562 // Warm up the user images screen. |
512 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); | 563 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); |
513 }, | 564 }, |
514 | 565 |
515 /** | 566 /** |
516 * Invoked when the auth host emits 'dialogShown' event. | 567 * Invoked when the auth host emits 'dialogShown' event. |
517 * @private | 568 * @private |
518 */ | 569 */ |
519 onDialogShown_: function() { | 570 onDialogShown_: function() { |
(...skipping 12 matching lines...) Expand all Loading... |
532 | 583 |
533 /** | 584 /** |
534 * Invoked when the auth host emits 'backButton' event. | 585 * Invoked when the auth host emits 'backButton' event. |
535 * @private | 586 * @private |
536 */ | 587 */ |
537 onBackButton_: function(e) { | 588 onBackButton_: function(e) { |
538 $('back-button-item').hidden = !e.detail; | 589 $('back-button-item').hidden = !e.detail; |
539 }, | 590 }, |
540 | 591 |
541 /** | 592 /** |
542 * Invoked when the auth host emits 'showView' event. | 593 * Invoked when the auth host emits 'showView' event or when corresponding |
| 594 * guard time fires. |
543 * @private | 595 * @private |
544 */ | 596 */ |
545 onShowView_: function(e) { | 597 onShowView_: function(e) { |
| 598 if (showViewProcessed_) |
| 599 return; |
| 600 |
| 601 showViewProcessed_ = true; |
| 602 this.clearLoadAnimationGuardTimer_(); |
546 $('signin-frame').classList.add('show'); | 603 $('signin-frame').classList.add('show'); |
| 604 this.onLoginUIVisible_(); |
547 }, | 605 }, |
548 | 606 |
549 /** | 607 /** |
| 608 * Called when UI is shown. |
| 609 * @private |
| 610 */ |
| 611 onLoginUIVisible_: function() { |
| 612 // Show deferred error bubble. |
| 613 if (this.errorBubble_) { |
| 614 this.showErrorBubble(this.errorBubble_[0], this.errorBubble_[1]); |
| 615 this.errorBubble_ = undefined; |
| 616 } |
| 617 |
| 618 chrome.send('loginWebuiReady'); |
| 619 chrome.send('loginVisible', ['gaia-signin']); |
| 620 }, |
| 621 |
| 622 /** |
550 * Invoked when the user has successfully authenticated via SAML, the | 623 * Invoked when the user has successfully authenticated via SAML, the |
551 * principals API was not used and the auth host needs the user to confirm | 624 * principals API was not used and the auth host needs the user to confirm |
552 * the scraped password. | 625 * the scraped password. |
553 * @param {number} passwordCount The number of passwords that were scraped. | 626 * @param {number} passwordCount The number of passwords that were scraped. |
554 * @private | 627 * @private |
555 */ | 628 */ |
556 onAuthConfirmPassword_: function(passwordCount) { | 629 onAuthConfirmPassword_: function(passwordCount) { |
557 this.loading = true; | 630 this.loading = true; |
558 Oobe.getInstance().headerHidden = false; | 631 Oobe.getInstance().headerHidden = false; |
559 | 632 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 } | 924 } |
852 | 925 |
853 this.classList.toggle('whitelist-error', show); | 926 this.classList.toggle('whitelist-error', show); |
854 this.loading = !show; | 927 this.loading = !show; |
855 | 928 |
856 if (!show) | 929 if (!show) |
857 Oobe.showSigninUI(); | 930 Oobe.showSigninUI(); |
858 }, | 931 }, |
859 }; | 932 }; |
860 }); | 933 }); |
OLD | NEW |