Chromium Code Reviews| Index: chrome/browser/resources/chromeos/login/display_manager.js |
| diff --git a/chrome/browser/resources/chromeos/login/display_manager.js b/chrome/browser/resources/chromeos/login/display_manager.js |
| index 9ddeee2fcf05319249deee15123ddfa920493dce..2f81842699197d651bbb7bfbb6efe5299b5799b2 100644 |
| --- a/chrome/browser/resources/chromeos/login/display_manager.js |
| +++ b/chrome/browser/resources/chromeos/login/display_manager.js |
| @@ -53,6 +53,15 @@ |
| MANAGED_USER_CREATION_FLOW: 'ui-state-locally-managed' |
| }; |
| +/* Possible types of UI. */ |
| +/** @const */ var DISPLAY_TYPE = { |
| + UNKNOWN: 'unknown', |
| + OOBE: 'oobe', |
| + LOGIN: 'login', |
| + LOCK: 'lock', |
| + USER_ADDING: 'user-adding' |
| +}; |
| + |
| cr.define('cr.ui.login', function() { |
| var Bubble = cr.ui.Bubble; |
| @@ -100,6 +109,20 @@ cr.define('cr.ui.login', function() { |
| forceKeyboardFlow_: false, |
| /** |
| + * Type of UI. |
| + * @type {boolean} |
|
ygorshenin1
2013/07/30 15:06:34
nit: maybe string instead of boolean?
dzhioev (left Google)
2013/07/30 16:18:55
Done.
|
| + */ |
| + displayType_: DISPLAY_TYPE.UNKNOWN, |
| + |
| + get displayType() { |
| + return this.displayType_; |
| + }, |
| + |
| + set displayType(displayType) { |
| + this.displayType_ = displayType; |
| + }, |
| + |
| + /** |
| * Gets current screen element. |
| * @type {HTMLElement} |
| */ |
| @@ -317,8 +340,7 @@ cr.define('cr.ui.login', function() { |
| } |
| } else { |
| // First screen on OOBE launch. |
| - if (document.body.classList.contains('oobe-display') && |
| - innerContainer.classList.contains('down')) { |
| + if (this.isOobeUI() && innerContainer.classList.contains('down')) { |
| innerContainer.classList.remove('down'); |
| innerContainer.addEventListener( |
| 'webkitTransitionEnd', function f(e) { |
| @@ -334,7 +356,6 @@ cr.define('cr.ui.login', function() { |
| if (defaultControl) |
| defaultControl.focus(); |
| } |
| - newHeader.classList.remove('right'); // Old OOBE. |
| } |
| this.currentStep_ = nextStepIndex; |
| $('oobe').className = nextStepId; |
| @@ -531,23 +552,7 @@ cr.define('cr.ui.login', function() { |
| * Returns true if Oobe UI is shown. |
| */ |
| isOobeUI: function() { |
| - return !document.body.classList.contains('login-display'); |
| - }, |
| - |
| - /** |
| - * Returns true if the current UI type is the "Sign-in to add user" |
| - * (another user session is already active). |
| - */ |
| - isSignInToAddScreen: function() { |
| - return document.documentElement.getAttribute('screen') == |
| - 'user-adding'; |
| - }, |
| - |
| - /** |
| - * Returns true if the current UI type is the lock screen. |
| - */ |
| - isLockScreen: function() { |
| - return document.documentElement.getAttribute('screen') == 'lock'; |
| + return document.body.classList.contains('oobe-display'); |
| }, |
| /** |
| @@ -562,16 +567,20 @@ cr.define('cr.ui.login', function() { |
| * Initializes display manager. |
| */ |
| DisplayManager.initialize = function() { |
| - // Extracting screen type from URL. |
| - var hash = window.location.hash; |
| - var screenType; |
| - if (!hash) { |
| - console.error('Screen type not found. Setting default value "login".'); |
| - screenType = 'login'; |
| - } else { |
| - screenType = hash.substring(1); |
| + // Extracting display type from URL. |
| + var path = window.location.pathname.substr(1); |
| + var displayType = DISPLAY_TYPE.UNKNOWN; |
| + Object.getOwnPropertyNames(DISPLAY_TYPE).forEach(function(type) { |
| + if (DISPLAY_TYPE[type] == path) { |
| + displayType = path; |
| + } |
| + }); |
| + if (displayType == DISPLAY_TYPE.UNKNOWN) { |
| + console.error("Unknown display type '" + path + "'. Setting default."); |
| + displayType = DISPLAY_TYPE.LOGIN; |
| } |
| - document.documentElement.setAttribute('screen', screenType); |
| + Oobe.getInstance().displayType = displayType; |
| + document.documentElement.setAttribute('screen', displayType); |
| var link = $('enterprise-info-hint-link'); |
| link.addEventListener( |