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 Display manager for WebUI OOBE and login. | 6 * @fileoverview Display manager for WebUI OOBE and login. |
7 */ | 7 */ |
8 | 8 |
9 // TODO(xiyuan): Find a better to share those constants. | 9 // TODO(xiyuan): Find a better to share those constants. |
10 /** @const */ var SCREEN_OOBE_NETWORK = 'connect'; | 10 /** @const */ var SCREEN_OOBE_NETWORK = 'connect'; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 }; | 46 }; |
47 | 47 |
48 /* Possible UI states of the error screen. */ | 48 /* Possible UI states of the error screen. */ |
49 /** @const */ var ERROR_SCREEN_UI_STATE = { | 49 /** @const */ var ERROR_SCREEN_UI_STATE = { |
50 UNKNOWN: 'ui-state-unknown', | 50 UNKNOWN: 'ui-state-unknown', |
51 UPDATE: 'ui-state-update', | 51 UPDATE: 'ui-state-update', |
52 SIGNIN: 'ui-state-signin', | 52 SIGNIN: 'ui-state-signin', |
53 MANAGED_USER_CREATION_FLOW: 'ui-state-locally-managed' | 53 MANAGED_USER_CREATION_FLOW: 'ui-state-locally-managed' |
54 }; | 54 }; |
55 | 55 |
| 56 /* Possible types of UI. */ |
| 57 /** @const */ var DISPLAY_TYPE = { |
| 58 UNKNOWN: 'unknown', |
| 59 OOBE: 'oobe', |
| 60 LOGIN: 'login', |
| 61 LOCK: 'lock', |
| 62 USER_ADDING: 'user-adding' |
| 63 }; |
| 64 |
56 cr.define('cr.ui.login', function() { | 65 cr.define('cr.ui.login', function() { |
57 var Bubble = cr.ui.Bubble; | 66 var Bubble = cr.ui.Bubble; |
58 | 67 |
59 /** | 68 /** |
60 * Maximum time in milliseconds to wait for step transition to finish. | 69 * Maximum time in milliseconds to wait for step transition to finish. |
61 * The value is used as the duration for ensureTransitionEndEvent below. | 70 * The value is used as the duration for ensureTransitionEndEvent below. |
62 * It needs to be inline with the step screen transition duration time | 71 * It needs to be inline with the step screen transition duration time |
63 * defined in css file. The current value in css is 200ms. To avoid emulated | 72 * defined in css file. The current value in css is 200ms. To avoid emulated |
64 * webkitTransitionEnd fired before real one, 250ms is used. | 73 * webkitTransitionEnd fired before real one, 250ms is used. |
65 * @const | 74 * @const |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 */ | 132 */ |
124 allowToggleVersion_: false, | 133 allowToggleVersion_: false, |
125 | 134 |
126 /** | 135 /** |
127 * Whether keyboard navigation flow is enforced. | 136 * Whether keyboard navigation flow is enforced. |
128 * @type {boolean} | 137 * @type {boolean} |
129 */ | 138 */ |
130 forceKeyboardFlow_: false, | 139 forceKeyboardFlow_: false, |
131 | 140 |
132 /** | 141 /** |
| 142 * Type of UI. |
| 143 * @type {string} |
| 144 */ |
| 145 displayType_: DISPLAY_TYPE.UNKNOWN, |
| 146 |
| 147 get displayType() { |
| 148 return this.displayType_; |
| 149 }, |
| 150 |
| 151 set displayType(displayType) { |
| 152 this.displayType_ = displayType; |
| 153 }, |
| 154 |
| 155 /** |
133 * Gets current screen element. | 156 * Gets current screen element. |
134 * @type {HTMLElement} | 157 * @type {HTMLElement} |
135 */ | 158 */ |
136 get currentScreen() { | 159 get currentScreen() { |
137 return $(this.screens_[this.currentStep_]); | 160 return $(this.screens_[this.currentStep_]); |
138 }, | 161 }, |
139 | 162 |
140 /** | 163 /** |
141 * Hides/shows header (Shutdown/Add User/Cancel buttons). | 164 * Hides/shows header (Shutdown/Add User/Cancel buttons). |
142 * @param {boolean} hidden Whether header is hidden. | 165 * @param {boolean} hidden Whether header is hidden. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 defaultControl.focus(); | 364 defaultControl.focus(); |
342 }); | 365 }); |
343 ensureTransitionEndEvent(oldStep, MAX_SCREEN_TRANSITION_DURATION); | 366 ensureTransitionEndEvent(oldStep, MAX_SCREEN_TRANSITION_DURATION); |
344 } else { | 367 } else { |
345 oldStep.classList.add('hidden'); | 368 oldStep.classList.add('hidden'); |
346 if (defaultControl) | 369 if (defaultControl) |
347 defaultControl.focus(); | 370 defaultControl.focus(); |
348 } | 371 } |
349 } else { | 372 } else { |
350 // First screen on OOBE launch. | 373 // First screen on OOBE launch. |
351 if (document.body.classList.contains('oobe-display') && | 374 if (this.isOobeUI() && innerContainer.classList.contains('down')) { |
352 innerContainer.classList.contains('down')) { | |
353 innerContainer.classList.remove('down'); | 375 innerContainer.classList.remove('down'); |
354 innerContainer.addEventListener( | 376 innerContainer.addEventListener( |
355 'webkitTransitionEnd', function f(e) { | 377 'webkitTransitionEnd', function f(e) { |
356 innerContainer.removeEventListener('webkitTransitionEnd', f); | 378 innerContainer.removeEventListener('webkitTransitionEnd', f); |
357 $('progress-dots').classList.remove('down'); | 379 $('progress-dots').classList.remove('down'); |
358 chrome.send('loginVisible', ['oobe']); | 380 chrome.send('loginVisible', ['oobe']); |
359 // Refresh defaultControl. It could have changed. | 381 // Refresh defaultControl. It could have changed. |
360 var defaultControl = newStep.defaultControl; | 382 var defaultControl = newStep.defaultControl; |
361 if (defaultControl) | 383 if (defaultControl) |
362 defaultControl.focus(); | 384 defaultControl.focus(); |
363 }); | 385 }); |
364 ensureTransitionEndEvent(innerContainer, | 386 ensureTransitionEndEvent(innerContainer, |
365 MAX_SCREEN_TRANSITION_DURATION); | 387 MAX_SCREEN_TRANSITION_DURATION); |
366 } else { | 388 } else { |
367 if (defaultControl) | 389 if (defaultControl) |
368 defaultControl.focus(); | 390 defaultControl.focus(); |
| 391 chrome.send('loginVisible', ['oobe']); |
369 } | 392 } |
370 newHeader.classList.remove('right'); // Old OOBE. | |
371 } | 393 } |
372 this.currentStep_ = nextStepIndex; | 394 this.currentStep_ = nextStepIndex; |
373 $('oobe').className = nextStepId; | 395 $('oobe').className = nextStepId; |
374 | 396 |
375 $('step-logo').hidden = newStep.classList.contains('no-logo'); | 397 $('step-logo').hidden = newStep.classList.contains('no-logo'); |
376 | 398 |
377 chrome.send('updateCurrentScreen', [this.currentScreen.id]); | 399 chrome.send('updateCurrentScreen', [this.currentScreen.id]); |
378 }, | 400 }, |
379 | 401 |
380 /** | 402 /** |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 * @param {string} requisition The device requisition. | 579 * @param {string} requisition The device requisition. |
558 */ | 580 */ |
559 updateDeviceRequisition: function(requisition) { | 581 updateDeviceRequisition: function(requisition) { |
560 this.deviceRequisition_ = requisition; | 582 this.deviceRequisition_ = requisition; |
561 }, | 583 }, |
562 | 584 |
563 /** | 585 /** |
564 * Returns true if Oobe UI is shown. | 586 * Returns true if Oobe UI is shown. |
565 */ | 587 */ |
566 isOobeUI: function() { | 588 isOobeUI: function() { |
567 return !document.body.classList.contains('login-display'); | 589 return document.body.classList.contains('oobe-display'); |
568 }, | 590 }, |
569 | 591 |
570 /** | 592 /** |
571 * Returns true if the current UI type is the "Sign-in to add user" | |
572 * (another user session is already active). | |
573 */ | |
574 isSignInToAddScreen: function() { | |
575 return document.documentElement.getAttribute('screen') == | |
576 'user-adding'; | |
577 }, | |
578 | |
579 /** | |
580 * Returns true if the current UI type is the lock screen. | |
581 */ | |
582 isLockScreen: function() { | |
583 return document.documentElement.getAttribute('screen') == 'lock'; | |
584 }, | |
585 | |
586 /** | |
587 * Returns true if sign in UI should trigger wallpaper load on boot. | 593 * Returns true if sign in UI should trigger wallpaper load on boot. |
588 */ | 594 */ |
589 shouldLoadWallpaperOnBoot: function() { | 595 shouldLoadWallpaperOnBoot: function() { |
590 return loadTimeData.getString('bootIntoWallpaper') == 'on'; | 596 return loadTimeData.getString('bootIntoWallpaper') == 'on'; |
591 }, | 597 }, |
592 }; | 598 }; |
593 | 599 |
594 /** | 600 /** |
595 * Initializes display manager. | 601 * Initializes display manager. |
596 */ | 602 */ |
597 DisplayManager.initialize = function() { | 603 DisplayManager.initialize = function() { |
598 // Extracting screen type from URL. | 604 // Extracting display type from URL. |
599 var hash = window.location.hash; | 605 var path = window.location.pathname.substr(1); |
600 var screenType; | 606 var displayType = DISPLAY_TYPE.UNKNOWN; |
601 if (!hash) { | 607 Object.getOwnPropertyNames(DISPLAY_TYPE).forEach(function(type) { |
602 console.error('Screen type not found. Setting default value "login".'); | 608 if (DISPLAY_TYPE[type] == path) { |
603 screenType = 'login'; | 609 displayType = path; |
604 } else { | 610 } |
605 screenType = hash.substring(1); | 611 }); |
| 612 if (displayType == DISPLAY_TYPE.UNKNOWN) { |
| 613 console.error("Unknown display type '" + path + "'. Setting default."); |
| 614 displayType = DISPLAY_TYPE.LOGIN; |
606 } | 615 } |
607 document.documentElement.setAttribute('screen', screenType); | 616 Oobe.getInstance().displayType = displayType; |
| 617 document.documentElement.setAttribute('screen', displayType); |
608 | 618 |
609 var link = $('enterprise-info-hint-link'); | 619 var link = $('enterprise-info-hint-link'); |
610 link.addEventListener( | 620 link.addEventListener( |
611 'click', DisplayManager.handleEnterpriseHintLinkClick); | 621 'click', DisplayManager.handleEnterpriseHintLinkClick); |
612 }, | 622 }, |
613 | 623 |
614 /** | 624 /** |
615 * Returns offset (top, left) of the element. | 625 * Returns offset (top, left) of the element. |
616 * @param {!Element} element HTML element. | 626 * @param {!Element} element HTML element. |
617 * @return {!Object} The offset (top, left). | 627 * @return {!Object} The offset (top, left). |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 */ | 800 */ |
791 DisplayManager.refocusCurrentPod = function() { | 801 DisplayManager.refocusCurrentPod = function() { |
792 $('pod-row').refocusCurrentPod(); | 802 $('pod-row').refocusCurrentPod(); |
793 }; | 803 }; |
794 | 804 |
795 // Export | 805 // Export |
796 return { | 806 return { |
797 DisplayManager: DisplayManager | 807 DisplayManager: DisplayManager |
798 }; | 808 }; |
799 }); | 809 }); |
OLD | NEW |