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 animation guard timer. Started when GAIA page is loaded | 10 // GAIA animation guard timer. Started when GAIA page is loaded |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 * The most recent period of time that the user has interacted. This is | 172 * The most recent period of time that the user has interacted. This is |
173 * only updated when the offline page is active and the device is online. | 173 * only updated when the offline page is active and the device is online. |
174 */ | 174 */ |
175 mostRecentUserActivity_: Date.now(), | 175 mostRecentUserActivity_: Date.now(), |
176 | 176 |
177 /** | 177 /** |
178 * An element containg navigation buttons. | 178 * An element containg navigation buttons. |
179 */ | 179 */ |
180 navigation_: undefined, | 180 navigation_: undefined, |
181 | 181 |
| 182 |
| 183 /** |
| 184 * This is a copy of authenticator object attribute. |
| 185 * UI is tied to API version, so we adjust authernticator container |
| 186 * to match the API version. |
| 187 * Note that this cannot be changed after authenticator is created. |
| 188 */ |
| 189 chromeOSApiVersion_: undefined, |
| 190 |
182 /** @override */ | 191 /** @override */ |
183 decorate: function() { | 192 decorate: function() { |
184 this.navigation_ = $('gaia-navigation'); | 193 this.navigation_ = $('gaia-navigation'); |
185 | 194 |
186 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); | 195 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); |
187 this.gaiaAuthHost_.addEventListener( | 196 this.gaiaAuthHost_.addEventListener( |
188 'ready', this.onAuthReady_.bind(this)); | 197 'ready', this.onAuthReady_.bind(this)); |
189 | 198 |
190 var that = this; | 199 var that = this; |
191 [this.gaiaAuthHost_, $('offline-gaia'), $('offline-ad-auth')].forEach( | 200 [this.gaiaAuthHost_, $('offline-gaia'), $('offline-ad-auth')].forEach( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 this.gaiaAuthHost_.addEventListener( | 245 this.gaiaAuthHost_.addEventListener( |
237 'authFlowChange', this.onAuthFlowChange_.bind(this)); | 246 'authFlowChange', this.onAuthFlowChange_.bind(this)); |
238 this.gaiaAuthHost_.addEventListener( | 247 this.gaiaAuthHost_.addEventListener( |
239 'videoEnabledChange', this.onVideoEnabledChange_.bind(this)); | 248 'videoEnabledChange', this.onVideoEnabledChange_.bind(this)); |
240 | 249 |
241 this.gaiaAuthHost_.addEventListener( | 250 this.gaiaAuthHost_.addEventListener( |
242 'loadAbort', this.onLoadAbortMessage_.bind(this)); | 251 'loadAbort', this.onLoadAbortMessage_.bind(this)); |
243 this.gaiaAuthHost_.addEventListener( | 252 this.gaiaAuthHost_.addEventListener( |
244 'identifierEntered', this.onIdentifierEnteredMessage_.bind(this)); | 253 'identifierEntered', this.onIdentifierEnteredMessage_.bind(this)); |
245 | 254 |
246 this.navigation_.addEventListener('back', function() { | 255 this.navigation_.addEventListener( |
247 this.navigation_.backVisible = false; | 256 'back', this.onBackButtonClicked_.bind(this, null)); |
248 this.getSigninFrame_().back(); | 257 |
249 }.bind(this)); | 258 $('signin-back-button') |
| 259 .addEventListener( |
| 260 'click', this.onBackButtonClicked_.bind(this, true)); |
250 | 261 |
251 this.navigation_.addEventListener('close', function() { | 262 this.navigation_.addEventListener('close', function() { |
252 this.cancel(); | 263 this.cancel(); |
253 }.bind(this)); | 264 }.bind(this)); |
254 this.navigation_.addEventListener('refresh', function() { | 265 this.navigation_.addEventListener('refresh', function() { |
255 this.cancel(); | 266 this.cancel(); |
256 }.bind(this)); | 267 }.bind(this)); |
257 | 268 |
258 $('gaia-whitelist-error').addEventListener('buttonclick', function() { | 269 $('gaia-whitelist-error').addEventListener('buttonclick', function() { |
259 this.showWhitelistCheckFailedError(false); | 270 this.showWhitelistCheckFailedError(false); |
(...skipping 13 matching lines...) Expand all Loading... |
273 .addEventListener('samlPageChangeAccountClicked', function() { | 284 .addEventListener('samlPageChangeAccountClicked', function() { |
274 // The user requests to change the account. We must clear the email | 285 // The user requests to change the account. We must clear the email |
275 // field of the auth params. | 286 // field of the auth params. |
276 this.gaiaAuthParams_.email = ''; | 287 this.gaiaAuthParams_.email = ''; |
277 this.screenMode = ScreenMode.DEFAULT; | 288 this.screenMode = ScreenMode.DEFAULT; |
278 this.loadGaiaAuthHost_(false /* doSamlRedirect */); | 289 this.loadGaiaAuthHost_(false /* doSamlRedirect */); |
279 }.bind(this)); | 290 }.bind(this)); |
280 }, | 291 }, |
281 | 292 |
282 /** | 293 /** |
| 294 * Handles clicks on "Back" button. |
| 295 * @param {boolean} isDialogButton If event comes from gaia-dialog. |
| 296 */ |
| 297 onBackButtonClicked_: function(isDialogButton) { |
| 298 if (isDialogButton && !this.navigation_.backVisible) { |
| 299 this.cancel(); |
| 300 } else { |
| 301 this.navigation_.backVisible = false; |
| 302 this.getSigninFrame_().back(); |
| 303 } |
| 304 }, |
| 305 |
| 306 /** |
283 * Loads the authenticator and updates the UI to reflect the loading state. | 307 * Loads the authenticator and updates the UI to reflect the loading state. |
284 * @param {boolean} doSamlRedirect If the authenticator should do | 308 * @param {boolean} doSamlRedirect If the authenticator should do |
285 * authentication by automatic redirection to the SAML-based enrollment | 309 * authentication by automatic redirection to the SAML-based enrollment |
286 * enterprise domain IdP. | 310 * enterprise domain IdP. |
287 */ | 311 */ |
288 loadGaiaAuthHost_: function(doSamlRedirect) { | 312 loadGaiaAuthHost_: function(doSamlRedirect) { |
289 this.loading = true; | 313 this.loading = true; |
290 this.startLoadingTimer_(); | 314 this.startLoadingTimer_(); |
291 | 315 |
292 this.gaiaAuthParams_.doSamlRedirect = doSamlRedirect; | 316 this.gaiaAuthParams_.doSamlRedirect = doSamlRedirect; |
(...skipping 17 matching lines...) Expand all Loading... |
310 return this.screenMode_ == ScreenMode.OFFLINE; | 334 return this.screenMode_ == ScreenMode.OFFLINE; |
311 }, | 335 }, |
312 | 336 |
313 /** | 337 /** |
314 * Sets the current screen mode and updates the visible elements | 338 * Sets the current screen mode and updates the visible elements |
315 * accordingly. | 339 * accordingly. |
316 * @param {integer} value The screen mode. | 340 * @param {integer} value The screen mode. |
317 */ | 341 */ |
318 set screenMode(value) { | 342 set screenMode(value) { |
319 this.screenMode_ = value; | 343 this.screenMode_ = value; |
| 344 this.updateSigninFrameContainers_(); |
320 switch (this.screenMode_) { | 345 switch (this.screenMode_) { |
321 case ScreenMode.DEFAULT: | 346 case ScreenMode.DEFAULT: |
| 347 $('signin-frame-dialog').hidden = false; |
322 $('signin-frame').hidden = false; | 348 $('signin-frame').hidden = false; |
323 $('offline-gaia').hidden = true; | 349 $('offline-gaia').hidden = true; |
324 $('saml-interstitial').hidden = true; | 350 $('saml-interstitial').hidden = true; |
325 $('offline-ad-auth').hidden = true; | 351 $('offline-ad-auth').hidden = true; |
326 break; | 352 break; |
327 case ScreenMode.OFFLINE: | 353 case ScreenMode.OFFLINE: |
| 354 $('signin-frame-dialog').hidden = true; |
328 $('signin-frame').hidden = true; | 355 $('signin-frame').hidden = true; |
329 $('offline-gaia').hidden = false; | 356 $('offline-gaia').hidden = false; |
330 $('saml-interstitial').hidden = true; | 357 $('saml-interstitial').hidden = true; |
331 $('offline-ad-auth').hidden = true; | 358 $('offline-ad-auth').hidden = true; |
332 break; | 359 break; |
333 case ScreenMode.AD_AUTH: | 360 case ScreenMode.AD_AUTH: |
| 361 $('signin-frame-dialog').hidden = true; |
334 $('signin-frame').hidden = true; | 362 $('signin-frame').hidden = true; |
335 $('offline-gaia').hidden = true; | 363 $('offline-gaia').hidden = true; |
336 $('saml-interstitial').hidden = true; | 364 $('saml-interstitial').hidden = true; |
337 $('offline-ad-auth').hidden = false; | 365 $('offline-ad-auth').hidden = false; |
338 break; | 366 break; |
339 case ScreenMode.SAML_INTERSTITIAL: | 367 case ScreenMode.SAML_INTERSTITIAL: |
| 368 $('signin-frame-dialog').hidden = true; |
340 $('signin-frame').hidden = true; | 369 $('signin-frame').hidden = true; |
341 $('offline-gaia').hidden = true; | 370 $('offline-gaia').hidden = true; |
342 $('saml-interstitial').hidden = false; | 371 $('saml-interstitial').hidden = false; |
343 $('offline-ad-auth').hidden = true; | 372 $('offline-ad-auth').hidden = true; |
344 break; | 373 break; |
345 } | 374 } |
346 | |
347 chrome.send('updateOfflineLogin', [this.isOffline()]); | 375 chrome.send('updateOfflineLogin', [this.isOffline()]); |
348 this.updateControlsState(); | 376 this.updateControlsState(); |
349 }, | 377 }, |
350 | 378 |
351 /** | 379 /** |
352 * This enables or disables trying to go back to the online login page | 380 * This enables or disables trying to go back to the online login page |
353 * after the user is idle for a few minutes, assuming that we're currently | 381 * after the user is idle for a few minutes, assuming that we're currently |
354 * in the offline one. This is only applicable when the offline page is | 382 * in the offline one. This is only applicable when the offline page is |
355 * currently active. It is intended that when the device goes online, this | 383 * currently active. It is intended that when the device goes online, this |
356 * gets called with true; when it goes offline, this gets called with | 384 * gets called with true; when it goes offline, this gets called with |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 | 621 |
594 $('login-header-bar').showCreateSupervisedButton = | 622 $('login-header-bar').showCreateSupervisedButton = |
595 data.supervisedUsersCanCreate; | 623 data.supervisedUsersCanCreate; |
596 $('login-header-bar').showGuestButton = data.guestSignin; | 624 $('login-header-bar').showGuestButton = data.guestSignin; |
597 | 625 |
598 // Reset SAML | 626 // Reset SAML |
599 this.classList.toggle('full-width', false); | 627 this.classList.toggle('full-width', false); |
600 $('saml-notice-container').hidden = true; | 628 $('saml-notice-container').hidden = true; |
601 this.samlPasswordConfirmAttempt_ = 0; | 629 this.samlPasswordConfirmAttempt_ = 0; |
602 | 630 |
| 631 this.chromeOSApiVersion_ = data.chromeOSApiVersion; |
| 632 if (this.chromeOSApiVersion_ == 2) |
| 633 $('signin-frame-container-v2').appendChild($('signin-frame')); |
| 634 |
| 635 this.updateSigninFrameContainers_(); |
| 636 |
603 // Screen size could have been changed because of 'full-width' classes. | 637 // Screen size could have been changed because of 'full-width' classes. |
604 if (Oobe.getInstance().currentScreen === this) | 638 if (Oobe.getInstance().currentScreen === this) |
605 Oobe.getInstance().updateScreenSize(this); | 639 Oobe.getInstance().updateScreenSize(this); |
606 | 640 |
607 var params = {}; | 641 var params = {}; |
608 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) { | 642 for (var i in cr.login.GaiaAuthHost.SUPPORTED_PARAMS) { |
609 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i]; | 643 var name = cr.login.GaiaAuthHost.SUPPORTED_PARAMS[i]; |
610 if (data[name]) | 644 if (data[name]) |
611 params[name] = data[name]; | 645 params[name] = data[name]; |
612 } | 646 } |
(...skipping 22 matching lines...) Expand all Loading... |
635 this.loading = false; | 669 this.loading = false; |
636 // This event is for the browser tests. | 670 // This event is for the browser tests. |
637 $('saml-interstitial').fire('samlInterstitialPageReady'); | 671 $('saml-interstitial').fire('samlInterstitialPageReady'); |
638 break; | 672 break; |
639 } | 673 } |
640 this.updateControlsState(); | 674 this.updateControlsState(); |
641 chrome.send('authExtensionLoaded'); | 675 chrome.send('authExtensionLoaded'); |
642 }, | 676 }, |
643 | 677 |
644 /** | 678 /** |
| 679 * Displays correct screen container for given mode and APi version. |
| 680 */ |
| 681 updateSigninFrameContainers_: function() { |
| 682 let old_state = this.classList.contains('v2'); |
| 683 this.classList.toggle('v2', false); |
| 684 if (this.screenMode_ == ScreenMode.DEFAULT && |
| 685 this.chromeOSApiVersion_ == 2) { |
| 686 this.classList.toggle('v2', true); |
| 687 } |
| 688 // Switching between signin-frame-dialog and gaia-step-contents |
| 689 // updates screen size. |
| 690 if (old_state != this.classList.contains('v2')) |
| 691 Oobe.getInstance().updateScreenSize(this); |
| 692 }, |
| 693 |
| 694 /** |
645 * Whether the current auth flow is SAML. | 695 * Whether the current auth flow is SAML. |
646 */ | 696 */ |
647 isSAML: function() { | 697 isSAML: function() { |
648 return this.gaiaAuthHost_.authFlow == cr.login.GaiaAuthHost.AuthFlow.SAML; | 698 return this.gaiaAuthHost_.authFlow == cr.login.GaiaAuthHost.AuthFlow.SAML; |
649 }, | 699 }, |
650 | 700 |
651 /** | 701 /** |
652 * Helper function to update the title bar. | 702 * Helper function to update the title bar. |
653 */ | 703 */ |
654 updateSamlNotice_: function() { | 704 updateSamlNotice_: function() { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 if (this.screenMode_ != ScreenMode.AD_AUTH) | 1161 if (this.screenMode_ != ScreenMode.AD_AUTH) |
1112 return; | 1162 return; |
1113 var adAuthUI = this.getSigninFrame_(); | 1163 var adAuthUI = this.getSigninFrame_(); |
1114 adAuthUI.setUser(username); | 1164 adAuthUI.setUser(username); |
1115 adAuthUI.setInvalid(errorState); | 1165 adAuthUI.setInvalid(errorState); |
1116 this.loading = false; | 1166 this.loading = false; |
1117 Oobe.getInstance().headerHidden = false; | 1167 Oobe.getInstance().headerHidden = false; |
1118 } | 1168 } |
1119 }; | 1169 }; |
1120 }); | 1170 }); |
OLD | NEW |