| 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 User pod row implementation. | 6 * @fileoverview User pod row implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('login', function() { | 9 cr.define('login', function() { |
| 10 /** | 10 /** |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 var MAX_NUMBER_OF_COLUMNS = 6; | 30 var MAX_NUMBER_OF_COLUMNS = 6; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Maximal number of rows if sign-in banner is displayed alonside. | 33 * Maximal number of rows if sign-in banner is displayed alonside. |
| 34 * @type {number} | 34 * @type {number} |
| 35 * @const | 35 * @const |
| 36 */ | 36 */ |
| 37 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; | 37 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Variables used for pod placement processing. | 40 * Variables used for pod placement processing. Width and height should be |
| 41 * Width and height should be synced with computed CSS sizes of pods. | 41 * synced with computed CSS sizes of pods. |
| 42 */ | 42 */ |
| 43 var POD_WIDTH = 180; | 43 var POD_WIDTH = 180; |
| 44 var POD_HEIGHT = 217; | 44 var POD_HEIGHT = 217; |
| 45 var POD_ROW_PADDING = 10; | 45 var POD_ROW_PADDING = 10; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Whether to preselect the first pod automatically on login screen. | 48 * Whether to preselect the first pod automatically on login screen. |
| 49 * @type {boolean} | 49 * @type {boolean} |
| 50 * @const | 50 * @const |
| 51 */ | 51 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 75 POD_INPUT: 1, // Password input fields (and whole pods themselves). | 75 POD_INPUT: 1, // Password input fields (and whole pods themselves). |
| 76 HEADER_BAR: 2, // Buttons on the header bar (Shutdown, Add User). | 76 HEADER_BAR: 2, // Buttons on the header bar (Shutdown, Add User). |
| 77 ACTION_BOX: 3, // Action box buttons. | 77 ACTION_BOX: 3, // Action box buttons. |
| 78 PAD_MENU_ITEM: 4 // User pad menu items (Remove this user). | 78 PAD_MENU_ITEM: 4 // User pad menu items (Remove this user). |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // Focus and tab order are organized as follows: | 81 // Focus and tab order are organized as follows: |
| 82 // | 82 // |
| 83 // (1) all user pods have tab index 1 so they are traversed first; | 83 // (1) all user pods have tab index 1 so they are traversed first; |
| 84 // (2) when a user pod is activated, its tab index is set to -1 and its | 84 // (2) when a user pod is activated, its tab index is set to -1 and its |
| 85 // main input field gets focus and tab index 1; | 85 // main input field gets focus and tab index 1; |
| 86 // (3) buttons on the header bar have tab index 2 so they follow user pods; | 86 // (3) buttons on the header bar have tab index 2 so they follow user pods; |
| 87 // (4) Action box buttons have tab index 3 and follow header bar buttons; | 87 // (4) Action box buttons have tab index 3 and follow header bar buttons; |
| 88 // (5) lastly, focus jumps to the Status Area and back to user pods. | 88 // (5) lastly, focus jumps to the Status Area and back to user pods. |
| 89 // | 89 // |
| 90 // 'Focus' event is handled by a capture handler for the whole document | 90 // 'Focus' event is handled by a capture handler for the whole document |
| 91 // and in some cases 'mousedown' event handlers are used instead of 'click' | 91 // and in some cases 'mousedown' event handlers are used instead of 'click' |
| 92 // handlers where it's necessary to prevent 'focus' event from being fired. | 92 // handlers where it's necessary to prevent 'focus' event from being fired. |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Helper function to remove a class from given element. | 95 * Helper function to remove a class from given element. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 /** | 252 /** |
| 253 * Gets Caps Lock hint image. | 253 * Gets Caps Lock hint image. |
| 254 * @type {!HTMLImageElement} | 254 * @type {!HTMLImageElement} |
| 255 */ | 255 */ |
| 256 get capslockHintElement() { | 256 get capslockHintElement() { |
| 257 return this.querySelector('.capslock-hint'); | 257 return this.querySelector('.capslock-hint'); |
| 258 }, | 258 }, |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * Gets user signin button. | 261 * Gets user sign in button. |
| 262 * @type {!HTMLInputElement} | 262 * @type {!HTMLButtonElement} |
| 263 */ | 263 */ |
| 264 get signinButtonElement() { | 264 get signinButtonElement() { |
| 265 return this.querySelector('.signin-button'); | 265 return this.querySelector('.signin-button'); |
| 266 }, | 266 }, |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * Gets launch app button. |
| 270 * @type {!HTMLButtonElement} |
| 271 */ |
| 272 get launchAppButtonElement() { |
| 273 return this.querySelector('.launch-app-button'); |
| 274 }, |
| 275 |
| 276 /** |
| 269 * Gets action box area. | 277 * Gets action box area. |
| 270 * @type {!HTMLInputElement} | 278 * @type {!HTMLInputElement} |
| 271 */ | 279 */ |
| 272 get actionBoxAreaElement() { | 280 get actionBoxAreaElement() { |
| 273 return this.querySelector('.action-box-area'); | 281 return this.querySelector('.action-box-area'); |
| 274 }, | 282 }, |
| 275 | 283 |
| 276 /** | 284 /** |
| 277 * Gets user type icon area. | 285 * Gets user type icon area. |
| 278 * @type {!HTMLDivElement} | 286 * @type {!HTMLDivElement} |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 364 |
| 357 /** | 365 /** |
| 358 * Gets the locked user indicator box. | 366 * Gets the locked user indicator box. |
| 359 * @type {!HTMLInputElement} | 367 * @type {!HTMLInputElement} |
| 360 */ | 368 */ |
| 361 get lockedIndicatorElement() { | 369 get lockedIndicatorElement() { |
| 362 return this.querySelector('.locked-indicator'); | 370 return this.querySelector('.locked-indicator'); |
| 363 }, | 371 }, |
| 364 | 372 |
| 365 /** | 373 /** |
| 366 * Gets the custom button. This button is normally hidden, but can be | 374 * Gets the custom button. This button is normally hidden, but can be shown |
| 367 * shown using the chrome.screenlockPrivate API. | 375 * using the chrome.screenlockPrivate API. |
| 368 * @type {!HTMLInputElement} | 376 * @type {!HTMLInputElement} |
| 369 */ | 377 */ |
| 370 get customButton() { | 378 get customButton() { |
| 371 return this.querySelector('.custom-button'); | 379 return this.querySelector('.custom-button'); |
| 372 }, | 380 }, |
| 373 | 381 |
| 374 /** | 382 /** |
| 375 * Updates the user pod element. | 383 * Updates the user pod element. |
| 376 */ | 384 */ |
| 377 update: function() { | 385 update: function() { |
| 378 this.imageElement.src = 'chrome://userimage/' + this.user.username + | 386 this.imageElement.src = 'chrome://userimage/' + this.user.username + |
| 379 '?id=' + UserPod.userImageSalt_[this.user.username]; | 387 '?id=' + UserPod.userImageSalt_[this.user.username]; |
| 380 | 388 |
| 381 this.nameElement.textContent = this.user_.displayName; | 389 this.nameElement.textContent = this.user_.displayName; |
| 382 this.signedInIndicatorElement.hidden = !this.user_.signedIn; | 390 this.signedInIndicatorElement.hidden = !this.user_.signedIn; |
| 383 | 391 |
| 384 var forceOnlineSignin = this.forceOnlineSignin; | 392 var forceOnlineSignin = this.forceOnlineSignin; |
| 385 this.passwordElement.hidden = forceOnlineSignin; | 393 this.passwordElement.hidden = forceOnlineSignin; |
| 386 this.signinButtonElement.hidden = !forceOnlineSignin; | 394 this.signinButtonElement.hidden = !forceOnlineSignin; |
| 387 | 395 |
| 388 this.updateActionBoxArea(); | 396 this.updateActionBoxArea(); |
| 389 | 397 |
| 390 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 398 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
| 391 'passwordFieldAccessibleName', this.user_.emailAddress)); | 399 'passwordFieldAccessibleName', this.user_.emailAddress)); |
| 392 | 400 |
| 393 this.updateUserTypeIcon(); | 401 this.customizeUserPodPerUserType(); |
| 394 }, | 402 }, |
| 395 | 403 |
| 396 updateActionBoxArea: function() { | 404 updateActionBoxArea: function() { |
| 397 this.actionBoxAreaElement.hidden = this.user_.publicAccount; | 405 if (this.user_.publicAccount || this.user_.isApp) { |
| 406 this.actionBoxAreaElement.hidden = true; |
| 407 return; |
| 408 } |
| 409 |
| 410 this.actionBoxAreaElement.hidden = false; |
| 398 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; | 411 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; |
| 399 | 412 |
| 400 this.actionBoxAreaElement.setAttribute( | 413 this.actionBoxAreaElement.setAttribute( |
| 401 'aria-label', loadTimeData.getStringF( | 414 'aria-label', loadTimeData.getStringF( |
| 402 'podMenuButtonAccessibleName', this.user_.emailAddress)); | 415 'podMenuButtonAccessibleName', this.user_.emailAddress)); |
| 403 this.actionBoxMenuRemoveElement.setAttribute( | 416 this.actionBoxMenuRemoveElement.setAttribute( |
| 404 'aria-label', loadTimeData.getString( | 417 'aria-label', loadTimeData.getString( |
| 405 'podMenuRemoveItemAccessibleName')); | 418 'podMenuRemoveItemAccessibleName')); |
| 406 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? | 419 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? |
| 407 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : | 420 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : |
| 408 this.user_.displayName; | 421 this.user_.displayName; |
| 409 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; | 422 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; |
| 410 this.actionBoxMenuTitleEmailElement.hidden = | 423 this.actionBoxMenuTitleEmailElement.hidden = |
| 411 this.user_.locallyManagedUser; | 424 this.user_.locallyManagedUser; |
| 412 | 425 |
| 413 this.actionBoxMenuCommandElement.textContent = | 426 this.actionBoxMenuCommandElement.textContent = |
| 414 loadTimeData.getString('removeUser'); | 427 loadTimeData.getString('removeUser'); |
| 415 }, | 428 }, |
| 416 | 429 |
| 417 updateUserTypeIcon: function() { | 430 customizeUserPodPerUserType: function() { |
| 418 var isMultiProfilesUI = | 431 var isMultiProfilesUI = |
| 419 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | 432 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
| 420 | 433 |
| 421 if (this.user_.locallyManagedUser) { | 434 if (this.user_.locallyManagedUser) { |
| 422 this.userTypeIconAreaElement.classList.add('supervised'); | 435 this.setUserPodIconType('supervised'); |
| 423 this.userTypeIconAreaElement.hidden = false; | |
| 424 } else if (isMultiProfilesUI && !this.user_.isMultiProfilesAllowed) { | 436 } else if (isMultiProfilesUI && !this.user_.isMultiProfilesAllowed) { |
| 425 // Mark user pod as not focusable. | 437 // Mark user pod as not focusable which in addition to the grayed out |
| 438 // filter makes it look in disabled state. |
| 426 this.classList.add('not-focusable'); | 439 this.classList.add('not-focusable'); |
| 427 | 440 this.setUserPodIconType('policy'); |
| 428 this.userTypeIconAreaElement.classList.add('policy'); | |
| 429 this.userTypeIconAreaElement.hidden = false; | |
| 430 | 441 |
| 431 this.querySelector('.mp-policy-title').hidden = false; | 442 this.querySelector('.mp-policy-title').hidden = false; |
| 432 if (this.user_.multiProfilesPolicy == 'primary-only') | 443 if (this.user.multiProfilesPolicy == 'primary-only') |
| 433 this.querySelector('.mp-policy-primary-only-msg').hidden = false; | 444 this.querySelector('.mp-policy-primary-only-msg').hidden = false; |
| 434 else | 445 else |
| 435 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; | 446 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; |
| 447 } else if (this.user_.isApp) { |
| 448 this.setUserPodIconType('app'); |
| 436 } | 449 } |
| 437 }, | 450 }, |
| 438 | 451 |
| 452 setUserPodIconType: function(userTypeClass) { |
| 453 this.userTypeIconAreaElement.classList.add(userTypeClass); |
| 454 this.userTypeIconAreaElement.hidden = false; |
| 455 }, |
| 456 |
| 439 /** | 457 /** |
| 440 * The user that this pod represents. | 458 * The user that this pod represents. |
| 441 * @type {!Object} | 459 * @type {!Object} |
| 442 */ | 460 */ |
| 443 user_: undefined, | 461 user_: undefined, |
| 444 get user() { | 462 get user() { |
| 445 return this.user_; | 463 return this.user_; |
| 446 }, | 464 }, |
| 447 set user(userDict) { | 465 set user(userDict) { |
| 448 this.user_ = userDict; | 466 this.user_ = userDict; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 this.passwordElement.hidden = forceOnlineSignin; | 549 this.passwordElement.hidden = forceOnlineSignin; |
| 532 | 550 |
| 533 // Move tabIndex from the whole pod to the main input. | 551 // Move tabIndex from the whole pod to the main input. |
| 534 this.tabIndex = -1; | 552 this.tabIndex = -1; |
| 535 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; | 553 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; |
| 536 this.mainInput.focus(); | 554 this.mainInput.focus(); |
| 537 }, | 555 }, |
| 538 | 556 |
| 539 /** | 557 /** |
| 540 * Activates the pod. | 558 * Activates the pod. |
| 559 * @param {Event} e Event object. |
| 541 * @return {boolean} True if activated successfully. | 560 * @return {boolean} True if activated successfully. |
| 542 */ | 561 */ |
| 543 activate: function() { | 562 activate: function(e) { |
| 544 if (!this.signinButtonElement.hidden) { | 563 if (this.forceOnlineSignin) { |
| 545 this.showSigninUI(); | 564 this.showSigninUI(); |
| 546 } else if (!this.passwordElement.value) { | 565 } else if (!this.passwordElement.value) { |
| 547 return false; | 566 return false; |
| 548 } else { | 567 } else { |
| 549 Oobe.disableSigninUI(); | 568 Oobe.disableSigninUI(); |
| 550 chrome.send('authenticateUser', | 569 chrome.send('authenticateUser', |
| 551 [this.user.username, this.passwordElement.value]); | 570 [this.user.username, this.passwordElement.value]); |
| 552 } | 571 } |
| 553 | 572 |
| 554 return true; | 573 return true; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 }, | 730 }, |
| 712 | 731 |
| 713 /** | 732 /** |
| 714 * Handles click event on a user pod. | 733 * Handles click event on a user pod. |
| 715 * @param {Event} e Click event. | 734 * @param {Event} e Click event. |
| 716 */ | 735 */ |
| 717 handleClickOnPod_: function(e) { | 736 handleClickOnPod_: function(e) { |
| 718 if (this.parentNode.disabled) | 737 if (this.parentNode.disabled) |
| 719 return; | 738 return; |
| 720 | 739 |
| 721 if (!this.signinButtonElement.hidden && !this.isActionBoxMenuActive) { | 740 if (this.forceOnlineSignin && !this.isActionBoxMenuActive) { |
| 722 this.showSigninUI(); | 741 this.showSigninUI(); |
| 723 // Prevent default so that we don't trigger 'focus' event. | 742 // Prevent default so that we don't trigger 'focus' event. |
| 724 e.preventDefault(); | 743 e.preventDefault(); |
| 725 } | 744 } |
| 726 }, | 745 }, |
| 727 | 746 |
| 728 /** | 747 /** |
| 729 * Called when the custom button is clicked. | 748 * Called when the custom button is clicked. |
| 730 */ | 749 */ |
| 731 handleCustomButtonClick_: function() { | 750 handleCustomButtonClick_: function() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 826 |
| 808 /** @override */ | 827 /** @override */ |
| 809 decorate: function() { | 828 decorate: function() { |
| 810 UserPod.prototype.decorate.call(this); | 829 UserPod.prototype.decorate.call(this); |
| 811 | 830 |
| 812 this.classList.remove('need-password'); | 831 this.classList.remove('need-password'); |
| 813 this.classList.add('public-account'); | 832 this.classList.add('public-account'); |
| 814 | 833 |
| 815 this.nameElement.addEventListener('keydown', (function(e) { | 834 this.nameElement.addEventListener('keydown', (function(e) { |
| 816 if (e.keyIdentifier == 'Enter') { | 835 if (e.keyIdentifier == 'Enter') { |
| 817 this.parentNode.activatedPod = this; | 836 this.parentNode.setActivatedPod(this, e); |
| 818 // Stop this keydown event from bubbling up to PodRow handler. | 837 // Stop this keydown event from bubbling up to PodRow handler. |
| 819 e.stopPropagation(); | 838 e.stopPropagation(); |
| 820 // Prevent default so that we don't trigger a 'click' event on the | 839 // Prevent default so that we don't trigger a 'click' event on the |
| 821 // newly focused "Enter" button. | 840 // newly focused "Enter" button. |
| 822 e.preventDefault(); | 841 e.preventDefault(); |
| 823 } | 842 } |
| 824 }).bind(this)); | 843 }).bind(this)); |
| 825 | 844 |
| 826 var learnMore = this.querySelector('.learn-more'); | 845 var learnMore = this.querySelector('.learn-more'); |
| 827 learnMore.addEventListener('mousedown', stopEventPropagation); | 846 learnMore.addEventListener('mousedown', stopEventPropagation); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 879 |
| 861 /** @override */ | 880 /** @override */ |
| 862 reset: function(takeFocus) { | 881 reset: function(takeFocus) { |
| 863 if (!takeFocus) | 882 if (!takeFocus) |
| 864 this.expanded = false; | 883 this.expanded = false; |
| 865 this.enterButtonElement.disabled = false; | 884 this.enterButtonElement.disabled = false; |
| 866 UserPod.prototype.reset.call(this, takeFocus); | 885 UserPod.prototype.reset.call(this, takeFocus); |
| 867 }, | 886 }, |
| 868 | 887 |
| 869 /** @override */ | 888 /** @override */ |
| 870 activate: function() { | 889 activate: function(e) { |
| 871 this.expanded = true; | 890 this.expanded = true; |
| 872 this.focusInput(); | 891 this.focusInput(); |
| 873 return true; | 892 return true; |
| 874 }, | 893 }, |
| 875 | 894 |
| 876 /** @override */ | 895 /** @override */ |
| 877 handleClickOnPod_: function(e) { | 896 handleClickOnPod_: function(e) { |
| 878 if (this.parentNode.disabled) | 897 if (this.parentNode.disabled) |
| 879 return; | 898 return; |
| 880 | 899 |
| 881 this.parentNode.focusPod(this); | 900 this.parentNode.focusPod(this); |
| 882 this.parentNode.activatedPod = this; | 901 this.parentNode.setActivatedPod(this, e); |
| 883 // Prevent default so that we don't trigger 'focus' event. | 902 // Prevent default so that we don't trigger 'focus' event. |
| 884 e.preventDefault(); | 903 e.preventDefault(); |
| 885 }, | 904 }, |
| 886 | 905 |
| 887 /** | 906 /** |
| 888 * Handle mouse and keyboard events for the learn more button. | 907 * Handle mouse and keyboard events for the learn more button. Triggering |
| 889 * Triggering the button causes information about public sessions to be | 908 * the button causes information about public sessions to be shown. |
| 890 * shown. | |
| 891 * @param {Event} event Mouse or keyboard event. | 909 * @param {Event} event Mouse or keyboard event. |
| 892 */ | 910 */ |
| 893 handleLearnMoreEvent: function(event) { | 911 handleLearnMoreEvent: function(event) { |
| 894 switch (event.type) { | 912 switch (event.type) { |
| 895 // Show informaton on left click. Let any other clicks propagate. | 913 // Show informaton on left click. Let any other clicks propagate. |
| 896 case 'click': | 914 case 'click': |
| 897 if (event.button != 0) | 915 if (event.button != 0) |
| 898 return; | 916 return; |
| 899 break; | 917 break; |
| 900 // Show informaton when <Return> or <Space> is pressed. Let any other | 918 // Show informaton when <Return> or <Space> is pressed. Let any other |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 | 996 |
| 979 /** @override */ | 997 /** @override */ |
| 980 reset: function(takeFocus) { | 998 reset: function(takeFocus) { |
| 981 // Always display the user's name for unfocused pods. | 999 // Always display the user's name for unfocused pods. |
| 982 if (!takeFocus) | 1000 if (!takeFocus) |
| 983 this.nameElement.hidden = false; | 1001 this.nameElement.hidden = false; |
| 984 UserPod.prototype.reset.call(this, takeFocus); | 1002 UserPod.prototype.reset.call(this, takeFocus); |
| 985 }, | 1003 }, |
| 986 | 1004 |
| 987 /** @override */ | 1005 /** @override */ |
| 988 activate: function() { | 1006 activate: function(e) { |
| 989 if (this.passwordElement.hidden) { | 1007 if (this.passwordElement.hidden) { |
| 990 Oobe.launchUser(this.user.emailAddress, this.user.displayName); | 1008 Oobe.launchUser(this.user.emailAddress, this.user.displayName); |
| 991 } else if (!this.passwordElement.value) { | 1009 } else if (!this.passwordElement.value) { |
| 992 return false; | 1010 return false; |
| 993 } else { | 1011 } else { |
| 994 chrome.send('authenticatedLaunchUser', | 1012 chrome.send('authenticatedLaunchUser', |
| 995 [this.user.emailAddress, | 1013 [this.user.emailAddress, |
| 996 this.user.displayName, | 1014 this.user.displayName, |
| 997 this.passwordElement.value]); | 1015 this.passwordElement.value]); |
| 998 } | 1016 } |
| 999 this.passwordElement.value = ''; | 1017 this.passwordElement.value = ''; |
| 1000 return true; | 1018 return true; |
| 1001 }, | 1019 }, |
| 1002 | 1020 |
| 1003 /** @override */ | 1021 /** @override */ |
| 1004 handleClickOnPod_: function(e) { | 1022 handleClickOnPod_: function(e) { |
| 1005 if (this.parentNode.disabled) | 1023 if (this.parentNode.disabled) |
| 1006 return; | 1024 return; |
| 1007 | 1025 |
| 1008 Oobe.clearErrors(); | 1026 Oobe.clearErrors(); |
| 1009 this.parentNode.lastFocusedPod_ = this; | 1027 this.parentNode.lastFocusedPod_ = this; |
| 1010 | 1028 |
| 1011 // If this is an unlocked pod, then open a browser window. Otherwise | 1029 // If this is an unlocked pod, then open a browser window. Otherwise |
| 1012 // just activate the pod and show the password field. | 1030 // just activate the pod and show the password field. |
| 1013 if (!this.user.needsSignin && !this.isActionBoxMenuActive) | 1031 if (!this.user.needsSignin && !this.isActionBoxMenuActive) |
| 1014 this.activate(); | 1032 this.activate(e); |
| 1015 }, | 1033 }, |
| 1016 | 1034 |
| 1017 /** @override */ | 1035 /** @override */ |
| 1018 handleRemoveUserConfirmationClick_: function(e) { | 1036 handleRemoveUserConfirmationClick_: function(e) { |
| 1019 chrome.send('removeUser', [this.user.profilePath]); | 1037 chrome.send('removeUser', [this.user.profilePath]); |
| 1020 }, | 1038 }, |
| 1021 }; | 1039 }; |
| 1022 | 1040 |
| 1023 /** | 1041 /** |
| 1042 * Creates a user pod that represents kiosk app. |
| 1043 * @constructor |
| 1044 * @extends {UserPod} |
| 1045 */ |
| 1046 var KioskAppPod = cr.ui.define(function() { |
| 1047 var node = UserPod(); |
| 1048 return node; |
| 1049 }); |
| 1050 |
| 1051 KioskAppPod.prototype = { |
| 1052 __proto__: UserPod.prototype, |
| 1053 |
| 1054 /** @override */ |
| 1055 decorate: function() { |
| 1056 UserPod.prototype.decorate.call(this); |
| 1057 this.launchAppButtonElement.addEventListener('click', |
| 1058 this.activate.bind(this)); |
| 1059 }, |
| 1060 |
| 1061 /** @override */ |
| 1062 update: function() { |
| 1063 this.imageElement.src = this.user.iconUrl; |
| 1064 this.imageElement.alt = this.user.label; |
| 1065 this.passwordElement.hidden = true; |
| 1066 this.signinButtonElement.hidden = true; |
| 1067 this.launchAppButtonElement.hidden = false; |
| 1068 this.signedInIndicatorElement.hidden = true; |
| 1069 this.nameElement.textContent = this.user.label; |
| 1070 |
| 1071 UserPod.prototype.updateActionBoxArea.call(this); |
| 1072 UserPod.prototype.customizeUserPodPerUserType.call(this); |
| 1073 }, |
| 1074 |
| 1075 /** @override */ |
| 1076 get mainInput() { |
| 1077 return this.launchAppButtonElement; |
| 1078 }, |
| 1079 |
| 1080 /** @override */ |
| 1081 focusInput: function() { |
| 1082 this.signinButtonElement.hidden = true; |
| 1083 this.launchAppButtonElement.hidden = false; |
| 1084 this.passwordElement.hidden = true; |
| 1085 |
| 1086 // Move tabIndex from the whole pod to the main input. |
| 1087 this.tabIndex = -1; |
| 1088 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; |
| 1089 this.mainInput.focus(); |
| 1090 }, |
| 1091 |
| 1092 /** @override */ |
| 1093 get forceOnlineSignin() { |
| 1094 return false; |
| 1095 }, |
| 1096 |
| 1097 /** @override */ |
| 1098 activate: function(e) { |
| 1099 var diagnosticMode = e && e.ctrlKey; |
| 1100 this.launchApp_(this.user, diagnosticMode); |
| 1101 return true; |
| 1102 }, |
| 1103 |
| 1104 /** @override */ |
| 1105 handleClickOnPod_: function(e) { |
| 1106 if (this.parentNode.disabled) |
| 1107 return; |
| 1108 |
| 1109 Oobe.clearErrors(); |
| 1110 this.parentNode.lastFocusedPod_ = this; |
| 1111 this.activate(e); |
| 1112 }, |
| 1113 |
| 1114 /** |
| 1115 * Launch the app. If |diagnosticMode| is true, ask user to confirm. |
| 1116 * @param {Object} app App data. |
| 1117 * @param {boolean} diagnosticMode Whether to run the app in diagnostic |
| 1118 * mode. |
| 1119 */ |
| 1120 launchApp_: function(app, diagnosticMode) { |
| 1121 if (!diagnosticMode) { |
| 1122 chrome.send('launchKioskApp', [app.id, false]); |
| 1123 return; |
| 1124 } |
| 1125 |
| 1126 var oobe = $('oobe'); |
| 1127 if (!oobe.confirmDiagnosticMode_) { |
| 1128 oobe.confirmDiagnosticMode_ = |
| 1129 new cr.ui.dialogs.ConfirmDialog(document.body); |
| 1130 oobe.confirmDiagnosticMode_.setOkLabel( |
| 1131 loadTimeData.getString('confirmKioskAppDiagnosticModeYes')); |
| 1132 oobe.confirmDiagnosticMode_.setCancelLabel( |
| 1133 loadTimeData.getString('confirmKioskAppDiagnosticModeNo')); |
| 1134 } |
| 1135 |
| 1136 oobe.confirmDiagnosticMode_.show( |
| 1137 loadTimeData.getStringF('confirmKioskAppDiagnosticModeFormat', |
| 1138 app.label), |
| 1139 function() { |
| 1140 chrome.send('launchKioskApp', [app.id, true]); |
| 1141 }); |
| 1142 }, |
| 1143 }; |
| 1144 |
| 1145 /** |
| 1024 * Creates a new pod row element. | 1146 * Creates a new pod row element. |
| 1025 * @constructor | 1147 * @constructor |
| 1026 * @extends {HTMLDivElement} | 1148 * @extends {HTMLDivElement} |
| 1027 */ | 1149 */ |
| 1028 var PodRow = cr.ui.define('podrow'); | 1150 var PodRow = cr.ui.define('podrow'); |
| 1029 | 1151 |
| 1030 PodRow.prototype = { | 1152 PodRow.prototype = { |
| 1031 __proto__: HTMLDivElement.prototype, | 1153 __proto__: HTMLDivElement.prototype, |
| 1032 | 1154 |
| 1033 // Whether this user pod row is shown for the first time. | 1155 // Whether this user pod row is shown for the first time. |
| 1034 firstShown_: true, | 1156 firstShown_: true, |
| 1035 | 1157 |
| 1036 // True if inside focusPod(). | 1158 // True if inside focusPod(). |
| 1037 insideFocusPod_: false, | 1159 insideFocusPod_: false, |
| 1038 | 1160 |
| 1039 // Focused pod. | 1161 // Focused pod. |
| 1040 focusedPod_: undefined, | 1162 focusedPod_: undefined, |
| 1041 | 1163 |
| 1042 // Activated pod, i.e. the pod of current login attempt. | 1164 // Activated pod, i.e. the pod of current login attempt. |
| 1043 activatedPod_: undefined, | 1165 activatedPod_: undefined, |
| 1044 | 1166 |
| 1045 // Pod that was most recently focused, if any. | 1167 // Pod that was most recently focused, if any. |
| 1046 lastFocusedPod_: undefined, | 1168 lastFocusedPod_: undefined, |
| 1047 | 1169 |
| 1048 // Pods whose initial images haven't been loaded yet. | 1170 // Pods whose initial images haven't been loaded yet. |
| 1049 podsWithPendingImages_: [], | 1171 podsWithPendingImages_: [], |
| 1050 | 1172 |
| 1173 // Whether pod creation is animated. |
| 1174 user_add_is_animated_: false, |
| 1175 |
| 1176 // Array of apps that are shown in addition to other user pods. |
| 1177 apps_: [], |
| 1178 |
| 1179 // Array of users that are shown (public/supervised/regular). |
| 1180 users_: [], |
| 1181 |
| 1051 /** @override */ | 1182 /** @override */ |
| 1052 decorate: function() { | 1183 decorate: function() { |
| 1053 // Event listeners that are installed for the time period during which | 1184 // Event listeners that are installed for the time period during which |
| 1054 // the element is visible. | 1185 // the element is visible. |
| 1055 this.listeners_ = { | 1186 this.listeners_ = { |
| 1056 focus: [this.handleFocus_.bind(this), true /* useCapture */], | 1187 focus: [this.handleFocus_.bind(this), true /* useCapture */], |
| 1057 click: [this.handleClick_.bind(this), true], | 1188 click: [this.handleClick_.bind(this), true], |
| 1058 mousemove: [this.handleMouseMove_.bind(this), false], | 1189 mousemove: [this.handleMouseMove_.bind(this), false], |
| 1059 keydown: [this.handleKeyDown.bind(this), false] | 1190 keydown: [this.handleKeyDown.bind(this), false] |
| 1060 }; | 1191 }; |
| 1061 }, | 1192 }, |
| 1062 | 1193 |
| 1063 /** | 1194 /** |
| 1064 * Returns all the pods in this pod row. | 1195 * Returns all the pods in this pod row. |
| 1065 * @type {NodeList} | 1196 * @type {NodeList} |
| 1066 */ | 1197 */ |
| 1067 get pods() { | 1198 get pods() { |
| 1068 return Array.prototype.slice.call(this.children); | 1199 return Array.prototype.slice.call(this.children); |
| 1069 }, | 1200 }, |
| 1070 | 1201 |
| 1071 /** | 1202 /** |
| 1072 * Return true if user pod row has only single user pod in it. | 1203 * Return true if user pod row has only single user pod in it. |
| 1073 * @type {boolean} | 1204 * @type {boolean} |
| 1074 */ | 1205 */ |
| 1075 get isSinglePod() { | 1206 get isSinglePod() { |
| 1076 return this.children.length == 1; | 1207 return this.children.length == 1; |
| 1077 }, | 1208 }, |
| 1078 | 1209 |
| 1079 /** | 1210 /** |
| 1211 * Returns pod with the given app id. |
| 1212 * @param {!string} app_id Application id to be matched. |
| 1213 * @return {Object} Pod with the given app id. null if pod hasn't been |
| 1214 * found. |
| 1215 */ |
| 1216 getPodWithAppId_: function(app_id) { |
| 1217 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 1218 if (pod.user.isApp && pod.user.id == app_id) |
| 1219 return pod; |
| 1220 } |
| 1221 return null; |
| 1222 }, |
| 1223 |
| 1224 /** |
| 1080 * Returns pod with the given username (null if there is no such pod). | 1225 * Returns pod with the given username (null if there is no such pod). |
| 1081 * @param {string} username Username to be matched. | 1226 * @param {string} username Username to be matched. |
| 1082 * @return {Object} Pod with the given username. null if pod hasn't been | 1227 * @return {Object} Pod with the given username. null if pod hasn't been |
| 1083 * found. | 1228 * found. |
| 1084 */ | 1229 */ |
| 1085 getPodWithUsername_: function(username) { | 1230 getPodWithUsername_: function(username) { |
| 1086 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 1231 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 1087 if (pod.user.username == username) | 1232 if (pod.user.username == username) |
| 1088 return pod; | 1233 return pod; |
| 1089 } | 1234 } |
| 1090 return null; | 1235 return null; |
| 1091 }, | 1236 }, |
| 1092 | 1237 |
| 1093 /** | 1238 /** |
| 1094 * True if the the pod row is disabled (handles no user interaction). | 1239 * True if the the pod row is disabled (handles no user interaction). |
| 1095 * @type {boolean} | 1240 * @type {boolean} |
| 1096 */ | 1241 */ |
| 1097 disabled_: false, | 1242 disabled_: false, |
| 1098 get disabled() { | 1243 get disabled() { |
| 1099 return this.disabled_; | 1244 return this.disabled_; |
| 1100 }, | 1245 }, |
| 1101 set disabled(value) { | 1246 set disabled(value) { |
| 1102 this.disabled_ = value; | 1247 this.disabled_ = value; |
| 1103 var controls = this.querySelectorAll('button,input'); | 1248 var controls = this.querySelectorAll('button,input'); |
| 1104 for (var i = 0, control; control = controls[i]; ++i) { | 1249 for (var i = 0, control; control = controls[i]; ++i) { |
| 1105 control.disabled = value; | 1250 control.disabled = value; |
| 1106 } | 1251 } |
| 1107 }, | 1252 }, |
| 1108 | 1253 |
| 1109 /** | 1254 /** |
| 1110 * Creates a user pod from given email. | 1255 * Creates a user pod from given email. |
| 1111 * @param {string} email User's email. | 1256 * @param {!Object} user User info dictionary. |
| 1112 */ | 1257 */ |
| 1113 createUserPod: function(user) { | 1258 createUserPod: function(user) { |
| 1114 var userPod; | 1259 var userPod; |
| 1115 if (user.isDesktopUser) | 1260 if (user.isDesktopUser) |
| 1116 userPod = new DesktopUserPod({user: user}); | 1261 userPod = new DesktopUserPod({user: user}); |
| 1117 else if (user.publicAccount) | 1262 else if (user.publicAccount) |
| 1118 userPod = new PublicAccountUserPod({user: user}); | 1263 userPod = new PublicAccountUserPod({user: user}); |
| 1264 else if (user.isApp) |
| 1265 userPod = new KioskAppPod({user: user}); |
| 1119 else | 1266 else |
| 1120 userPod = new UserPod({user: user}); | 1267 userPod = new UserPod({user: user}); |
| 1121 | 1268 |
| 1122 userPod.hidden = false; | 1269 userPod.hidden = false; |
| 1123 return userPod; | 1270 return userPod; |
| 1124 }, | 1271 }, |
| 1125 | 1272 |
| 1126 /** | 1273 /** |
| 1127 * Add an existing user pod to this pod row. | 1274 * Add an existing user pod to this pod row. |
| 1128 * @param {!Object} user User info dictionary. | 1275 * @param {!Object} user User info dictionary. |
| 1129 * @param {boolean} animated Whether to use init animation. | 1276 * @param {boolean} animated Whether to use init animation. |
| 1130 */ | 1277 */ |
| 1131 addUserPod: function(user, animated) { | 1278 addUserPod: function(user, animated) { |
| 1132 var userPod = this.createUserPod(user); | 1279 var userPod = this.createUserPod(user); |
| 1133 if (animated) { | 1280 if (animated) { |
| 1134 userPod.classList.add('init'); | 1281 userPod.classList.add('init'); |
| 1135 userPod.nameElement.classList.add('init'); | 1282 userPod.nameElement.classList.add('init'); |
| 1136 } | 1283 } |
| 1137 | 1284 |
| 1138 this.appendChild(userPod); | 1285 this.appendChild(userPod); |
| 1139 userPod.initialize(); | 1286 userPod.initialize(); |
| 1140 }, | 1287 }, |
| 1141 | 1288 |
| 1142 /** | 1289 /** |
| 1290 * Runs app with a given id from the list of loaded apps. |
| 1291 * @param {!string} app_id of an app to run. |
| 1292 * @param {boolean=} opt_diagnostic_mode Whether to run the app in |
| 1293 * diagnostic mode. Default is false. |
| 1294 */ |
| 1295 findAndRunAppForTesting: function(app_id, opt_diagnostic_mode) { |
| 1296 var app = this.getPodWithAppId_(app_id); |
| 1297 if (app) { |
| 1298 var activationEvent = cr.doc.createEvent('MouseEvents'); |
| 1299 var ctrlKey = opt_diagnostic_mode; |
| 1300 activationEvent.initMouseEvent('click', true, true, null, |
| 1301 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); |
| 1302 app.dispatchEvent(activationEvent); |
| 1303 } |
| 1304 }, |
| 1305 |
| 1306 /** |
| 1143 * Removes user pod from pod row. | 1307 * Removes user pod from pod row. |
| 1144 * @param {string} email User's email. | 1308 * @param {string} email User's email. |
| 1145 */ | 1309 */ |
| 1146 removeUserPod: function(username) { | 1310 removeUserPod: function(username) { |
| 1147 var podToRemove = this.getPodWithUsername_(username); | 1311 var podToRemove = this.getPodWithUsername_(username); |
| 1148 if (podToRemove == null) { | 1312 if (podToRemove == null) { |
| 1149 console.warn('Attempt to remove not existing pod for ' + username + | 1313 console.warn('Attempt to remove not existing pod for ' + username + |
| 1150 '.'); | 1314 '.'); |
| 1151 return; | 1315 return; |
| 1152 } | 1316 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 pod.classList.add('zoom'); | 1359 pod.classList.add('zoom'); |
| 1196 } | 1360 } |
| 1197 }, | 1361 }, |
| 1198 | 1362 |
| 1199 /** | 1363 /** |
| 1200 * Populates pod row with given existing users and start init animation. | 1364 * Populates pod row with given existing users and start init animation. |
| 1201 * @param {array} users Array of existing user emails. | 1365 * @param {array} users Array of existing user emails. |
| 1202 * @param {boolean} animated Whether to use init animation. | 1366 * @param {boolean} animated Whether to use init animation. |
| 1203 */ | 1367 */ |
| 1204 loadPods: function(users, animated) { | 1368 loadPods: function(users, animated) { |
| 1369 this.users_ = users; |
| 1370 this.user_add_is_animated_ = animated; |
| 1371 |
| 1372 this.rebuildPods(); |
| 1373 }, |
| 1374 |
| 1375 /** |
| 1376 * Rebuilds pod row using users_ and apps_ that were previously set or |
| 1377 * updated. |
| 1378 */ |
| 1379 rebuildPods: function() { |
| 1205 // Clear existing pods. | 1380 // Clear existing pods. |
| 1206 this.innerHTML = ''; | 1381 this.innerHTML = ''; |
| 1207 this.focusedPod_ = undefined; | 1382 this.focusedPod_ = undefined; |
| 1208 this.activatedPod_ = undefined; | 1383 this.activatedPod_ = undefined; |
| 1209 this.lastFocusedPod_ = undefined; | 1384 this.lastFocusedPod_ = undefined; |
| 1210 | 1385 |
| 1211 // Switch off animation | 1386 // Switch off animation |
| 1212 Oobe.getInstance().toggleClass('flying-pods', false); | 1387 Oobe.getInstance().toggleClass('flying-pods', false); |
| 1213 | 1388 |
| 1214 // Populate the pod row. | 1389 // Populate the pod row. |
| 1215 for (var i = 0; i < users.length; ++i) { | 1390 for (var i = 0; i < this.users_.length; ++i) |
| 1216 this.addUserPod(users[i], animated); | 1391 this.addUserPod(this.users_[i], this.user_add_is_animated_); |
| 1217 } | 1392 |
| 1218 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 1393 for (var i = 0, pod; pod = this.pods[i]; ++i) |
| 1219 this.podsWithPendingImages_.push(pod); | 1394 this.podsWithPendingImages_.push(pod); |
| 1220 } | 1395 |
| 1396 // TODO: Edge case handling when kiosk apps are not fitting. |
| 1397 for (var i = 0; i < this.apps_.length; ++i) |
| 1398 this.addUserPod(this.apps_[i], this.user_add_is_animated_); |
| 1399 |
| 1221 // Make sure we eventually show the pod row, even if some image is stuck. | 1400 // Make sure we eventually show the pod row, even if some image is stuck. |
| 1222 setTimeout(function() { | 1401 setTimeout(function() { |
| 1223 $('pod-row').classList.remove('images-loading'); | 1402 $('pod-row').classList.remove('images-loading'); |
| 1224 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); | 1403 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); |
| 1225 | 1404 |
| 1226 this.placePods_(); | 1405 this.placePods_(); |
| 1227 | 1406 |
| 1228 // Without timeout changes in pods positions will be animated even though | 1407 // Without timeout changes in pods positions will be animated even though |
| 1229 // it happened when 'flying-pods' class was disabled. | 1408 // it happened when 'flying-pods' class was disabled. |
| 1230 setTimeout(function() { | 1409 setTimeout(function() { |
| 1231 Oobe.getInstance().toggleClass('flying-pods', true); | 1410 Oobe.getInstance().toggleClass('flying-pods', true); |
| 1232 }, 0); | 1411 }, 0); |
| 1233 | 1412 |
| 1234 this.focusPod(this.preselectedPod); | 1413 this.focusPod(this.preselectedPod); |
| 1235 }, | 1414 }, |
| 1236 | 1415 |
| 1237 /** | 1416 /** |
| 1417 * Adds given apps to the pod row. |
| 1418 * @param {array} apps Array of apps. |
| 1419 */ |
| 1420 setApps: function(apps) { |
| 1421 this.apps_ = apps; |
| 1422 this.rebuildPods(); |
| 1423 chrome.send('kioskAppsLoaded'); |
| 1424 |
| 1425 // Check whether there's a pending kiosk app error. |
| 1426 window.setTimeout(function() { |
| 1427 chrome.send('checkKioskAppLaunchError'); |
| 1428 }, 500); |
| 1429 }, |
| 1430 |
| 1431 /** |
| 1238 * Shows a button on a user pod with an icon. Clicking on this button | 1432 * Shows a button on a user pod with an icon. Clicking on this button |
| 1239 * triggers an event used by the chrome.screenlockPrivate API. | 1433 * triggers an event used by the chrome.screenlockPrivate API. |
| 1240 * @param {string} username Username of pod to add button | 1434 * @param {string} username Username of pod to add button |
| 1241 * @param {string} iconURL URL of the button icon | 1435 * @param {string} iconURL URL of the button icon |
| 1242 */ | 1436 */ |
| 1243 showUserPodButton: function(username, iconURL) { | 1437 showUserPodButton: function(username, iconURL) { |
| 1244 var pod = this.getPodWithUsername_(username); | 1438 var pod = this.getPodWithUsername_(username); |
| 1245 if (pod == null) { | 1439 if (pod == null) { |
| 1246 console.error('Unable to show user pod button for ' + username + | 1440 console.error('Unable to show user pod button for ' + username + |
| 1247 ': user pod not found.'); | 1441 ': user pod not found.'); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 * @return {boolean} Pod focus status. | 1564 * @return {boolean} Pod focus status. |
| 1371 */ | 1565 */ |
| 1372 isFocused: function(pod) { | 1566 isFocused: function(pod) { |
| 1373 return this.focusedPod_ == pod; | 1567 return this.focusedPod_ == pod; |
| 1374 }, | 1568 }, |
| 1375 | 1569 |
| 1376 /** | 1570 /** |
| 1377 * Focuses a given user pod or clear focus when given null. | 1571 * Focuses a given user pod or clear focus when given null. |
| 1378 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). | 1572 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). |
| 1379 * @param {boolean=} opt_force If true, forces focus update even when | 1573 * @param {boolean=} opt_force If true, forces focus update even when |
| 1380 * podToFocus is already focused. | 1574 * podToFocus is already focused. |
| 1381 */ | 1575 */ |
| 1382 focusPod: function(podToFocus, opt_force) { | 1576 focusPod: function(podToFocus, opt_force) { |
| 1383 if (this.isFocused(podToFocus) && !opt_force) { | 1577 if (this.isFocused(podToFocus) && !opt_force) { |
| 1384 this.keyboardActivated_ = false; | 1578 this.keyboardActivated_ = false; |
| 1385 return; | 1579 return; |
| 1386 } | 1580 } |
| 1387 | 1581 |
| 1388 // Make sure that we don't focus pods that are not allowed to be focused. | 1582 // Make sure that we don't focus pods that are not allowed to be focused. |
| 1389 // TODO(nkostylev): Fix various keyboard focus related issues caused | 1583 // TODO(nkostylev): Fix various keyboard focus related issues caused |
| 1390 // by this approach. http://crbug.com/339042 | 1584 // by this approach. http://crbug.com/339042 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1416 if (!this.isFocused(podToFocus)) | 1610 if (!this.isFocused(podToFocus)) |
| 1417 Oobe.clearErrors(); | 1611 Oobe.clearErrors(); |
| 1418 | 1612 |
| 1419 var hadFocus = !!this.focusedPod_; | 1613 var hadFocus = !!this.focusedPod_; |
| 1420 this.focusedPod_ = podToFocus; | 1614 this.focusedPod_ = podToFocus; |
| 1421 if (podToFocus) { | 1615 if (podToFocus) { |
| 1422 podToFocus.classList.remove('faded'); | 1616 podToFocus.classList.remove('faded'); |
| 1423 podToFocus.classList.add('focused'); | 1617 podToFocus.classList.add('focused'); |
| 1424 podToFocus.reset(true); // Reset and give focus. | 1618 podToFocus.reset(true); // Reset and give focus. |
| 1425 // focusPod() automatically loads wallpaper | 1619 // focusPod() automatically loads wallpaper |
| 1426 chrome.send('focusPod', [podToFocus.user.username]); | 1620 if (!podToFocus.user.isApp) |
| 1621 chrome.send('focusPod', [podToFocus.user.username]); |
| 1427 this.firstShown_ = false; | 1622 this.firstShown_ = false; |
| 1428 this.lastFocusedPod_ = podToFocus; | 1623 this.lastFocusedPod_ = podToFocus; |
| 1429 } | 1624 } |
| 1430 this.insideFocusPod_ = false; | 1625 this.insideFocusPod_ = false; |
| 1431 this.keyboardActivated_ = false; | 1626 this.keyboardActivated_ = false; |
| 1432 }, | 1627 }, |
| 1433 | 1628 |
| 1434 /** | 1629 /** |
| 1435 * Focuses a given user pod by index or clear focus when given null. | 1630 * Focuses a given user pod by index or clear focus when given null. |
| 1436 * @param {int=} podToFocus index of User pod to focus. | 1631 * @param {int=} podToFocus index of User pod to focus. |
| 1437 * @param {boolean=} opt_force If true, forces focus update even when | 1632 * @param {boolean=} opt_force If true, forces focus update even when |
| 1438 * podToFocus is already focused. | 1633 * podToFocus is already focused. |
| 1439 */ | 1634 */ |
| 1440 focusPodByIndex: function(podToFocus, opt_force) { | 1635 focusPodByIndex: function(podToFocus, opt_force) { |
| 1441 if (podToFocus < this.pods.length) | 1636 if (podToFocus < this.pods.length) |
| 1442 this.focusPod(this.pods[podToFocus], opt_force); | 1637 this.focusPod(this.pods[podToFocus], opt_force); |
| 1443 }, | 1638 }, |
| 1444 | 1639 |
| 1445 /** | 1640 /** |
| 1446 * Resets wallpaper to the last active user's wallpaper, if any. | 1641 * Resets wallpaper to the last active user's wallpaper, if any. |
| 1447 */ | 1642 */ |
| 1448 loadLastWallpaper: function() { | 1643 loadLastWallpaper: function() { |
| 1449 if (this.lastFocusedPod_) | 1644 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) |
| 1450 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); | 1645 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); |
| 1451 }, | 1646 }, |
| 1452 | 1647 |
| 1453 /** | 1648 /** |
| 1454 * Returns the currently activated pod. | 1649 * Returns the currently activated pod. |
| 1455 * @type {UserPod} | 1650 * @type {UserPod} |
| 1456 */ | 1651 */ |
| 1457 get activatedPod() { | 1652 get activatedPod() { |
| 1458 return this.activatedPod_; | 1653 return this.activatedPod_; |
| 1459 }, | 1654 }, |
| 1460 set activatedPod(pod) { | 1655 |
| 1461 if (pod && pod.activate()) | 1656 /** |
| 1657 * Sets currently activated pod. |
| 1658 * @param {UserPod} pod Pod to check for focus. |
| 1659 * @param {Event} e Event object. |
| 1660 */ |
| 1661 setActivatedPod: function(pod, e) { |
| 1662 if (pod && pod.activate(e)) |
| 1462 this.activatedPod_ = pod; | 1663 this.activatedPod_ = pod; |
| 1463 }, | 1664 }, |
| 1464 | 1665 |
| 1465 /** | 1666 /** |
| 1466 * The pod of the signed-in user, if any; null otherwise. | 1667 * The pod of the signed-in user, if any; null otherwise. |
| 1467 * @type {?UserPod} | 1668 * @type {?UserPod} |
| 1468 */ | 1669 */ |
| 1469 get lockedPod() { | 1670 get lockedPod() { |
| 1470 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 1671 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 1471 if (pod.user.signedIn) | 1672 if (pod.user.signedIn) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) | 1876 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) |
| 1676 this.focusPod(this.focusedPod_.nextElementSibling); | 1877 this.focusPod(this.focusedPod_.nextElementSibling); |
| 1677 else | 1878 else |
| 1678 this.focusPod(this.firstElementChild); | 1879 this.focusPod(this.firstElementChild); |
| 1679 | 1880 |
| 1680 e.stopPropagation(); | 1881 e.stopPropagation(); |
| 1681 } | 1882 } |
| 1682 break; | 1883 break; |
| 1683 case 'Enter': | 1884 case 'Enter': |
| 1684 if (this.focusedPod_) { | 1885 if (this.focusedPod_) { |
| 1685 this.activatedPod = this.focusedPod_; | 1886 this.setActivatedPod(this.focusedPod_, e); |
| 1686 e.stopPropagation(); | 1887 e.stopPropagation(); |
| 1687 } | 1888 } |
| 1688 break; | 1889 break; |
| 1689 case 'U+001B': // Esc | 1890 case 'U+001B': // Esc |
| 1690 if (!this.isSinglePod) | 1891 if (!this.isSinglePod) |
| 1691 this.focusPod(); | 1892 this.focusPod(); |
| 1692 break; | 1893 break; |
| 1693 } | 1894 } |
| 1694 }, | 1895 }, |
| 1695 | 1896 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1706 if (this.focusedPod_) { | 1907 if (this.focusedPod_) { |
| 1707 var focusedPod = this.focusedPod_; | 1908 var focusedPod = this.focusedPod_; |
| 1708 var screen = this.parentNode; | 1909 var screen = this.parentNode; |
| 1709 var self = this; | 1910 var self = this; |
| 1710 focusedPod.addEventListener('webkitTransitionEnd', function f(e) { | 1911 focusedPod.addEventListener('webkitTransitionEnd', function f(e) { |
| 1711 if (e.target == focusedPod) { | 1912 if (e.target == focusedPod) { |
| 1712 focusedPod.removeEventListener('webkitTransitionEnd', f); | 1913 focusedPod.removeEventListener('webkitTransitionEnd', f); |
| 1713 focusedPod.reset(true); | 1914 focusedPod.reset(true); |
| 1714 // Notify screen that it is ready. | 1915 // Notify screen that it is ready. |
| 1715 screen.onShow(); | 1916 screen.onShow(); |
| 1716 chrome.send('loadWallpaper', [focusedPod.user.username]); | 1917 if (!focusedPod.user.isApp) |
| 1918 chrome.send('loadWallpaper', [focusedPod.user.username]); |
| 1717 } | 1919 } |
| 1718 }); | 1920 }); |
| 1719 // Guard timer for 1 second -- it would conver all possible animations. | 1921 // Guard timer for 1 second -- it would conver all possible animations. |
| 1720 ensureTransitionEndEvent(focusedPod, 1000); | 1922 ensureTransitionEndEvent(focusedPod, 1000); |
| 1721 } | 1923 } |
| 1722 }, | 1924 }, |
| 1723 | 1925 |
| 1724 /** | 1926 /** |
| 1725 * Called right before the pod row is shown. | 1927 * Called right before the pod row is shown. |
| 1726 */ | 1928 */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1757 if (this.podsWithPendingImages_.length == 0) { | 1959 if (this.podsWithPendingImages_.length == 0) { |
| 1758 this.classList.remove('images-loading'); | 1960 this.classList.remove('images-loading'); |
| 1759 } | 1961 } |
| 1760 } | 1962 } |
| 1761 }; | 1963 }; |
| 1762 | 1964 |
| 1763 return { | 1965 return { |
| 1764 PodRow: PodRow | 1966 PodRow: PodRow |
| 1765 }; | 1967 }; |
| 1766 }); | 1968 }); |
| OLD | NEW |