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

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: Fix failing tests 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 if (this.screenMode_ != ScreenMode.SAML_INTERSTITIAL)
xiyuan 2016/03/28 20:58:40 nit: seem unnecessary since the event could only b
afakhry 2016/03/28 23:15:32 I was just being paranoid! :) Done.
248 return;
249
250 this.screenMode = ScreenMode.DEFAULT;
251 this.loadGaiaAuthHost_(true /* doSamlRedirect */);
252 }.bind(this));
253 $('saml-interstitial').addEventListener('samlPageChangeAccountClicked',
254 function() {
255 if (this.screenMode_ != ScreenMode.SAML_INTERSTITIAL)
xiyuan 2016/03/28 20:58:40 nit: ditto
afakhry 2016/03/28 23:15:32 Done.
256 return;
257
258 this.screenMode = ScreenMode.DEFAULT;
259 this.loadGaiaAuthHost_(false /* doSamlRedirect */);
260 }.bind(this));
231 }, 261 },
232 262
233 /** 263 /**
264 * Loads the authenticator and updates the UI to reflect the loading state.
265 * @param {boolean} doSamlRedirect If the authenticator should do
266 * authentication by automatic redirection to the SAML-based enrollment
xiyuan 2016/03/28 20:58:40 nit: wrong indent
afakhry 2016/03/28 23:15:32 Done.
xiyuan 2016/03/29 02:10:49 What you did in new patch is fine but I meant to i
afakhry 2016/03/29 03:12:02 Done.
267 * enterprise domain IdP.
268 */
269 loadGaiaAuthHost_: function(doSamlRedirect) {
270 this.loading = true;
271 this.startLoadingTimer_();
272
273 this.gaiaAuthParams_.doSamlRedirect = doSamlRedirect;
274 this.gaiaAuthHost_.load(cr.login.GaiaAuthHost.AuthMode.DEFAULT,
275 this.gaiaAuthParams_);
276 },
277
278 /**
234 * Header text of the screen. 279 * Header text of the screen.
235 * @type {string} 280 * @type {string}
236 */ 281 */
237 get header() { 282 get header() {
238 return loadTimeData.getString('signinScreenTitle'); 283 return loadTimeData.getString('signinScreenTitle');
239 }, 284 },
240 285
241 /** 286 /**
242 * Returns true if offline version of Gaia is used. 287 * Returns true if offline version of Gaia is used.
243 * @type {boolean} 288 * @type {boolean}
244 */ 289 */
245 get isOffline() { 290 isOffline: function() {
246 return this.isOffline_; 291 return this.screenMode_ == ScreenMode.OFFLINE;
247 }, 292 },
248 293
249 /** 294 /**
250 * Sets whether offline version of Gaia is used. 295 * Sets the current screen mode and updates the visible elements
251 * @param {boolean} value Whether offline version of Gaia is used. 296 * accordingly.
297 * @param {integer} value The screen mode.
252 */ 298 */
253 set isOffline(value) { 299 set screenMode(value) {
254 this.isOffline_ = !!value; 300 this.screenMode_ = value;
255 $('signin-frame').hidden = this.isOffline_; 301 switch (this.screenMode_) {
256 $('offline-gaia').hidden = !this.isOffline_; 302 case ScreenMode.DEFAULT:
257 chrome.send('updateOfflineLogin', [value]); 303 $('signin-frame').hidden = false;
304 $('offline-gaia').hidden = true;
305 $('saml-interstitial').hidden = true;
306 break;
307 case ScreenMode.OFFLINE:
308 $('signin-frame').hidden = true;
309 $('offline-gaia').hidden = false;
310 $('saml-interstitial').hidden = true;
311 break;
312 case ScreenMode.SAML_INTERSTITIAL:
313 $('signin-frame').hidden = true;
314 $('offline-gaia').hidden = true;
315 $('saml-interstitial').hidden = false;
316 break;
317 }
318
xiyuan 2016/03/28 20:58:40 Should we call this.updateControlsState() since |s
afakhry 2016/03/28 23:15:32 Done.
319 chrome.send('updateOfflineLogin', [this.isOffline()]);
258 }, 320 },
259 321
260 /** 322 /**
261 * This enables or disables trying to go back to the online login page 323 * 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 324 * 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 325 * 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 326 * 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 327 * gets called with true; when it goes offline, this gets called with
266 * false. 328 * false.
267 */ 329 */
(...skipping 12 matching lines...) Expand all
280 if (!self.updateActivityTime_) { 342 if (!self.updateActivityTime_) {
281 self.updateActivityTime_ = function() { 343 self.updateActivityTime_ = function() {
282 self.mostRecentUserActivity_ = Date.now(); 344 self.mostRecentUserActivity_ = Date.now();
283 }; 345 };
284 } 346 }
285 347
286 // Begin monitoring. 348 // Begin monitoring.
287 if (shouldMonitor) { 349 if (shouldMonitor) {
288 // If we're not using the offline login page or we're already 350 // If we're not using the offline login page or we're already
289 // monitoring, then we don't need to do anything. 351 // monitoring, then we don't need to do anything.
290 if (!self.isOffline || self.tryToGoToOnlineLoginPageCallbackId_ !== -1) 352 if (!self.isOffline() ||
353 self.tryToGoToOnlineLoginPageCallbackId_ !== -1) {
291 return; 354 return;
355 }
292 356
293 self.mostRecentUserActivity_ = Date.now(); 357 self.mostRecentUserActivity_ = Date.now();
294 ACTIVITY_EVENTS.forEach(function(event) { 358 ACTIVITY_EVENTS.forEach(function(event) {
295 document.addEventListener(event, self.updateActivityTime_); 359 document.addEventListener(event, self.updateActivityTime_);
296 }); 360 });
297 361
298 self.tryToGoToOnlineLoginPageCallbackId_ = setInterval(function() { 362 self.tryToGoToOnlineLoginPageCallbackId_ = setInterval(function() {
299 // If we're not in the offline page or the signin page, then we want 363 // If we're not in the offline page or the signin page, then we want
300 // to terminate monitoring. 364 // to terminate monitoring.
301 if (!self.isOffline || 365 if (!self.isOffline() ||
302 Oobe.getInstance().currentScreen.id != 'gaia-signin') { 366 Oobe.getInstance().currentScreen.id != 'gaia-signin') {
303 self.monitorOfflineIdle(false); 367 self.monitorOfflineIdle(false);
304 return; 368 return;
305 } 369 }
306 370
307 var idleDuration = Date.now() - self.mostRecentUserActivity_; 371 var idleDuration = Date.now() - self.mostRecentUserActivity_;
308 if (idleDuration > IDLE_TIME_UNTIL_EXIT_OFFLINE_IN_MILLISECONDS) { 372 if (idleDuration > IDLE_TIME_UNTIL_EXIT_OFFLINE_IN_MILLISECONDS) {
309 self.monitorOfflineIdle(false); 373 self.monitorOfflineIdle(false);
310 Oobe.resetSigninUI(true); 374 Oobe.resetSigninUI(true);
311 } 375 }
(...skipping 14 matching lines...) Expand all
326 } 390 }
327 }, 391 },
328 392
329 /** 393 /**
330 * Shows/hides loading UI. 394 * Shows/hides loading UI.
331 * @param {boolean} show True to show loading UI. 395 * @param {boolean} show True to show loading UI.
332 * @private 396 * @private
333 */ 397 */
334 showLoadingUI_: function(show) { 398 showLoadingUI_: function(show) {
335 $('gaia-loading').hidden = !show; 399 $('gaia-loading').hidden = !show;
336 this.getSigninFrame_().hidden = show; 400 if (this.screenMode_ != ScreenMode.DEFAULT)
401 this.getSigninFrame_().hidden = show;
402 this.getSigninFrame_().classList.toggle('show', !show);
337 this.classList.toggle('loading', show); 403 this.classList.toggle('loading', show);
338 $('signin-frame').classList.remove('show');
339 this.updateControlsState(); 404 this.updateControlsState();
340 }, 405 },
341 406
342 /** 407 /**
343 * Handler for Gaia loading timeout. 408 * Handler for Gaia loading timeout.
344 * @private 409 * @private
345 */ 410 */
346 onLoadingTimeOut_: function() { 411 onLoadingTimeOut_: function() {
347 if (this != Oobe.getInstance().currentScreen) 412 if (this != Oobe.getInstance().currentScreen)
348 return; 413 return;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 480
416 this.showLoadingUI_(loading); 481 this.showLoadingUI_(loading);
417 }, 482 },
418 483
419 /** 484 /**
420 * Event handler that is invoked just before the frame is shown. 485 * Event handler that is invoked just before the frame is shown.
421 * @param {string} data Screen init payload. Url of auth extension start 486 * @param {string} data Screen init payload. Url of auth extension start
422 * page. 487 * page.
423 */ 488 */
424 onBeforeShow: function(data) { 489 onBeforeShow: function(data) {
490 this.screenMode = ScreenMode.DEFAULT;
491 this.loading = true;
425 chrome.send('loginUIStateChanged', ['gaia-signin', true]); 492 chrome.send('loginUIStateChanged', ['gaia-signin', true]);
426 $('progress-dots').hidden = true; 493 $('progress-dots').hidden = true;
427 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN; 494 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN;
428 495
429 // Ensure that GAIA signin (or loading UI) is actually visible. 496 // Ensure that GAIA signin (or loading UI) is actually visible.
430 window.requestAnimationFrame(function() { 497 window.requestAnimationFrame(function() {
431 chrome.send('loginVisible', ['gaia-loading']); 498 chrome.send('loginVisible', ['gaia-loading']);
432 }); 499 });
433 500
434 this.classList.toggle('loading', this.loading);
435
436 // Button header is always visible when sign in is presented. 501 // Button header is always visible when sign in is presented.
437 // Header is hidden once GAIA reports on successful sign in. 502 // Header is hidden once GAIA reports on successful sign in.
438 Oobe.getInstance().headerHidden = false; 503 Oobe.getInstance().headerHidden = false;
439 504
440 this.lastBackMessageValue_ = false; 505 this.lastBackMessageValue_ = false;
441 this.updateControlsState(); 506 this.updateControlsState();
442 }, 507 },
443 508
444 getSigninFrame_: function() { 509 getSigninFrame_: function() {
445 return this.isOffline ? $('offline-gaia') : $('signin-frame'); 510 switch (this.screenMode_) {
511 case ScreenMode.DEFAULT:
512 return $('signin-frame');
513 case ScreenMode.OFFLINE:
514 return $('offline-gaia');
515 case ScreenMode.SAML_INTERSTITIAL:
516 return $('saml-interstitial');
517 }
446 }, 518 },
447 519
448 focusSigninFrame: function() { 520 focusSigninFrame: function() {
449 this.getSigninFrame_().focus(); 521 this.getSigninFrame_().focus();
450 }, 522 },
451 523
452 onAfterShow: function() { 524 onAfterShow: function() {
453 if (!this.loading) 525 if (!this.loading)
454 this.focusSigninFrame(); 526 this.focusSigninFrame();
455 }, 527 },
456 528
457 /** 529 /**
458 * Event handler that is invoked just before the screen is hidden. 530 * Event handler that is invoked just before the screen is hidden.
459 */ 531 */
460 onBeforeHide: function() { 532 onBeforeHide: function() {
461 chrome.send('loginUIStateChanged', ['gaia-signin', false]); 533 chrome.send('loginUIStateChanged', ['gaia-signin', false]);
462 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; 534 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN;
463 $('offline-gaia').switchToEmailCard(false /* animated */); 535 $('offline-gaia').switchToEmailCard(false /* animated */);
464 }, 536 },
465 537
466 /** 538 /**
467 * Loads the authentication extension into the iframe. 539 * Loads the authentication extension into the iframe.
468 * @param {Object} data Extension parameters bag. 540 * @param {Object} data Extension parameters bag.
469 * @private 541 * @private
470 */ 542 */
471 loadAuthExtension: function(data) { 543 loadAuthExtension: function(data) {
472 this.isOffline = data.useOffline; 544 this.screenMode = data.screenMode;
473 this.email = ''; 545 this.email = '';
474 this.authCompleted_ = false; 546 this.authCompleted_ = false;
475 this.lastBackMessageValue_ = false; 547 this.lastBackMessageValue_ = false;
476 548 $('saml-interstitial').domain = data.enterpriseDomain;
xiyuan 2016/03/28 20:58:40 nit: Move this into "case ScreenMode.SAML_INTERSTI
afakhry 2016/03/28 23:15:32 Done.
477 // Reset SAML
478 this.classList.toggle('full-width', false);
479 this.samlPasswordConfirmAttempt_ = 0;
480 549
481 this.updateAuthExtension_(data); 550 this.updateAuthExtension_(data);
482 551
483 var params = {}; 552 var params = {};
484 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) { 553 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) {
485 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i]; 554 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i];
486 if (data[name]) 555 if (data[name])
487 params[name] = data[name]; 556 params[name] = data[name];
488 } 557 }
489 558
490 if (data.enterpriseInfoMessage)
491 params.enterpriseInfoMessage = data.enterpriseInfoMessage;
492
493 params.isNewGaiaFlow = true; 559 params.isNewGaiaFlow = true;
560 params.doSamlRedirect =
561 (this.screenMode_ == ScreenMode.SAML_INTERSTITIAL);
xiyuan 2016/03/28 20:58:40 nit: wrong indent?
afakhry 2016/03/28 23:15:32 Done.
494 562
495 // Screen size could have been changed because of 'full-width' classes. 563 // Screen size could have been changed because of 'full-width' classes.
496 if (Oobe.getInstance().currentScreen === this) 564 if (Oobe.getInstance().currentScreen === this)
497 Oobe.getInstance().updateScreenSize(this); 565 Oobe.getInstance().updateScreenSize(this);
498 566
499 if (data.forceReload || 567 if (data.forceReload ||
500 JSON.stringify(this.gaiaAuthParams_) != JSON.stringify(params)) { 568 JSON.stringify(this.gaiaAuthParams_) != JSON.stringify(params)) {
501 this.gaiaAuthParams_ = params; 569 this.gaiaAuthParams_ = params;
502 this.loading = true;
503 this.startLoadingTimer_();
504 570
505 if (this.isOffline) { 571 switch (this.screenMode_) {
506 this.loadOffline(params); 572 case ScreenMode.DEFAULT:
507 } else { 573 this.loadGaiaAuthHost_(false /* doSamlRedirect */);
508 this.gaiaAuthHost_.load(cr.login.GaiaAuthHost.AuthMode.DEFAULT, 574 break;
509 params); 575
576 case ScreenMode.OFFLINE:
577 this.loadOffline(params);
578 break;
579
580 case ScreenMode.SAML_INTERSTITIAL:
581 if (this.loading)
582 this.loading = false;
583 break;
510 } 584 }
511 } 585 }
512 this.updateControlsState(); 586 this.updateControlsState();
513 }, 587 },
514 588
515 /** 589 /**
516 * Updates the authentication extension with new parameters, if needed. 590 * Updates the authentication extension with new parameters, if needed.
517 * @param {Object} data New extension parameters bag. 591 * @param {Object} data New extension parameters bag.
518 * @private 592 * @private
519 */ 593 */
520 updateAuthExtension_: function(data) { 594 updateAuthExtension_: function(data) {
521 $('login-header-bar').showCreateSupervisedButton = 595 $('login-header-bar').showCreateSupervisedButton =
522 data.supervisedUsersCanCreate; 596 data.supervisedUsersCanCreate;
523 $('login-header-bar').showGuestButton = data.guestSignin; 597 $('login-header-bar').showGuestButton = data.guestSignin;
524 598
525 this.updateControlsState(); 599 this.updateControlsState();
526 600
601 // Reset SAML
527 this.classList.toggle('full-width', false); 602 this.classList.toggle('full-width', false);
603 this.samlPasswordConfirmAttempt_ = 0;
528 if (Oobe.getInstance().currentScreen === this) 604 if (Oobe.getInstance().currentScreen === this)
529 Oobe.getInstance().updateScreenSize(this); 605 Oobe.getInstance().updateScreenSize(this);
530 }, 606 },
531 607
532 /** 608 /**
533 * Whether the current auth flow is SAML. 609 * Whether the current auth flow is SAML.
534 */ 610 */
535 isSAML: function() { 611 isSAML: function() {
536 return this.gaiaAuthHost_.authFlow == 612 return this.gaiaAuthHost_.authFlow ==
537 cr.login.GaiaAuthHost.AuthFlow.SAML; 613 cr.login.GaiaAuthHost.AuthFlow.SAML;
538 }, 614 },
539 615
540 /** 616 /**
541 * Invoked when the authDomain property is changed on the GAIA host. 617 * Invoked when the authDomain property is changed on the GAIA host.
542 */ 618 */
543 onAuthDomainChange_: function() { 619 onAuthDomainChange_: function() {
544 $('saml-notice-message').textContent = loadTimeData.getStringF( 620 $('saml-notice-message').textContent = loadTimeData.getStringF(
545 'samlNotice', 621 'samlNotice',
546 this.gaiaAuthHost_.authDomain); 622 this.gaiaAuthHost_.authDomain);
547 }, 623 },
548 624
549 /** 625 /**
550 * Invoked when the authFlow property is changed on the GAIA host. 626 * Invoked when the authFlow property is changed on the GAIA host.
551 */ 627 */
552 onAuthFlowChange_: function() { 628 onAuthFlowChange_: function() {
553 var isSAML = this.isSAML(); 629 var isSAML = this.isSAML();
554 630
631 if (isSAML && this.loading)
xiyuan 2016/03/28 20:58:40 Think we should fix this in authenticator.js. That
afakhry 2016/03/28 23:15:32 Done.
632 this.onAuthReady_();
633
555 this.classList.toggle('full-width', isSAML); 634 this.classList.toggle('full-width', isSAML);
556 $('saml-notice-container').hidden = !isSAML; 635 $('saml-notice-container').hidden = !isSAML;
557 636
558 if (Oobe.getInstance().currentScreen === this) { 637 if (Oobe.getInstance().currentScreen === this) {
559 Oobe.getInstance().updateScreenSize(this); 638 Oobe.getInstance().updateScreenSize(this);
560 } 639 }
561 640
562 this.updateControlsState(); 641 this.updateControlsState();
563 }, 642 },
564 643
565 /** 644 /**
566 * Invoked when the auth host emits 'ready' event. 645 * Invoked when the auth host emits 'ready' event.
567 * @private 646 * @private
568 */ 647 */
569 onAuthReady_: function() { 648 onAuthReady_: function() {
570 showViewProcessed_ = false; 649 this.showViewProcessed_ = false;
571 this.startLoadAnimationGuardTimer_(); 650 this.startLoadAnimationGuardTimer_();
572 this.clearLoadingTimer_(); 651 this.clearLoadingTimer_();
573 this.loading = false; 652 this.loading = false;
574 653
575 // Warm up the user images screen. 654 // Warm up the user images screen.
576 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER}); 655 Oobe.getInstance().preloadScreen({id: SCREEN_USER_IMAGE_PICKER});
577 }, 656 },
578 657
579 /** 658 /**
580 * Invoked when the auth host emits 'dialogShown' event. 659 * Invoked when the auth host emits 'dialogShown' event.
(...skipping 20 matching lines...) Expand all
601 this.lastBackMessageValue_ = !!e.detail; 680 this.lastBackMessageValue_ = !!e.detail;
602 this.updateControlsState(); 681 this.updateControlsState();
603 }, 682 },
604 683
605 /** 684 /**
606 * Invoked when the auth host emits 'showView' event or when corresponding 685 * Invoked when the auth host emits 'showView' event or when corresponding
607 * guard time fires. 686 * guard time fires.
608 * @private 687 * @private
609 */ 688 */
610 onShowView_: function(e) { 689 onShowView_: function(e) {
611 if (showViewProcessed_) 690 if (this.showViewProcessed_)
612 return; 691 return;
613 692
614 showViewProcessed_ = true; 693 this.showViewProcessed_ = true;
615 this.clearLoadAnimationGuardTimer_(); 694 this.clearLoadAnimationGuardTimer_();
616 $('signin-frame').classList.add('show'); 695 this.getSigninFrame_().classList.toggle('show', true);
617 this.onLoginUIVisible_(); 696 this.onLoginUIVisible_();
618 }, 697 },
619 698
620 /** 699 /**
621 * Called when UI is shown. 700 * Called when UI is shown.
622 * @private 701 * @private
623 */ 702 */
624 onLoginUIVisible_: function() { 703 onLoginUIVisible_: function() {
625 // Show deferred error bubble. 704 // Show deferred error bubble.
626 if (this.errorBubble_) { 705 if (this.errorBubble_) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 876
798 /** 877 /**
799 * Clears input fields and switches to input mode. 878 * Clears input fields and switches to input mode.
800 * @param {boolean} takeFocus True to take focus. 879 * @param {boolean} takeFocus True to take focus.
801 * @param {boolean} forceOnline Whether online sign-in should be forced. 880 * @param {boolean} forceOnline Whether online sign-in should be forced.
802 * If |forceOnline| is false previously used sign-in type will be used. 881 * If |forceOnline| is false previously used sign-in type will be used.
803 */ 882 */
804 reset: function(takeFocus, forceOnline) { 883 reset: function(takeFocus, forceOnline) {
805 // Reload and show the sign-in UI if needed. 884 // Reload and show the sign-in UI if needed.
806 if (takeFocus) { 885 if (takeFocus) {
807 if (!forceOnline && this.isOffline) { 886 if (!forceOnline && this.isOffline()) {
808 // Show 'Cancel' button to allow user to return to the main screen 887 // Show 'Cancel' button to allow user to return to the main screen
809 // (e.g. this makes sense when connection is back). 888 // (e.g. this makes sense when connection is back).
810 Oobe.getInstance().headerHidden = false; 889 Oobe.getInstance().headerHidden = false;
811 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN; 890 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN;
812 // Do nothing, since offline version is reloaded after an error comes. 891 // Do nothing, since offline version is reloaded after an error comes.
813 } else { 892 } else {
814 Oobe.showSigninUI(); 893 Oobe.showSigninUI();
815 } 894 }
816 } 895 }
817 }, 896 },
818 897
819 /** 898 /**
820 * Reloads extension frame. 899 * Reloads extension frame.
821 */ 900 */
822 doReload: function() { 901 doReload: function() {
823 if (this.isOffline) 902 if (this.isOffline())
824 return; 903 return;
825 this.gaiaAuthHost_.reload(); 904 this.gaiaAuthHost_.reload();
826 this.loading = true; 905 this.loading = true;
827 this.startLoadingTimer_(); 906 this.startLoadingTimer_();
828 this.lastBackMessageValue_ = false; 907 this.lastBackMessageValue_ = false;
829 this.authCompleted_ = false; 908 this.authCompleted_ = false;
830 this.updateControlsState(); 909 this.updateControlsState();
831 }, 910 },
832 911
833 /** 912 /**
834 * Shows sign-in error bubble. 913 * Shows sign-in error bubble.
835 * @param {number} loginAttempts Number of login attemps tried. 914 * @param {number} loginAttempts Number of login attemps tried.
836 * @param {HTMLElement} content Content to show in bubble. 915 * @param {HTMLElement} content Content to show in bubble.
837 */ 916 */
838 showErrorBubble: function(loginAttempts, error) { 917 showErrorBubble: function(loginAttempts, error) {
839 if (this.isOffline) { 918 if (this.isOffline()) {
840 $('add-user-button').hidden = true; 919 $('add-user-button').hidden = true;
841 // Reload offline version of the sign-in extension, which will show 920 // Reload offline version of the sign-in extension, which will show
842 // error itself. 921 // error itself.
843 chrome.send('offlineLogin', [this.email]); 922 chrome.send('offlineLogin', [this.email]);
844 } else if (!this.loading) { 923 } else if (!this.loading) {
845 // TODO(dzhioev): investigate if this branch ever get hit. 924 // TODO(dzhioev): investigate if this branch ever get hit.
846 $('bubble').showContentForElement($('gaia-signin-form-container'), 925 $('bubble').showContentForElement($('gaia-signin-form-container'),
847 cr.ui.Bubble.Attachment.LEFT, 926 cr.ui.Bubble.Attachment.LEFT,
848 error); 927 error);
849 } else { 928 } else {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 onIdentifierEntered: function(data) { 962 onIdentifierEntered: function(data) {
884 chrome.send('identifierEntered', [data.accountIdentifier]); 963 chrome.send('identifierEntered', [data.accountIdentifier]);
885 }, 964 },
886 965
887 /** 966 /**
888 * Sets enterprise info strings for offline gaia. 967 * Sets enterprise info strings for offline gaia.
889 * Also sets callback and sends message whether we already have email and 968 * Also sets callback and sends message whether we already have email and
890 * should switch to the password screen with error. 969 * should switch to the password screen with error.
891 */ 970 */
892 loadOffline: function(params) { 971 loadOffline: function(params) {
972 this.loading = true;
973 this.startLoadingTimer_();
893 var offlineLogin = $('offline-gaia'); 974 var offlineLogin = $('offline-gaia');
894 if ('enterpriseInfoMessage' in params) 975 offlineLogin.showEnterpriseMessage = !!('enterpriseDomain' in params);
895 offlineLogin.enterpriseInfo = params['enterpriseInfoMessage'];
896 if ('emailDomain' in params) 976 if ('emailDomain' in params)
897 offlineLogin.emailDomain = '@' + params['emailDomain']; 977 offlineLogin.emailDomain = '@' + params['emailDomain'];
898 offlineLogin.setEmail(params.email); 978 offlineLogin.setEmail(params.email);
899 this.onAuthReady_(); 979 this.onAuthReady_();
900 }, 980 },
901 981
902 /** 982 /**
903 * Show/Hide error when user is not in whitelist. When UI is hidden 983 * Show/Hide error when user is not in whitelist. When UI is hidden
904 * GAIA is reloaded. 984 * GAIA is reloaded.
905 * @param {boolean} show Show/hide error UI. 985 * @param {boolean} show Show/hide error UI.
(...skipping 10 matching lines...) Expand all
916 this.classList.toggle('whitelist-error', show); 996 this.classList.toggle('whitelist-error', show);
917 this.loading = !show; 997 this.loading = !show;
918 998
919 if (!show) 999 if (!show)
920 Oobe.showSigninUI(); 1000 Oobe.showSigninUI();
921 1001
922 this.updateControlsState(); 1002 this.updateControlsState();
923 } 1003 }
924 }; 1004 };
925 }); 1005 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698