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

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

Issue 21004005: Made small refactoring of OobeUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 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
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 * Groups of screens (screen IDs) that should have the same dimensions. 69 * Groups of screens (screen IDs) that should have the same dimensions.
61 * @type Array.<Array.<string>> 70 * @type Array.<Array.<string>>
62 * @const 71 * @const
63 */ 72 */
64 var SCREEN_GROUPS = [[SCREEN_OOBE_NETWORK, 73 var SCREEN_GROUPS = [[SCREEN_OOBE_NETWORK,
65 SCREEN_OOBE_EULA, 74 SCREEN_OOBE_EULA,
(...skipping 27 matching lines...) Expand all
93 */ 102 */
94 allowToggleVersion_: false, 103 allowToggleVersion_: false,
95 104
96 /** 105 /**
97 * Whether keyboard navigation flow is enforced. 106 * Whether keyboard navigation flow is enforced.
98 * @type {boolean} 107 * @type {boolean}
99 */ 108 */
100 forceKeyboardFlow_: false, 109 forceKeyboardFlow_: false,
101 110
102 /** 111 /**
112 * Type of UI.
113 * @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.
114 */
115 displayType_: DISPLAY_TYPE.UNKNOWN,
116
117 get displayType() {
118 return this.displayType_;
119 },
120
121 set displayType(displayType) {
122 this.displayType_ = displayType;
123 },
124
125 /**
103 * Gets current screen element. 126 * Gets current screen element.
104 * @type {HTMLElement} 127 * @type {HTMLElement}
105 */ 128 */
106 get currentScreen() { 129 get currentScreen() {
107 return $(this.screens_[this.currentStep_]); 130 return $(this.screens_[this.currentStep_]);
108 }, 131 },
109 132
110 /** 133 /**
111 * Hides/shows header (Shutdown/Add User/Cancel buttons). 134 * Hides/shows header (Shutdown/Add User/Cancel buttons).
112 * @param {boolean} hidden Whether header is hidden. 135 * @param {boolean} hidden Whether header is hidden.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (defaultControl) 333 if (defaultControl)
311 defaultControl.focus(); 334 defaultControl.focus();
312 }); 335 });
313 } else { 336 } else {
314 oldStep.classList.add('hidden'); 337 oldStep.classList.add('hidden');
315 if (defaultControl) 338 if (defaultControl)
316 defaultControl.focus(); 339 defaultControl.focus();
317 } 340 }
318 } else { 341 } else {
319 // First screen on OOBE launch. 342 // First screen on OOBE launch.
320 if (document.body.classList.contains('oobe-display') && 343 if (this.isOobeUI() && innerContainer.classList.contains('down')) {
321 innerContainer.classList.contains('down')) {
322 innerContainer.classList.remove('down'); 344 innerContainer.classList.remove('down');
323 innerContainer.addEventListener( 345 innerContainer.addEventListener(
324 'webkitTransitionEnd', function f(e) { 346 'webkitTransitionEnd', function f(e) {
325 innerContainer.removeEventListener('webkitTransitionEnd', f); 347 innerContainer.removeEventListener('webkitTransitionEnd', f);
326 $('progress-dots').classList.remove('down'); 348 $('progress-dots').classList.remove('down');
327 chrome.send('loginVisible', ['oobe']); 349 chrome.send('loginVisible', ['oobe']);
328 // Refresh defaultControl. It could have changed. 350 // Refresh defaultControl. It could have changed.
329 var defaultControl = newStep.defaultControl; 351 var defaultControl = newStep.defaultControl;
330 if (defaultControl) 352 if (defaultControl)
331 defaultControl.focus(); 353 defaultControl.focus();
332 }); 354 });
333 } else { 355 } else {
334 if (defaultControl) 356 if (defaultControl)
335 defaultControl.focus(); 357 defaultControl.focus();
336 } 358 }
337 newHeader.classList.remove('right'); // Old OOBE.
338 } 359 }
339 this.currentStep_ = nextStepIndex; 360 this.currentStep_ = nextStepIndex;
340 $('oobe').className = nextStepId; 361 $('oobe').className = nextStepId;
341 362
342 $('step-logo').hidden = newStep.classList.contains('no-logo'); 363 $('step-logo').hidden = newStep.classList.contains('no-logo');
343 364
344 chrome.send('updateCurrentScreen', [this.currentScreen.id]); 365 chrome.send('updateCurrentScreen', [this.currentScreen.id]);
345 }, 366 },
346 367
347 /** 368 /**
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 * @param {string} requisition The device requisition. 545 * @param {string} requisition The device requisition.
525 */ 546 */
526 updateDeviceRequisition: function(requisition) { 547 updateDeviceRequisition: function(requisition) {
527 this.deviceRequisition_ = requisition; 548 this.deviceRequisition_ = requisition;
528 }, 549 },
529 550
530 /** 551 /**
531 * Returns true if Oobe UI is shown. 552 * Returns true if Oobe UI is shown.
532 */ 553 */
533 isOobeUI: function() { 554 isOobeUI: function() {
534 return !document.body.classList.contains('login-display'); 555 return document.body.classList.contains('oobe-display');
535 }, 556 },
536 557
537 /** 558 /**
538 * Returns true if the current UI type is the "Sign-in to add user"
539 * (another user session is already active).
540 */
541 isSignInToAddScreen: function() {
542 return document.documentElement.getAttribute('screen') ==
543 'user-adding';
544 },
545
546 /**
547 * Returns true if the current UI type is the lock screen.
548 */
549 isLockScreen: function() {
550 return document.documentElement.getAttribute('screen') == 'lock';
551 },
552
553 /**
554 * Returns true if sign in UI should trigger wallpaper load on boot. 559 * Returns true if sign in UI should trigger wallpaper load on boot.
555 */ 560 */
556 shouldLoadWallpaperOnBoot: function() { 561 shouldLoadWallpaperOnBoot: function() {
557 return loadTimeData.getString('bootIntoWallpaper') == 'on'; 562 return loadTimeData.getString('bootIntoWallpaper') == 'on';
558 }, 563 },
559 }; 564 };
560 565
561 /** 566 /**
562 * Initializes display manager. 567 * Initializes display manager.
563 */ 568 */
564 DisplayManager.initialize = function() { 569 DisplayManager.initialize = function() {
565 // Extracting screen type from URL. 570 // Extracting display type from URL.
566 var hash = window.location.hash; 571 var path = window.location.pathname.substr(1);
567 var screenType; 572 var displayType = DISPLAY_TYPE.UNKNOWN;
568 if (!hash) { 573 Object.getOwnPropertyNames(DISPLAY_TYPE).forEach(function(type) {
569 console.error('Screen type not found. Setting default value "login".'); 574 if (DISPLAY_TYPE[type] == path) {
570 screenType = 'login'; 575 displayType = path;
571 } else { 576 }
572 screenType = hash.substring(1); 577 });
578 if (displayType == DISPLAY_TYPE.UNKNOWN) {
579 console.error("Unknown display type '" + path + "'. Setting default.");
580 displayType = DISPLAY_TYPE.LOGIN;
573 } 581 }
574 document.documentElement.setAttribute('screen', screenType); 582 Oobe.getInstance().displayType = displayType;
583 document.documentElement.setAttribute('screen', displayType);
575 584
576 var link = $('enterprise-info-hint-link'); 585 var link = $('enterprise-info-hint-link');
577 link.addEventListener( 586 link.addEventListener(
578 'click', DisplayManager.handleEnterpriseHintLinkClick); 587 'click', DisplayManager.handleEnterpriseHintLinkClick);
579 }, 588 },
580 589
581 /** 590 /**
582 * Returns offset (top, left) of the element. 591 * Returns offset (top, left) of the element.
583 * @param {!Element} element HTML element. 592 * @param {!Element} element HTML element.
584 * @return {!Object} The offset (top, left). 593 * @return {!Object} The offset (top, left).
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 */ 766 */
758 DisplayManager.refocusCurrentPod = function() { 767 DisplayManager.refocusCurrentPod = function() {
759 $('pod-row').refocusCurrentPod(); 768 $('pod-row').refocusCurrentPod();
760 }; 769 };
761 770
762 // Export 771 // Export
763 return { 772 return {
764 DisplayManager: DisplayManager 773 DisplayManager: DisplayManager
765 }; 774 };
766 }); 775 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698