Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_gaia_signin.js

Issue 1831523003: FR: SAML Sign In - Interstitial page to send users directly to IdP login screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove the <br> comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 animation guard timer. Started when GAIA page is loaded 10 // GAIA animation guard timer. Started when GAIA page is loaded
11 // (Authenticator 'ready' event) and is intended to guard against edge cases 11 // (Authenticator 'ready' event) and is intended to guard against edge cases
12 // when 'showView' message is not generated/received. 12 // when 'showView' message is not generated/received.
13 /** @const */ var GAIA_ANIMATION_GUARD_MILLISEC = 300; 13 /** @const */ var GAIA_ANIMATION_GUARD_MILLISEC = 300;
14 14
15 // Maximum Gaia loading time in seconds. 15 // Maximum Gaia loading time in seconds.
16 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; 16 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60;
17 17
18 // The help topic regarding user not being in the whitelist. 18 // The help topic regarding user not being in the whitelist.
19 /** @const */ var HELP_CANT_ACCESS_ACCOUNT = 188036; 19 /** @const */ var HELP_CANT_ACCESS_ACCOUNT = 188036;
20 20
21 // Amount of time the user has to be idle for before showing the online login 21 // Amount of time the user has to be idle for before showing the online login
22 // page. 22 // page.
23 /** @const */ var IDLE_TIME_UNTIL_EXIT_OFFLINE_IN_MILLISECONDS = 180 * 1000; 23 /** @const */ var IDLE_TIME_UNTIL_EXIT_OFFLINE_IN_MILLISECONDS = 180 * 1000;
24 24
25 // Approximate amount of time between checks to see if we should go to the 25 // Approximate amount of time between checks to see if we should go to the
26 // online login page when we're in the offline login page and the device is 26 // online login page when we're in the offline login page and the device is
27 // online. 27 // online.
28 /** @const */ var IDLE_TIME_CHECK_FREQUENCY = 5 * 1000; 28 /** @const */ var IDLE_TIME_CHECK_FREQUENCY = 5 * 1000;
29 29
30 /**
31 * The modes this screen can be in.
32 * @enum {integer}
33 */
34 var ScreenMode = {
35 DEFAULT: 0, // Default GAIA login flow.
36 OFFLINE: 1, // GAIA offline login.
37 SAML_INTERSTITIAL: 2 // Interstitial page before SAML redirection.
38 };
39
30 return { 40 return {
31 EXTERNAL_API: [ 41 EXTERNAL_API: [
32 'loadAuthExtension', 42 'loadAuthExtension',
33 'doReload', 43 'doReload',
34 'monitorOfflineIdle', 44 'monitorOfflineIdle',
35 'updateControlsState', 45 'updateControlsState',
36 'showWhitelistCheckFailedError', 46 'showWhitelistCheckFailedError',
37 ], 47 ],
38 48
39 /** 49 /**
40 * Saved gaia auth host load params. 50 * Saved gaia auth host load params.
41 * @type {?string} 51 * @type {?string}
42 * @private 52 * @private
43 */ 53 */
44 gaiaAuthParams_: null, 54 gaiaAuthParams_: null,
45 55
46 /** 56 /**
47 * Whether offline version of Gaia page is used. 57 * Current mode of this screen.
48 * @type {boolean} 58 * @type {integer}
49 * @private 59 * @private
50 */ 60 */
51 isOffline_: false, 61 screenMode_: ScreenMode.DEFAULT,
52 62
53 /** 63 /**
54 * Email of the user, which is logging in using offline mode. 64 * Email of the user, which is logging in using offline mode.
55 * @type {string} 65 * @type {string}
56 */ 66 */
57 email: '', 67 email: '',
58 68
59 /** 69 /**
60 * Timer id of pending load. 70 * Timer id of pending load.
61 * @type {number} 71 * @type {number}
62 * @private 72 * @private
63 */ 73 */
64 loadingTimer_: undefined, 74 loadingTimer_: undefined,
65 75
66 /** 76 /**
67 * Timer id of a guard timer that is fired in case 'showView' message 77 * Timer id of a guard timer that is fired in case 'showView' message
68 * is not received from GAIA. 78 * is not received from GAIA.
69 * @type {number} 79 * @type {number}
70 * @private 80 * @private
71 */ 81 */
72 loadAnimationGuardTimer_: undefined, 82 loadAnimationGuardTimer_: undefined,
73 83
74 /** 84 /**
75 * Whether we've processed 'showView' message - either from GAIA or from 85 * Whether we've processed 'showView' message - either from GAIA or from
76 * guard timer. 86 * guard timer.
77 * @type {boolean} 87 * @type {boolean}
78 * @private 88 * @private
79 */ 89 */
80 showViewProcessed_: undefined, 90 showViewProcessed_: false,
81 91
82 /** 92 /**
83 * Whether we've processed 'authCompleted' message. 93 * Whether we've processed 'authCompleted' message.
84 * @type {boolean} 94 * @type {boolean}
85 * @private 95 * @private
86 */ 96 */
87 authCompleted_: false, 97 authCompleted_: false,
88 98
89 /** 99 /**
90 * Value contained in the last received 'backButton' event. 100 * Value contained in the last received 'backButton' event.
91 * @type {boolean} 101 * @type {boolean}
92 * @private 102 * @private
93 */ 103 */
94 lastBackMessageValue_: false, 104 lastBackMessageValue_: false,
95 105
96 /** 106 /**
97 * Whether the dialog could be closed. 107 * Whether the dialog could be closed.
98 * @type {boolean} 108 * @type {boolean}
99 */ 109 */
100 get closable() { 110 get closable() {
101 return !!$('pod-row').pods.length || this.isOffline; 111 return !!$('pod-row').pods.length || this.isOffline();
102 }, 112 },
103 113
104 /** 114 /**
105 * Returns true if GAIA is at the begging of flow (i.e. the email page). 115 * Returns true if GAIA is at the begging of flow (i.e. the email page).
106 * @type {boolean} 116 * @type {boolean}
107 */ 117 */
108 isAtTheBeginning: function() { 118 isAtTheBeginning: function() {
109 return !this.navigation_.backVisible && 119 return !this.navigation_.backVisible &&
110 !this.isSAML() && 120 !this.isSAML() &&
111 !this.classList.contains('whitelist-error') && 121 !this.classList.contains('whitelist-error') &&
112 !this.authCompleted_; 122 !this.authCompleted_;
113 }, 123 },
114 124
115 /** 125 /**
116 * Updates visibility of navigation buttons. 126 * Updates visibility of navigation buttons.
117 */ 127 */
118 updateControlsState: function() { 128 updateControlsState: function() {
119 var isWhitelistError = this.classList.contains('whitelist-error'); 129 var isWhitelistError = this.classList.contains('whitelist-error');
120 130
121 this.navigation_.backVisible = 131 this.navigation_.backVisible =
122 this.lastBackMessageValue_ && 132 this.lastBackMessageValue_ &&
123 !isWhitelistError && 133 !isWhitelistError &&
124 !this.authCompleted_ && 134 !this.authCompleted_ &&
125 !this.loading && 135 !this.loading &&
126 !this.isSAML(); 136 !this.isSAML();
127 137
128 this.navigation_.refreshVisible = 138 this.navigation_.refreshVisible =
129 !this.closable && this.isAtTheBeginning(); 139 !this.closable && this.isAtTheBeginning() &&
140 this.screenMode_ != ScreenMode.SAML_INTERSTITIAL;
130 141
131 this.navigation_.closeVisible = 142 this.navigation_.closeVisible =
132 !this.navigation_.refreshVisible && 143 !this.navigation_.refreshVisible &&
133 !isWhitelistError && 144 !isWhitelistError &&
134 !this.authCompleted; 145 !this.authCompleted &&
146 this.screenMode_ != ScreenMode.SAML_INTERSTITIAL;
135 147
136 $('login-header-bar').updateUI_(); 148 $('login-header-bar').updateUI_();
137 }, 149 },
138 150
139 /** 151 /**
140 * SAML password confirmation attempt count. 152 * SAML password confirmation attempt count.
141 * @type {number} 153 * @type {number}
142 */ 154 */
143 samlPasswordConfirmAttempt_: 0, 155 samlPasswordConfirmAttempt_: 0,
144 156
(...skipping 22 matching lines...) Expand all
167 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); 179 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame'));
168 this.gaiaAuthHost_.addEventListener( 180 this.gaiaAuthHost_.addEventListener(
169 'ready', this.onAuthReady_.bind(this)); 181 'ready', this.onAuthReady_.bind(this));
170 182
171 var that = this; 183 var that = this;
172 [this.gaiaAuthHost_, $('offline-gaia')].forEach(function(frame) { 184 [this.gaiaAuthHost_, $('offline-gaia')].forEach(function(frame) {
173 // Ignore events from currently inactive frame. 185 // Ignore events from currently inactive frame.
174 var frameFilter = function(callback) { 186 var frameFilter = function(callback) {
175 return function(e) { 187 return function(e) {
176 var isEventOffline = frame === $('offline-gaia'); 188 var isEventOffline = frame === $('offline-gaia');
177 if (isEventOffline === that.isOffline) 189 if (isEventOffline === that.isOffline())
178 callback.call(that, e); 190 callback.call(that, e);
179 }; 191 };
180 }; 192 };
181 193
182 frame.addEventListener('authCompleted', 194 frame.addEventListener('authCompleted',
183 frameFilter(that.onAuthCompletedMessage_)); 195 frameFilter(that.onAuthCompletedMessage_));
184 frame.addEventListener('backButton', frameFilter(that.onBackButton_)); 196 frame.addEventListener('backButton', frameFilter(that.onBackButton_));
185 frame.addEventListener('dialogShown', frameFilter(that.onDialogShown_)); 197 frame.addEventListener('dialogShown', frameFilter(that.onDialogShown_));
186 frame.addEventListener('dialogHidden', 198 frame.addEventListener('dialogHidden',
187 frameFilter(that.onDialogHidden_)); 199 frameFilter(that.onDialogHidden_));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 this.cancel(); 233 this.cancel();
222 }.bind(this)); 234 }.bind(this));
223 235
224 $('gaia-whitelist-error').addEventListener('buttonclick', function() { 236 $('gaia-whitelist-error').addEventListener('buttonclick', function() {
225 this.showWhitelistCheckFailedError(false); 237 this.showWhitelistCheckFailedError(false);
226 }.bind(this)); 238 }.bind(this));
227 239
228 $('gaia-whitelist-error').addEventListener('linkclick', function() { 240 $('gaia-whitelist-error').addEventListener('linkclick', function() {
229 chrome.send('launchHelpApp', [HELP_CANT_ACCESS_ACCOUNT]); 241 chrome.send('launchHelpApp', [HELP_CANT_ACCESS_ACCOUNT]);
230 }); 242 });
243
244 // Register handlers for the saml interstitial page events.
245 $('saml-interstitial').addEventListener('samlPageNextClicked',
246 function() {
247 this.screenMode = ScreenMode.DEFAULT;
248 this.loadGaiaAuthHost_(true /* doSamlRedirect */);
249 }.bind(this));
250 $('saml-interstitial').addEventListener('samlPageChangeAccountClicked',
251 function() {
252 this.screenMode = ScreenMode.DEFAULT;
253 this.loadGaiaAuthHost_(false /* doSamlRedirect */);
254 }.bind(this));
231 }, 255 },
232 256
233 /** 257 /**
258 * Loads the authenticator and updates the UI to reflect the loading state.
259 * @param {boolean} doSamlRedirect If the authenticator should do
260 * authentication by automatic redirection to the SAML-based enrollment
261 * enterprise domain IdP.
262 */
263 loadGaiaAuthHost_: function(doSamlRedirect) {
264 this.loading = true;
265 this.startLoadingTimer_();
266
267 this.gaiaAuthParams_.doSamlRedirect = doSamlRedirect;
268 this.gaiaAuthHost_.load(cr.login.GaiaAuthHost.AuthMode.DEFAULT,
269 this.gaiaAuthParams_);
270 },
271
272 /**
234 * Header text of the screen. 273 * Header text of the screen.
235 * @type {string} 274 * @type {string}
236 */ 275 */
237 get header() { 276 get header() {
238 return loadTimeData.getString('signinScreenTitle'); 277 return loadTimeData.getString('signinScreenTitle');
239 }, 278 },
240 279
241 /** 280 /**
242 * Returns true if offline version of Gaia is used. 281 * Returns true if offline version of Gaia is used.
243 * @type {boolean} 282 * @type {boolean}
244 */ 283 */
245 get isOffline() { 284 isOffline: function() {
246 return this.isOffline_; 285 return this.screenMode_ == ScreenMode.OFFLINE;
247 }, 286 },
248 287
249 /** 288 /**
250 * Sets whether offline version of Gaia is used. 289 * Sets the current screen mode and updates the visible elements
251 * @param {boolean} value Whether offline version of Gaia is used. 290 * accordingly.
291 * @param {integer} value The screen mode.
252 */ 292 */
253 set isOffline(value) { 293 set screenMode(value) {
254 this.isOffline_ = !!value; 294 this.screenMode_ = value;
255 $('signin-frame').hidden = this.isOffline_; 295 switch (this.screenMode_) {
256 $('offline-gaia').hidden = !this.isOffline_; 296 case ScreenMode.DEFAULT:
257 chrome.send('updateOfflineLogin', [value]); 297 $('signin-frame').hidden = false;
298 $('offline-gaia').hidden = true;
299 $('saml-interstitial').hidden = true;
300 break;
301 case ScreenMode.OFFLINE:
302 $('signin-frame').hidden = true;
303 $('offline-gaia').hidden = false;
304 $('saml-interstitial').hidden = true;
305 break;
306 case ScreenMode.SAML_INTERSTITIAL:
307 $('signin-frame').hidden = true;
308 $('offline-gaia').hidden = true;
309 $('saml-interstitial').hidden = false;
310 break;
311 }
312
313 chrome.send('updateOfflineLogin', [this.isOffline()]);
314 this.updateControlsState();
258 }, 315 },
259 316
260 /** 317 /**
261 * This enables or disables trying to go back to the online login page 318 * This enables or disables trying to go back to the online login page
262 * after the user is idle for a few minutes, assuming that we're currently 319 * after the user is idle for a few minutes, assuming that we're currently
263 * in the offline one. This is only applicable when the offline page is 320 * in the offline one. This is only applicable when the offline page is
264 * currently active. It is intended that when the device goes online, this 321 * currently active. It is intended that when the device goes online, this
265 * gets called with true; when it goes offline, this gets called with 322 * gets called with true; when it goes offline, this gets called with
266 * false. 323 * false.
267 */ 324 */
(...skipping 12 matching lines...) Expand all
280 if (!self.updateActivityTime_) { 337 if (!self.updateActivityTime_) {
281 self.updateActivityTime_ = function() { 338 self.updateActivityTime_ = function() {
282 self.mostRecentUserActivity_ = Date.now(); 339 self.mostRecentUserActivity_ = Date.now();
283 }; 340 };
284 } 341 }
285 342
286 // Begin monitoring. 343 // Begin monitoring.
287 if (shouldMonitor) { 344 if (shouldMonitor) {
288 // If we're not using the offline login page or we're already 345 // If we're not using the offline login page or we're already
289 // monitoring, then we don't need to do anything. 346 // monitoring, then we don't need to do anything.
290 if (!self.isOffline || self.tryToGoToOnlineLoginPageCallbackId_ !== -1) 347 if (!self.isOffline() ||
348 self.tryToGoToOnlineLoginPageCallbackId_ !== -1) {
291 return; 349 return;
350 }
292 351
293 self.mostRecentUserActivity_ = Date.now(); 352 self.mostRecentUserActivity_ = Date.now();
294 ACTIVITY_EVENTS.forEach(function(event) { 353 ACTIVITY_EVENTS.forEach(function(event) {
295 document.addEventListener(event, self.updateActivityTime_); 354 document.addEventListener(event, self.updateActivityTime_);
296 }); 355 });
297 356
298 self.tryToGoToOnlineLoginPageCallbackId_ = setInterval(function() { 357 self.tryToGoToOnlineLoginPageCallbackId_ = setInterval(function() {
299 // If we're not in the offline page or the signin page, then we want 358 // If we're not in the offline page or the signin page, then we want
300 // to terminate monitoring. 359 // to terminate monitoring.
301 if (!self.isOffline || 360 if (!self.isOffline() ||
302 Oobe.getInstance().currentScreen.id != 'gaia-signin') { 361 Oobe.getInstance().currentScreen.id != 'gaia-signin') {
303 self.monitorOfflineIdle(false); 362 self.monitorOfflineIdle(false);
304 return; 363 return;
305 } 364 }
306 365
307 var idleDuration = Date.now() - self.mostRecentUserActivity_; 366 var idleDuration = Date.now() - self.mostRecentUserActivity_;
308 if (idleDuration > IDLE_TIME_UNTIL_EXIT_OFFLINE_IN_MILLISECONDS) { 367 if (idleDuration > IDLE_TIME_UNTIL_EXIT_OFFLINE_IN_MILLISECONDS) {
309 self.monitorOfflineIdle(false); 368 self.monitorOfflineIdle(false);
310 Oobe.resetSigninUI(true); 369 Oobe.resetSigninUI(true);
311 } 370 }
(...skipping 14 matching lines...) Expand all
326 } 385 }
327 }, 386 },
328 387
329 /** 388 /**
330 * Shows/hides loading UI. 389 * Shows/hides loading UI.
331 * @param {boolean} show True to show loading UI. 390 * @param {boolean} show True to show loading UI.
332 * @private 391 * @private
333 */ 392 */
334 showLoadingUI_: function(show) { 393 showLoadingUI_: function(show) {
335 $('gaia-loading').hidden = !show; 394 $('gaia-loading').hidden = !show;
395
396 // Only set hidden for offline-gaia or saml-interstitial and not set it on
397 // the 'sign-frame' webview element. Setting it on webview not only hides
398 // but also affects its loading events.
399 if (this.screenMode_ != ScreenMode.DEFAULT)
400 this.getSigninFrame_().hidden = show;
401 this.getSigninFrame_().classList.toggle('show', !show);
336 this.classList.toggle('loading', show); 402 this.classList.toggle('loading', show);
337 // Only set hidden for offline-gaia and not set it on the 'sign-frame'
338 // webview element. Setting it on webview not only hides but also affects
339 // its loading events.
340 if (this.isOffline)
341 this.getSigninFrame_().hidden = show;
342 $('signin-frame').classList.remove('show');
343 this.updateControlsState(); 403 this.updateControlsState();
344 }, 404 },
345 405
346 /** 406 /**
347 * Handler for Gaia loading timeout. 407 * Handler for Gaia loading timeout.
348 * @private 408 * @private
349 */ 409 */
350 onLoadingTimeOut_: function() { 410 onLoadingTimeOut_: function() {
351 if (this != Oobe.getInstance().currentScreen) 411 if (this != Oobe.getInstance().currentScreen)
352 return; 412 return;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 479
420 this.showLoadingUI_(loading); 480 this.showLoadingUI_(loading);
421 }, 481 },
422 482
423 /** 483 /**
424 * Event handler that is invoked just before the frame is shown. 484 * Event handler that is invoked just before the frame is shown.
425 * @param {string} data Screen init payload. Url of auth extension start 485 * @param {string} data Screen init payload. Url of auth extension start
426 * page. 486 * page.
427 */ 487 */
428 onBeforeShow: function(data) { 488 onBeforeShow: function(data) {
489 this.screenMode = ScreenMode.DEFAULT;
490 this.loading = true;
429 chrome.send('loginUIStateChanged', ['gaia-signin', true]); 491 chrome.send('loginUIStateChanged', ['gaia-signin', true]);
430 $('progress-dots').hidden = true; 492 $('progress-dots').hidden = true;
431 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN; 493 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN;
432 494
433 // Ensure that GAIA signin (or loading UI) is actually visible. 495 // Ensure that GAIA signin (or loading UI) is actually visible.
434 window.requestAnimationFrame(function() { 496 window.requestAnimationFrame(function() {
435 chrome.send('loginVisible', ['gaia-loading']); 497 chrome.send('loginVisible', ['gaia-loading']);
436 }); 498 });
437 499
438 this.classList.toggle('loading', this.loading);
439
440 // Button header is always visible when sign in is presented. 500 // Button header is always visible when sign in is presented.
441 // Header is hidden once GAIA reports on successful sign in. 501 // Header is hidden once GAIA reports on successful sign in.
442 Oobe.getInstance().headerHidden = false; 502 Oobe.getInstance().headerHidden = false;
443 503
444 this.lastBackMessageValue_ = false; 504 this.lastBackMessageValue_ = false;
445 this.updateControlsState(); 505 this.updateControlsState();
446 }, 506 },
447 507
448 getSigninFrame_: function() { 508 getSigninFrame_: function() {
449 return this.isOffline ? $('offline-gaia') : $('signin-frame'); 509 switch (this.screenMode_) {
510 case ScreenMode.DEFAULT:
511 return $('signin-frame');
512 case ScreenMode.OFFLINE:
513 return $('offline-gaia');
514 case ScreenMode.SAML_INTERSTITIAL:
515 return $('saml-interstitial');
516 }
450 }, 517 },
451 518
452 focusSigninFrame: function() { 519 focusSigninFrame: function() {
453 this.getSigninFrame_().focus(); 520 this.getSigninFrame_().focus();
454 }, 521 },
455 522
456 onAfterShow: function() { 523 onAfterShow: function() {
457 if (!this.loading) 524 if (!this.loading)
458 this.focusSigninFrame(); 525 this.focusSigninFrame();
459 }, 526 },
460 527
461 /** 528 /**
462 * Event handler that is invoked just before the screen is hidden. 529 * Event handler that is invoked just before the screen is hidden.
463 */ 530 */
464 onBeforeHide: function() { 531 onBeforeHide: function() {
465 chrome.send('loginUIStateChanged', ['gaia-signin', false]); 532 chrome.send('loginUIStateChanged', ['gaia-signin', false]);
466 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; 533 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN;
467 $('offline-gaia').switchToEmailCard(false /* animated */); 534 $('offline-gaia').switchToEmailCard(false /* animated */);
468 }, 535 },
469 536
470 /** 537 /**
471 * Loads the authentication extension into the iframe. 538 * Loads the authentication extension into the iframe.
472 * @param {Object} data Extension parameters bag. 539 * @param {Object} data Extension parameters bag.
473 * @private 540 * @private
474 */ 541 */
475 loadAuthExtension: function(data) { 542 loadAuthExtension: function(data) {
476 this.isOffline = data.useOffline; 543 this.screenMode = data.screenMode;
477 this.email = ''; 544 this.email = '';
478 this.authCompleted_ = false; 545 this.authCompleted_ = false;
479 this.lastBackMessageValue_ = false; 546 this.lastBackMessageValue_ = false;
480 547
481 // Reset SAML
482 this.classList.toggle('full-width', false);
483 this.samlPasswordConfirmAttempt_ = 0;
484
485 this.updateAuthExtension_(data); 548 this.updateAuthExtension_(data);
486 549
487 var params = {}; 550 var params = {};
488 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) { 551 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) {
489 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i]; 552 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i];
490 if (data[name]) 553 if (data[name])
491 params[name] = data[name]; 554 params[name] = data[name];
492 } 555 }
493 556
494 if (data.enterpriseInfoMessage)
495 params.enterpriseInfoMessage = data.enterpriseInfoMessage;
496
497 params.isNewGaiaFlow = true; 557 params.isNewGaiaFlow = true;
558 params.doSamlRedirect =
559 (this.screenMode_ == ScreenMode.SAML_INTERSTITIAL);
498 560
499 // Screen size could have been changed because of 'full-width' classes. 561 // Screen size could have been changed because of 'full-width' classes.
500 if (Oobe.getInstance().currentScreen === this) 562 if (Oobe.getInstance().currentScreen === this)
501 Oobe.getInstance().updateScreenSize(this); 563 Oobe.getInstance().updateScreenSize(this);
502 564
503 if (data.forceReload || 565 if (data.forceReload ||
504 JSON.stringify(this.gaiaAuthParams_) != JSON.stringify(params)) { 566 JSON.stringify(this.gaiaAuthParams_) != JSON.stringify(params)) {
505 this.gaiaAuthParams_ = params; 567 this.gaiaAuthParams_ = params;
506 this.loading = true;
507 this.startLoadingTimer_();
508 568
509 if (this.isOffline) { 569 switch (this.screenMode_) {
510 this.loadOffline(params); 570 case ScreenMode.DEFAULT:
511 } else { 571 this.loadGaiaAuthHost_(false /* doSamlRedirect */);
512 this.gaiaAuthHost_.load(cr.login.GaiaAuthHost.AuthMode.DEFAULT, 572 break;
513 params); 573
574 case ScreenMode.OFFLINE:
575 this.loadOffline(params);
576 break;
577
578 case ScreenMode.SAML_INTERSTITIAL:
579 $('saml-interstitial').domain = data.enterpriseDomain;
580 if (this.loading)
581 this.loading = false;
582 break;
514 } 583 }
515 } 584 }
516 this.updateControlsState(); 585 this.updateControlsState();
517 }, 586 },
518 587
519 /** 588 /**
520 * Updates the authentication extension with new parameters, if needed. 589 * Updates the authentication extension with new parameters, if needed.
521 * @param {Object} data New extension parameters bag. 590 * @param {Object} data New extension parameters bag.
522 * @private 591 * @private
523 */ 592 */
524 updateAuthExtension_: function(data) { 593 updateAuthExtension_: function(data) {
525 $('login-header-bar').showCreateSupervisedButton = 594 $('login-header-bar').showCreateSupervisedButton =
526 data.supervisedUsersCanCreate; 595 data.supervisedUsersCanCreate;
527 $('login-header-bar').showGuestButton = data.guestSignin; 596 $('login-header-bar').showGuestButton = data.guestSignin;
528 597
529 this.updateControlsState(); 598 this.updateControlsState();
530 599
600 // Reset SAML
531 this.classList.toggle('full-width', false); 601 this.classList.toggle('full-width', false);
602 this.samlPasswordConfirmAttempt_ = 0;
532 if (Oobe.getInstance().currentScreen === this) 603 if (Oobe.getInstance().currentScreen === this)
533 Oobe.getInstance().updateScreenSize(this); 604 Oobe.getInstance().updateScreenSize(this);
534 }, 605 },
535 606
536 /** 607 /**
537 * Whether the current auth flow is SAML. 608 * Whether the current auth flow is SAML.
538 */ 609 */
539 isSAML: function() { 610 isSAML: function() {
540 return this.gaiaAuthHost_.authFlow == 611 return this.gaiaAuthHost_.authFlow ==
541 cr.login.GaiaAuthHost.AuthFlow.SAML; 612 cr.login.GaiaAuthHost.AuthFlow.SAML;
(...skipping 22 matching lines...) Expand all
564 } 635 }
565 636
566 this.updateControlsState(); 637 this.updateControlsState();
567 }, 638 },
568 639
569 /** 640 /**
570 * Invoked when the auth host emits 'ready' event. 641 * Invoked when the auth host emits 'ready' event.
571 * @private 642 * @private
572 */ 643 */
573 onAuthReady_: function() { 644 onAuthReady_: function() {
574 showViewProcessed_ = false; 645 this.showViewProcessed_ = false;
575 this.startLoadAnimationGuardTimer_(); 646 this.startLoadAnimationGuardTimer_();
576 this.clearLoadingTimer_(); 647 this.clearLoadingTimer_();
577 this.loading = false; 648 this.loading = false;
578 649
579 // Warm up the user images screen. 650 // Warm up the user images screen.
580 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); 651 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER});
581 }, 652 },
582 653
583 /** 654 /**
584 * Invoked when the auth host emits 'dialogShown' event. 655 * Invoked when the auth host emits 'dialogShown' event.
(...skipping 20 matching lines...) Expand all
605 this.lastBackMessageValue_ = !!e.detail; 676 this.lastBackMessageValue_ = !!e.detail;
606 this.updateControlsState(); 677 this.updateControlsState();
607 }, 678 },
608 679
609 /** 680 /**
610 * Invoked when the auth host emits 'showView' event or when corresponding 681 * Invoked when the auth host emits 'showView' event or when corresponding
611 * guard time fires. 682 * guard time fires.
612 * @private 683 * @private
613 */ 684 */
614 onShowView_: function(e) { 685 onShowView_: function(e) {
615 if (showViewProcessed_) 686 if (this.showViewProcessed_)
616 return; 687 return;
617 688
618 showViewProcessed_ = true; 689 this.showViewProcessed_ = true;
619 this.clearLoadAnimationGuardTimer_(); 690 this.clearLoadAnimationGuardTimer_();
620 $('signin-frame').classList.add('show'); 691 this.getSigninFrame_().classList.toggle('show', true);
621 this.onLoginUIVisible_(); 692 this.onLoginUIVisible_();
622 }, 693 },
623 694
624 /** 695 /**
625 * Called when UI is shown. 696 * Called when UI is shown.
626 * @private 697 * @private
627 */ 698 */
628 onLoginUIVisible_: function() { 699 onLoginUIVisible_: function() {
629 // Show deferred error bubble. 700 // Show deferred error bubble.
630 if (this.errorBubble_) { 701 if (this.errorBubble_) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 872
802 /** 873 /**
803 * Clears input fields and switches to input mode. 874 * Clears input fields and switches to input mode.
804 * @param {boolean} takeFocus True to take focus. 875 * @param {boolean} takeFocus True to take focus.
805 * @param {boolean} forceOnline Whether online sign-in should be forced. 876 * @param {boolean} forceOnline Whether online sign-in should be forced.
806 * If |forceOnline| is false previously used sign-in type will be used. 877 * If |forceOnline| is false previously used sign-in type will be used.
807 */ 878 */
808 reset: function(takeFocus, forceOnline) { 879 reset: function(takeFocus, forceOnline) {
809 // Reload and show the sign-in UI if needed. 880 // Reload and show the sign-in UI if needed.
810 if (takeFocus) { 881 if (takeFocus) {
811 if (!forceOnline && this.isOffline) { 882 if (!forceOnline && this.isOffline()) {
812 // Show 'Cancel' button to allow user to return to the main screen 883 // Show 'Cancel' button to allow user to return to the main screen
813 // (e.g. this makes sense when connection is back). 884 // (e.g. this makes sense when connection is back).
814 Oobe.getInstance().headerHidden = false; 885 Oobe.getInstance().headerHidden = false;
815 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN; 886 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN;
816 // Do nothing, since offline version is reloaded after an error comes. 887 // Do nothing, since offline version is reloaded after an error comes.
817 } else { 888 } else {
818 Oobe.showSigninUI(); 889 Oobe.showSigninUI();
819 } 890 }
820 } 891 }
821 }, 892 },
822 893
823 /** 894 /**
824 * Reloads extension frame. 895 * Reloads extension frame.
825 */ 896 */
826 doReload: function() { 897 doReload: function() {
827 if (this.isOffline) 898 if (this.isOffline())
828 return; 899 return;
829 this.gaiaAuthHost_.reload(); 900 this.gaiaAuthHost_.reload();
830 this.loading = true; 901 this.loading = true;
831 this.startLoadingTimer_(); 902 this.startLoadingTimer_();
832 this.lastBackMessageValue_ = false; 903 this.lastBackMessageValue_ = false;
833 this.authCompleted_ = false; 904 this.authCompleted_ = false;
834 this.updateControlsState(); 905 this.updateControlsState();
835 }, 906 },
836 907
837 /** 908 /**
838 * Shows sign-in error bubble. 909 * Shows sign-in error bubble.
839 * @param {number} loginAttempts Number of login attemps tried. 910 * @param {number} loginAttempts Number of login attemps tried.
840 * @param {HTMLElement} content Content to show in bubble. 911 * @param {HTMLElement} content Content to show in bubble.
841 */ 912 */
842 showErrorBubble: function(loginAttempts, error) { 913 showErrorBubble: function(loginAttempts, error) {
843 if (this.isOffline) { 914 if (this.isOffline()) {
844 $('add-user-button').hidden = true; 915 $('add-user-button').hidden = true;
845 // Reload offline version of the sign-in extension, which will show 916 // Reload offline version of the sign-in extension, which will show
846 // error itself. 917 // error itself.
847 chrome.send('offlineLogin', [this.email]); 918 chrome.send('offlineLogin', [this.email]);
848 } else if (!this.loading) { 919 } else if (!this.loading) {
849 // TODO(dzhioev): investigate if this branch ever get hit. 920 // TODO(dzhioev): investigate if this branch ever get hit.
850 $('bubble').showContentForElement($('gaia-signin-form-container'), 921 $('bubble').showContentForElement($('gaia-signin-form-container'),
851 cr.ui.Bubble.Attachment.LEFT, 922 cr.ui.Bubble.Attachment.LEFT,
852 error); 923 error);
853 } else { 924 } else {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 onIdentifierEntered: function(data) { 958 onIdentifierEntered: function(data) {
888 chrome.send('identifierEntered', [data.accountIdentifier]); 959 chrome.send('identifierEntered', [data.accountIdentifier]);
889 }, 960 },
890 961
891 /** 962 /**
892 * Sets enterprise info strings for offline gaia. 963 * Sets enterprise info strings for offline gaia.
893 * Also sets callback and sends message whether we already have email and 964 * Also sets callback and sends message whether we already have email and
894 * should switch to the password screen with error. 965 * should switch to the password screen with error.
895 */ 966 */
896 loadOffline: function(params) { 967 loadOffline: function(params) {
968 this.loading = true;
969 this.startLoadingTimer_();
897 var offlineLogin = $('offline-gaia'); 970 var offlineLogin = $('offline-gaia');
898 if ('enterpriseInfoMessage' in params) 971 offlineLogin.showEnterpriseMessage = !!('enterpriseDomain' in params);
899 offlineLogin.enterpriseInfo = params['enterpriseInfoMessage'];
900 if ('emailDomain' in params) 972 if ('emailDomain' in params)
901 offlineLogin.emailDomain = '@' + params['emailDomain']; 973 offlineLogin.emailDomain = '@' + params['emailDomain'];
902 offlineLogin.setEmail(params.email); 974 offlineLogin.setEmail(params.email);
903 this.onAuthReady_(); 975 this.onAuthReady_();
904 }, 976 },
905 977
906 /** 978 /**
907 * Show/Hide error when user is not in whitelist. When UI is hidden 979 * Show/Hide error when user is not in whitelist. When UI is hidden
908 * GAIA is reloaded. 980 * GAIA is reloaded.
909 * @param {boolean} show Show/hide error UI. 981 * @param {boolean} show Show/hide error UI.
(...skipping 10 matching lines...) Expand all
920 this.classList.toggle('whitelist-error', show); 992 this.classList.toggle('whitelist-error', show);
921 this.loading = !show; 993 this.loading = !show;
922 994
923 if (!show) 995 if (!show)
924 Oobe.showSigninUI(); 996 Oobe.showSigninUI();
925 997
926 this.updateControlsState(); 998 this.updateControlsState();
927 } 999 }
928 }; 1000 };
929 }); 1001 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698