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) { |
Dmitry Polukhin
2015/04/22 13:17:51
nit, i would extract this part to separate functio
Nikita (slow)
2015/04/22 13:55:23
Done.
| |
503 if (this.errorBubble_) { | 560 // Show deferred error bubble. |
504 this.showErrorBubble(this.errorBubble_[0], this.errorBubble_[1]); | 561 if (this.errorBubble_) { |
505 this.errorBubble_ = undefined; | 562 this.showErrorBubble(this.errorBubble_[0], this.errorBubble_[1]); |
563 this.errorBubble_ = undefined; | |
564 } | |
565 | |
566 chrome.send('loginWebuiReady'); | |
567 chrome.send('loginVisible', ['gaia-signin']); | |
506 } | 568 } |
507 | 569 |
508 chrome.send('loginWebuiReady'); | |
509 chrome.send('loginVisible', ['gaia-signin']); | |
510 | |
511 // Warm up the user images screen. | 570 // Warm up the user images screen. |
512 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); | 571 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); |
513 }, | 572 }, |
514 | 573 |
515 /** | 574 /** |
516 * Invoked when the auth host emits 'dialogShown' event. | 575 * Invoked when the auth host emits 'dialogShown' event. |
517 * @private | 576 * @private |
518 */ | 577 */ |
519 onDialogShown_: function() { | 578 onDialogShown_: function() { |
520 $('back-button-item').disabled = true; | 579 $('back-button-item').disabled = true; |
(...skipping 15 matching lines...) Expand all Loading... | |
536 */ | 595 */ |
537 onBackButton_: function(e) { | 596 onBackButton_: function(e) { |
538 $('back-button-item').hidden = !e.detail; | 597 $('back-button-item').hidden = !e.detail; |
539 }, | 598 }, |
540 | 599 |
541 /** | 600 /** |
542 * Invoked when the auth host emits 'showView' event. | 601 * Invoked when the auth host emits 'showView' event. |
543 * @private | 602 * @private |
544 */ | 603 */ |
545 onShowView_: function(e) { | 604 onShowView_: function(e) { |
605 if (showViewProcessed_) | |
606 return; | |
607 | |
608 showViewProcessed_ = true; | |
609 this.clearLoadAnimationGuardTimer_(); | |
610 | |
546 $('signin-frame').classList.add('show'); | 611 $('signin-frame').classList.add('show'); |
612 | |
613 // Show deferred error bubble. | |
614 if (this.errorBubble_) { | |
615 this.showErrorBubble(this.errorBubble_[0], this.errorBubble_[1]); | |
616 this.errorBubble_ = undefined; | |
617 } | |
618 | |
619 chrome.send('loginWebuiReady'); | |
620 chrome.send('loginVisible', ['gaia-signin']); | |
547 }, | 621 }, |
548 | 622 |
549 /** | 623 /** |
550 * Invoked when the user has successfully authenticated via SAML, the | 624 * 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 | 625 * principals API was not used and the auth host needs the user to confirm |
552 * the scraped password. | 626 * the scraped password. |
553 * @param {number} passwordCount The number of passwords that were scraped. | 627 * @param {number} passwordCount The number of passwords that were scraped. |
554 * @private | 628 * @private |
555 */ | 629 */ |
556 onAuthConfirmPassword_: function(passwordCount) { | 630 onAuthConfirmPassword_: function(passwordCount) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 } | 925 } |
852 | 926 |
853 this.classList.toggle('whitelist-error', show); | 927 this.classList.toggle('whitelist-error', show); |
854 this.loading = !show; | 928 this.loading = !show; |
855 | 929 |
856 if (!show) | 930 if (!show) |
857 Oobe.showSigninUI(); | 931 Oobe.showSigninUI(); |
858 }, | 932 }, |
859 }; | 933 }; |
860 }); | 934 }); |
OLD | NEW |