OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 /** | 357 /** |
358 * Gets user type icon area. | 358 * Gets user type icon area. |
359 * @type {!HTMLDivElement} | 359 * @type {!HTMLDivElement} |
360 */ | 360 */ |
361 get userTypeIconAreaElement() { | 361 get userTypeIconAreaElement() { |
362 return this.querySelector('.user-type-icon-area'); | 362 return this.querySelector('.user-type-icon-area'); |
363 }, | 363 }, |
364 | 364 |
365 /** | 365 /** |
| 366 * Gets user type bubble like multi-profiles policy restriction message. |
| 367 * @type {!HTMLDivElement} |
| 368 */ |
| 369 get userTypeBubbleElement() { |
| 370 return this.querySelector('.user-type-bubble'); |
| 371 }, |
| 372 |
| 373 /** |
366 * Gets user type icon. | 374 * Gets user type icon. |
367 * @type {!HTMLDivElement} | 375 * @type {!HTMLDivElement} |
368 */ | 376 */ |
369 get userTypeIconElement() { | 377 get userTypeIconElement() { |
370 return this.querySelector('.user-type-icon-image'); | 378 return this.querySelector('.user-type-icon-image'); |
371 }, | 379 }, |
372 | 380 |
373 /** | 381 /** |
374 * Gets action box menu. | 382 * Gets action box menu. |
375 * @type {!HTMLInputElement} | 383 * @type {!HTMLInputElement} |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 this.user_.displayName; | 526 this.user_.displayName; |
519 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; | 527 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; |
520 this.actionBoxMenuTitleEmailElement.hidden = | 528 this.actionBoxMenuTitleEmailElement.hidden = |
521 this.user_.locallyManagedUser; | 529 this.user_.locallyManagedUser; |
522 | 530 |
523 this.actionBoxMenuCommandElement.textContent = | 531 this.actionBoxMenuCommandElement.textContent = |
524 loadTimeData.getString('removeUser'); | 532 loadTimeData.getString('removeUser'); |
525 }, | 533 }, |
526 | 534 |
527 customizeUserPodPerUserType: function() { | 535 customizeUserPodPerUserType: function() { |
528 var isMultiProfilesUI = | |
529 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | |
530 | |
531 if (this.user_.locallyManagedUser && !this.user_.isDesktopUser) { | 536 if (this.user_.locallyManagedUser && !this.user_.isDesktopUser) { |
532 this.setUserPodIconType('supervised'); | 537 this.setUserPodIconType('supervised'); |
533 } else if (isMultiProfilesUI && !this.user_.isMultiProfilesAllowed) { | 538 } else if (this.multiProfilesPolicyApplied) { |
534 // Mark user pod as not focusable which in addition to the grayed out | 539 // Mark user pod as not focusable which in addition to the grayed out |
535 // filter makes it look in disabled state. | 540 // filter makes it look in disabled state. |
536 this.classList.add('not-focusable'); | 541 this.classList.add('not-focusable'); |
537 this.setUserPodIconType('policy'); | 542 this.setUserPodIconType('policy'); |
538 | 543 |
539 this.querySelector('.mp-policy-title').hidden = false; | 544 this.querySelector('.mp-policy-title').hidden = false; |
540 if (this.user.multiProfilesPolicy == 'primary-only') | 545 if (this.user.multiProfilesPolicy == 'primary-only') |
541 this.querySelector('.mp-policy-primary-only-msg').hidden = false; | 546 this.querySelector('.mp-policy-primary-only-msg').hidden = false; |
542 else if (this.user.multiProfilesPolicy == 'owner-primary-only') | 547 else if (this.user.multiProfilesPolicy == 'owner-primary-only') |
543 this.querySelector('.mp-owner-primary-only-msg').hidden = false; | 548 this.querySelector('.mp-owner-primary-only-msg').hidden = false; |
(...skipping 16 matching lines...) Expand all Loading... |
560 user_: undefined, | 565 user_: undefined, |
561 get user() { | 566 get user() { |
562 return this.user_; | 567 return this.user_; |
563 }, | 568 }, |
564 set user(userDict) { | 569 set user(userDict) { |
565 this.user_ = userDict; | 570 this.user_ = userDict; |
566 this.update(); | 571 this.update(); |
567 }, | 572 }, |
568 | 573 |
569 /** | 574 /** |
| 575 * Returns true if multi-profiles sign in is currently active and this |
| 576 * user pod is restricted per policy. |
| 577 * @type {boolean} |
| 578 */ |
| 579 get multiProfilesPolicyApplied() { |
| 580 var isMultiProfilesUI = |
| 581 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
| 582 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; |
| 583 }, |
| 584 |
| 585 /** |
570 * Gets main input element. | 586 * Gets main input element. |
571 * @type {(HTMLButtonElement|HTMLInputElement)} | 587 * @type {(HTMLButtonElement|HTMLInputElement)} |
572 */ | 588 */ |
573 get mainInput() { | 589 get mainInput() { |
574 if (this.isAuthTypePassword) { | 590 if (this.isAuthTypePassword) { |
575 return this.passwordElement; | 591 return this.passwordElement; |
576 } else if (this.isAuthTypeOnlineSignIn) { | 592 } else if (this.isAuthTypeOnlineSignIn) { |
577 return this.signinButtonElement; | 593 return this.signinButtonElement; |
578 } else if (this.isAuthTypeUserClick) { | 594 } else if (this.isAuthTypeUserClick) { |
579 return this; | 595 return this; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 return this.actionBoxAreaElement.classList.contains('hovered'); | 631 return this.actionBoxAreaElement.classList.contains('hovered'); |
616 }, | 632 }, |
617 set isActionBoxMenuHovered(hovered) { | 633 set isActionBoxMenuHovered(hovered) { |
618 if (hovered == this.isActionBoxMenuHovered) | 634 if (hovered == this.isActionBoxMenuHovered) |
619 return; | 635 return; |
620 | 636 |
621 if (hovered) { | 637 if (hovered) { |
622 this.actionBoxAreaElement.classList.add('hovered'); | 638 this.actionBoxAreaElement.classList.add('hovered'); |
623 this.classList.add('hovered'); | 639 this.classList.add('hovered'); |
624 } else { | 640 } else { |
| 641 if (this.multiProfilesPolicyApplied) |
| 642 this.userTypeBubbleElement.classList.remove('bubble-shown'); |
625 this.actionBoxAreaElement.classList.remove('hovered'); | 643 this.actionBoxAreaElement.classList.remove('hovered'); |
626 this.classList.remove('hovered'); | 644 this.classList.remove('hovered'); |
627 } | 645 } |
628 }, | 646 }, |
629 | 647 |
630 /** | 648 /** |
631 * Set the authentication type for the pod. | 649 * Set the authentication type for the pod. |
632 * @param {number} An auth type value defined in the AUTH_TYPE enum. | 650 * @param {number} An auth type value defined in the AUTH_TYPE enum. |
633 * @param {string} authValue The initial value used for the auth type. | 651 * @param {string} authValue The initial value used for the auth type. |
634 */ | 652 */ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 4); | 763 4); |
746 }, | 764 }, |
747 | 765 |
748 /** | 766 /** |
749 * Shows signin UI for this user. | 767 * Shows signin UI for this user. |
750 */ | 768 */ |
751 showSigninUI: function() { | 769 showSigninUI: function() { |
752 if (this.user.locallyManagedUser && !this.user.isDesktopUser) { | 770 if (this.user.locallyManagedUser && !this.user.isDesktopUser) { |
753 this.showSupervisedUserSigninWarning(); | 771 this.showSupervisedUserSigninWarning(); |
754 } else { | 772 } else { |
| 773 // Special case for multi-profiles sign in. We show users even if they |
| 774 // are not allowed per policy. Restrict those users from starting GAIA. |
| 775 if (this.multiProfilesPolicyApplied) |
| 776 return; |
| 777 |
755 this.parentNode.showSigninUI(this.user.emailAddress); | 778 this.parentNode.showSigninUI(this.user.emailAddress); |
756 } | 779 } |
757 }, | 780 }, |
758 | 781 |
759 /** | 782 /** |
760 * Resets the input field and updates the tab order of pod controls. | 783 * Resets the input field and updates the tab order of pod controls. |
761 * @param {boolean} takeFocus If true, input field takes focus. | 784 * @param {boolean} takeFocus If true, input field takes focus. |
762 */ | 785 */ |
763 reset: function(takeFocus) { | 786 reset: function(takeFocus) { |
764 this.passwordElement.value = ''; | 787 this.passwordElement.value = ''; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 if (this.parentNode.disabled) | 914 if (this.parentNode.disabled) |
892 return; | 915 return; |
893 | 916 |
894 if (!this.isActionBoxMenuActive) { | 917 if (!this.isActionBoxMenuActive) { |
895 if (this.isAuthTypeOnlineSignIn) { | 918 if (this.isAuthTypeOnlineSignIn) { |
896 this.showSigninUI(); | 919 this.showSigninUI(); |
897 } else if (this.isAuthTypeUserClick) { | 920 } else if (this.isAuthTypeUserClick) { |
898 this.parentNode.setActivatedPod(this); | 921 this.parentNode.setActivatedPod(this); |
899 } | 922 } |
900 | 923 |
| 924 if (this.multiProfilesPolicyApplied) |
| 925 this.userTypeBubbleElement.classList.add('bubble-shown'); |
| 926 |
901 // Prevent default so that we don't trigger 'focus' event. | 927 // Prevent default so that we don't trigger 'focus' event. |
902 e.preventDefault(); | 928 e.preventDefault(); |
903 } | 929 } |
904 }, | 930 }, |
905 | 931 |
906 /** | 932 /** |
907 * Handles keydown event for a user pod. | 933 * Handles keydown event for a user pod. |
908 * @param {Event} e Key event. | 934 * @param {Event} e Key event. |
909 */ | 935 */ |
910 handlePodKeyDown_: function(e) { | 936 handlePodKeyDown_: function(e) { |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 }, | 1982 }, |
1957 | 1983 |
1958 /** | 1984 /** |
1959 * Focuses a given user pod or clear focus when given null. | 1985 * Focuses a given user pod or clear focus when given null. |
1960 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). | 1986 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). |
1961 * @param {boolean=} opt_force If true, forces focus update even when | 1987 * @param {boolean=} opt_force If true, forces focus update even when |
1962 * podToFocus is already focused. | 1988 * podToFocus is already focused. |
1963 */ | 1989 */ |
1964 focusPod: function(podToFocus, opt_force) { | 1990 focusPod: function(podToFocus, opt_force) { |
1965 if (this.isFocused(podToFocus) && !opt_force) { | 1991 if (this.isFocused(podToFocus) && !opt_force) { |
| 1992 // Calling focusPod w/o podToFocus means reset. |
| 1993 if (!podToFocus) |
| 1994 Oobe.clearErrors(); |
1966 this.keyboardActivated_ = false; | 1995 this.keyboardActivated_ = false; |
1967 return; | 1996 return; |
1968 } | 1997 } |
1969 | 1998 |
1970 // Make sure that we don't focus pods that are not allowed to be focused. | 1999 // Make sure that we don't focus pods that are not allowed to be focused. |
1971 // TODO(nkostylev): Fix various keyboard focus related issues caused | 2000 // TODO(nkostylev): Fix various keyboard focus related issues caused |
1972 // by this approach. http://crbug.com/339042 | 2001 // by this approach. http://crbug.com/339042 |
1973 if (podToFocus && podToFocus.classList.contains('not-focusable')) { | 2002 if (podToFocus && podToFocus.classList.contains('not-focusable')) { |
1974 this.keyboardActivated_ = false; | 2003 this.keyboardActivated_ = false; |
1975 return; | 2004 return; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2348 if (this.podsWithPendingImages_.length == 0) { | 2377 if (this.podsWithPendingImages_.length == 0) { |
2349 this.classList.remove('images-loading'); | 2378 this.classList.remove('images-loading'); |
2350 } | 2379 } |
2351 } | 2380 } |
2352 }; | 2381 }; |
2353 | 2382 |
2354 return { | 2383 return { |
2355 PodRow: PodRow | 2384 PodRow: PodRow |
2356 }; | 2385 }; |
2357 }); | 2386 }); |
OLD | NEW |