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

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

Issue 168813002: Refactor user pods to use authType property for distinct authentication modes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ScreenLockerTest Created 6 years, 10 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 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 * @enum {number} 72 * @enum {number}
73 * @const 73 * @const
74 */ 74 */
75 var UserPodTabOrder = { 75 var UserPodTabOrder = {
76 POD_INPUT: 1, // Password input fields (and whole pods themselves). 76 POD_INPUT: 1, // Password input fields (and whole pods themselves).
77 HEADER_BAR: 2, // Buttons on the header bar (Shutdown, Add User). 77 HEADER_BAR: 2, // Buttons on the header bar (Shutdown, Add User).
78 ACTION_BOX: 3, // Action box buttons. 78 ACTION_BOX: 3, // Action box buttons.
79 PAD_MENU_ITEM: 4 // User pad menu items (Remove this user). 79 PAD_MENU_ITEM: 4 // User pad menu items (Remove this user).
80 }; 80 };
81 81
82 /**
83 * Supported authentication types. Keep in sync with the enum in
84 * chrome/browser/chromeos/login/login_display.h
85 * @enum {number}
86 * @const
87 */
88 var AUTH_TYPE = {
89 OFFLINE_PASSWORD: 0,
90 ONLINE_SIGN_IN: 1,
91 NUMERIC_PIN: 2,
92 USER_CLICK: 3,
93 };
94
95 /**
96 * Names of authentication types.
97 */
98 var AUTH_TYPE_NAMES = {
99 0: 'offlinePassword',
100 1: 'onlineSignIn',
101 2: 'numericPin',
102 3: 'userClick',
103 };
104
82 // Focus and tab order are organized as follows: 105 // Focus and tab order are organized as follows:
83 // 106 //
84 // (1) all user pods have tab index 1 so they are traversed first; 107 // (1) all user pods have tab index 1 so they are traversed first;
85 // (2) when a user pod is activated, its tab index is set to -1 and its 108 // (2) when a user pod is activated, its tab index is set to -1 and its
86 // main input field gets focus and tab index 1; 109 // main input field gets focus and tab index 1;
87 // (3) buttons on the header bar have tab index 2 so they follow user pods; 110 // (3) buttons on the header bar have tab index 2 so they follow user pods;
88 // (4) Action box buttons have tab index 3 and follow header bar buttons; 111 // (4) Action box buttons have tab index 3 and follow header bar buttons;
89 // (5) lastly, focus jumps to the Status Area and back to user pods. 112 // (5) lastly, focus jumps to the Status Area and back to user pods.
90 // 113 //
91 // 'Focus' event is handled by a capture handler for the whole document 114 // 'Focus' event is handled by a capture handler for the whole document
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 * @type {Object} 151 * @type {Object}
129 */ 152 */
130 UserPod.userImageSalt_ = {}; 153 UserPod.userImageSalt_ = {};
131 154
132 UserPod.prototype = { 155 UserPod.prototype = {
133 __proto__: HTMLDivElement.prototype, 156 __proto__: HTMLDivElement.prototype,
134 157
135 /** @override */ 158 /** @override */
136 decorate: function() { 159 decorate: function() {
137 this.tabIndex = UserPodTabOrder.POD_INPUT; 160 this.tabIndex = UserPodTabOrder.POD_INPUT;
138 this.customButton.tabIndex = UserPodTabOrder.POD_INPUT; 161 this.customButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
139 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.ACTION_BOX; 162 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.ACTION_BOX;
140 163
141 this.addEventListener('click', 164 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this));
142 this.handleClickOnPod_.bind(this)); 165 this.addEventListener('click', this.handleClickOnPod_.bind(this));
143 166
144 this.signinButtonElement.addEventListener('click', 167 this.signinButtonElement.addEventListener('click',
145 this.activate.bind(this)); 168 this.activate.bind(this));
146 169
147 this.actionBoxAreaElement.addEventListener('mousedown', 170 this.actionBoxAreaElement.addEventListener('mousedown',
148 stopEventPropagation); 171 stopEventPropagation);
149 this.actionBoxAreaElement.addEventListener('click', 172 this.actionBoxAreaElement.addEventListener('click',
150 this.handleActionAreaButtonClick_.bind(this)); 173 this.handleActionAreaButtonClick_.bind(this));
151 this.actionBoxAreaElement.addEventListener('keydown', 174 this.actionBoxAreaElement.addEventListener('keydown',
152 this.handleActionAreaButtonKeyDown_.bind(this)); 175 this.handleActionAreaButtonKeyDown_.bind(this));
153 176
154 this.actionBoxMenuRemoveElement.addEventListener('click', 177 this.actionBoxMenuRemoveElement.addEventListener('click',
155 this.handleRemoveCommandClick_.bind(this)); 178 this.handleRemoveCommandClick_.bind(this));
156 this.actionBoxMenuRemoveElement.addEventListener('keydown', 179 this.actionBoxMenuRemoveElement.addEventListener('keydown',
157 this.handleRemoveCommandKeyDown_.bind(this)); 180 this.handleRemoveCommandKeyDown_.bind(this));
158 this.actionBoxMenuRemoveElement.addEventListener('blur', 181 this.actionBoxMenuRemoveElement.addEventListener('blur',
159 this.handleRemoveCommandBlur_.bind(this)); 182 this.handleRemoveCommandBlur_.bind(this));
160 183
161 if (this.actionBoxRemoveUserWarningButtonElement) { 184 if (this.actionBoxRemoveUserWarningButtonElement) {
162 this.actionBoxRemoveUserWarningButtonElement.addEventListener( 185 this.actionBoxRemoveUserWarningButtonElement.addEventListener(
163 'click', 186 'click',
164 this.handleRemoveUserConfirmationClick_.bind(this)); 187 this.handleRemoveUserConfirmationClick_.bind(this));
165 } 188 }
166 189
167 this.customButton.addEventListener('click', 190 this.customButtonElement.addEventListener('click',
168 this.handleCustomButtonClick_.bind(this)); 191 this.handleCustomButtonClick_.bind(this));
169 }, 192 },
170 193
171 /** 194 /**
172 * Initializes the pod after its properties set and added to a pod row. 195 * Initializes the pod after its properties set and added to a pod row.
173 */ 196 */
174 initialize: function() { 197 initialize: function() {
175 this.passwordElement.addEventListener('keydown', 198 this.passwordElement.addEventListener('keydown',
176 this.parentNode.handleKeyDown.bind(this.parentNode)); 199 this.parentNode.handleKeyDown.bind(this.parentNode));
177 this.passwordElement.addEventListener('keypress', 200 this.passwordElement.addEventListener('keypress',
178 this.handlePasswordKeyPress_.bind(this)); 201 this.handlePasswordKeyPress_.bind(this));
179 202
180 this.imageElement.addEventListener('load', 203 this.imageElement.addEventListener('load',
181 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); 204 this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
205
206 var initialAuthType = this.user.initialAuthType ||
207 AUTH_TYPE.OFFLINE_PASSWORD;
208 this.setAuthType(initialAuthType, null);
182 }, 209 },
183 210
184 /** 211 /**
185 * Resets tab order for pod elements to its initial state. 212 * Resets tab order for pod elements to its initial state.
186 */ 213 */
187 resetTabOrder: function() { 214 resetTabOrder: function() {
215 // Note: the |mainInput| can be the pod itself.
216 this.mainInput.tabIndex = -1;
188 this.tabIndex = UserPodTabOrder.POD_INPUT; 217 this.tabIndex = UserPodTabOrder.POD_INPUT;
189 this.mainInput.tabIndex = -1;
190 }, 218 },
191 219
192 /** 220 /**
193 * Handles keypress event (i.e. any textual input) on password input. 221 * Handles keypress event (i.e. any textual input) on password input.
194 * @param {Event} e Keypress Event object. 222 * @param {Event} e Keypress Event object.
195 * @private 223 * @private
196 */ 224 */
197 handlePasswordKeyPress_: function(e) { 225 handlePasswordKeyPress_: function(e) {
198 // When tabbing from the system tray a tab key press is received. Suppress 226 // When tabbing from the system tray a tab key press is received. Suppress
199 // this so as not to type a tab character into the password field. 227 // this so as not to type a tab character into the password field.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 272
245 /** 273 /**
246 * Gets password field. 274 * Gets password field.
247 * @type {!HTMLInputElement} 275 * @type {!HTMLInputElement}
248 */ 276 */
249 get passwordElement() { 277 get passwordElement() {
250 return this.querySelector('.password'); 278 return this.querySelector('.password');
251 }, 279 },
252 280
253 /** 281 /**
282 * Gets the password label, which is used to show a message where the
283 * password field is normally.
284 * @type {!HTMLInputElement}
285 */
286 get passwordLabelElement() {
287 return this.querySelector('.password-label');
288 },
289
290 /**
254 * Gets Caps Lock hint image. 291 * Gets Caps Lock hint image.
255 * @type {!HTMLImageElement} 292 * @type {!HTMLImageElement}
256 */ 293 */
257 get capslockHintElement() { 294 get capslockHintElement() {
258 return this.querySelector('.capslock-hint'); 295 return this.querySelector('.capslock-hint');
259 }, 296 },
260 297
261 /** 298 /**
262 * Gets user sign in button. 299 * Gets user sign in button.
263 * @type {!HTMLButtonElement} 300 * @type {!HTMLButtonElement}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 */ 406 */
370 get lockedIndicatorElement() { 407 get lockedIndicatorElement() {
371 return this.querySelector('.locked-indicator'); 408 return this.querySelector('.locked-indicator');
372 }, 409 },
373 410
374 /** 411 /**
375 * Gets the custom button. This button is normally hidden, but can be shown 412 * Gets the custom button. This button is normally hidden, but can be shown
376 * using the chrome.screenlockPrivate API. 413 * using the chrome.screenlockPrivate API.
377 * @type {!HTMLInputElement} 414 * @type {!HTMLInputElement}
378 */ 415 */
379 get customButton() { 416 get customButtonElement() {
380 return this.querySelector('.custom-button'); 417 return this.querySelector('.custom-button');
381 }, 418 },
382 419
383 /** 420 /**
384 * Updates the user pod element. 421 * Updates the user pod element.
385 */ 422 */
386 update: function() { 423 update: function() {
387 this.imageElement.src = 'chrome://userimage/' + this.user.username + 424 this.imageElement.src = 'chrome://userimage/' + this.user.username +
388 '?id=' + UserPod.userImageSalt_[this.user.username]; 425 '?id=' + UserPod.userImageSalt_[this.user.username];
389 426
390 this.nameElement.textContent = this.user_.displayName; 427 this.nameElement.textContent = this.user_.displayName;
391 this.signedInIndicatorElement.hidden = !this.user_.signedIn; 428 this.signedInIndicatorElement.hidden = !this.user_.signedIn;
392 429
393 var forceOnlineSignin = this.forceOnlineSignin; 430 this.signinButtonElement.hidden = !this.isAuthTypeOnlineSignIn;
394 this.passwordElement.hidden = forceOnlineSignin; 431 this.customButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
395 this.signinButtonElement.hidden = !forceOnlineSignin; 432 if (this.isAuthTypeUserClick) {
433 this.passwordLabelElement.textContent = this.authValue;
434 this.customButtonElement.tabIndex = -1;
435 }
396 436
397 this.updateActionBoxArea(); 437 this.updateActionBoxArea();
398 438
399 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( 439 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF(
400 'passwordFieldAccessibleName', this.user_.emailAddress)); 440 'passwordFieldAccessibleName', this.user_.emailAddress));
401 441
402 this.customizeUserPodPerUserType(); 442 this.customizeUserPodPerUserType();
403 }, 443 },
404 444
405 updateActionBoxArea: function() { 445 updateActionBoxArea: function() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 user_: undefined, 502 user_: undefined,
463 get user() { 503 get user() {
464 return this.user_; 504 return this.user_;
465 }, 505 },
466 set user(userDict) { 506 set user(userDict) {
467 this.user_ = userDict; 507 this.user_ = userDict;
468 this.update(); 508 this.update();
469 }, 509 },
470 510
471 /** 511 /**
472 * Whether this user must authenticate against GAIA.
473 */
474 get forceOnlineSignin() {
475 return this.user.forceOnlineSignin && !this.user.signedIn;
476 },
477
478 /**
479 * Gets main input element. 512 * Gets main input element.
480 * @type {(HTMLButtonElement|HTMLInputElement)} 513 * @type {(HTMLButtonElement|HTMLInputElement)}
481 */ 514 */
482 get mainInput() { 515 get mainInput() {
483 if (!this.signinButtonElement.hidden) 516 if (this.isAuthTypePassword) {
517 return this.passwordElement;
518 } else if (this.isAuthTypeOnlineSignIn) {
484 return this.signinButtonElement; 519 return this.signinButtonElement;
485 else 520 } else if (this.isAuthTypeUserClick) {
486 return this.passwordElement; 521 return this;
522 }
487 }, 523 },
488 524
489 /** 525 /**
490 * Whether action box button is in active state. 526 * Whether action box button is in active state.
491 * @type {boolean} 527 * @type {boolean}
492 */ 528 */
493 get isActionBoxMenuActive() { 529 get isActionBoxMenuActive() {
494 return this.actionBoxAreaElement.classList.contains('active'); 530 return this.actionBoxAreaElement.classList.contains('active');
495 }, 531 },
496 set isActionBoxMenuActive(active) { 532 set isActionBoxMenuActive(active) {
(...skipping 30 matching lines...) Expand all
527 if (hovered) { 563 if (hovered) {
528 this.actionBoxAreaElement.classList.add('hovered'); 564 this.actionBoxAreaElement.classList.add('hovered');
529 this.classList.add('hovered'); 565 this.classList.add('hovered');
530 } else { 566 } else {
531 this.actionBoxAreaElement.classList.remove('hovered'); 567 this.actionBoxAreaElement.classList.remove('hovered');
532 this.classList.remove('hovered'); 568 this.classList.remove('hovered');
533 } 569 }
534 }, 570 },
535 571
536 /** 572 /**
573 * Set the authentication type for the pod.
574 * @param {number} An auth type value defined in the AUTH_TYPE enum.
575 * @param {string} authValue The initial value used for the auth type.
576 */
577 setAuthType: function(authType, authValue) {
578 this.authType_ = authType;
579 this.authValue_ = authValue;
580 this.setAttribute('auth-type', AUTH_TYPE_NAMES[this.authType_]);
581 this.update();
582 this.reset(this.parentNode.isFocused(this));
583 },
584
585 /**
586 * The auth type of the user pod. This value is one of the enum
587 * values in AUTH_TYPE.
588 * @type {number}
589 */
590 get authType() {
591 return this.authType_;
592 },
593
594 /**
595 * The initial value used for the pod's authentication type.
596 * eg. a prepopulated password input when using password authentication.
597 */
598 get authValue() {
599 return this.authValue_;
600 },
601
602 /**
603 * True if the the user pod uses a password to authenticate.
604 * @type {bool}
605 */
606 get isAuthTypePassword() {
607 return this.authType_ == AUTH_TYPE.OFFLINE_PASSWORD;
608 },
609
610 /**
611 * True if the the user pod uses a user click to authenticate.
612 * @type {bool}
613 */
614 get isAuthTypeUserClick() {
615 return this.authType_ == AUTH_TYPE.USER_CLICK;
616 },
617
618 /**
619 * True if the the user pod uses a online sign in to authenticate.
620 * @type {bool}
621 */
622 get isAuthTypeOnlineSignIn() {
623 return this.authType_ == AUTH_TYPE.ONLINE_SIGN_IN;
624 },
625
626 /**
537 * Updates the image element of the user. 627 * Updates the image element of the user.
538 */ 628 */
539 updateUserImage: function() { 629 updateUserImage: function() {
540 UserPod.userImageSalt_[this.user.username] = new Date().getTime(); 630 UserPod.userImageSalt_[this.user.username] = new Date().getTime();
541 this.update(); 631 this.update();
542 }, 632 },
543 633
544 /** 634 /**
545 * Focuses on input element. 635 * Focuses on input element.
546 */ 636 */
547 focusInput: function() { 637 focusInput: function() {
548 var forceOnlineSignin = this.forceOnlineSignin;
549 this.signinButtonElement.hidden = !forceOnlineSignin;
550 this.passwordElement.hidden = forceOnlineSignin;
551
552 // Move tabIndex from the whole pod to the main input. 638 // Move tabIndex from the whole pod to the main input.
639 // Note: the |mainInput| can be the pod itself.
553 this.tabIndex = -1; 640 this.tabIndex = -1;
554 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; 641 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT;
555 this.mainInput.focus(); 642 this.mainInput.focus();
556 }, 643 },
557 644
558 /** 645 /**
559 * Activates the pod. 646 * Activates the pod.
560 * @param {Event} e Event object. 647 * @param {Event} e Event object.
561 * @return {boolean} True if activated successfully. 648 * @return {boolean} True if activated successfully.
562 */ 649 */
563 activate: function(e) { 650 activate: function(e) {
564 if (this.forceOnlineSignin) { 651 if (this.isAuthTypeOnlineSignIn) {
565 this.showSigninUI(); 652 this.showSigninUI();
566 } else if (!this.passwordElement.value) { 653 } else if (this.isAuthTypeUserClick) {
567 return false; 654 Oobe.disableSigninUI();
568 } else { 655 chrome.send('authenticateUser', [this.user.username, '']);
656 } else if (this.isAuthTypePassword) {
657 if (!this.passwordElement.value)
658 return false;
569 Oobe.disableSigninUI(); 659 Oobe.disableSigninUI();
570 chrome.send('authenticateUser', 660 chrome.send('authenticateUser',
571 [this.user.username, this.passwordElement.value]); 661 [this.user.username, this.passwordElement.value]);
662 } else {
663 console.error('Activating user pod with invalid authentication type: ' +
664 this.authType);
572 } 665 }
573 666
574 return true; 667 return true;
575 }, 668 },
576 669
577 showSupervisedUserSigninWarning: function() { 670 showSupervisedUserSigninWarning: function() {
578 // Locally managed user token has been invalidated. 671 // Locally managed user token has been invalidated.
579 // Make sure that pod is focused i.e. "Sign in" button is seen. 672 // Make sure that pod is focused i.e. "Sign in" button is seen.
580 this.parentNode.focusPod(this); 673 this.parentNode.focusPod(this);
581 674
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 }, 824 },
732 825
733 /** 826 /**
734 * Handles click event on a user pod. 827 * Handles click event on a user pod.
735 * @param {Event} e Click event. 828 * @param {Event} e Click event.
736 */ 829 */
737 handleClickOnPod_: function(e) { 830 handleClickOnPod_: function(e) {
738 if (this.parentNode.disabled) 831 if (this.parentNode.disabled)
739 return; 832 return;
740 833
741 if (this.forceOnlineSignin && !this.isActionBoxMenuActive) { 834 if (!this.isActionBoxMenuActive) {
742 this.showSigninUI(); 835 if (this.isAuthTypeOnlineSignIn) {
836 this.showSigninUI();
837 } else if (this.isAuthTypeUserClick) {
838 this.parentNode.setActivatedPod(this);
839 }
840
743 // Prevent default so that we don't trigger 'focus' event. 841 // Prevent default so that we don't trigger 'focus' event.
744 e.preventDefault(); 842 e.preventDefault();
745 } 843 }
746 }, 844 },
747 845
748 /** 846 /**
847 * Handles keydown event for a user pod.
848 * @param {Event} e Key event.
849 */
850 handlePodKeyDown_: function(e) {
851 if (!this.isAuthTypeUserClick || this.disabled)
852 return;
853 switch (e.keyIdentifier) {
854 case 'Enter':
855 case 'U+0020': // Space
856 if (this.parentNode.isFocused(this))
857 this.parentNode.setActivatedPod(this);
858 break;
859 }
860 },
861
862 /**
749 * Called when the custom button is clicked. 863 * Called when the custom button is clicked.
750 */ 864 */
751 handleCustomButtonClick_: function() { 865 handleCustomButtonClick_: function() {
752 chrome.send('customButtonClicked', [this.user.username]); 866 chrome.send('customButtonClicked', [this.user.username]);
753 } 867 }
754 }; 868 };
755 869
756 /** 870 /**
757 * Creates a public account user pod. 871 * Creates a public account user pod.
758 * @constructor 872 * @constructor
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 920
807 // Accessibility focus indicator does not move with the focused 921 // Accessibility focus indicator does not move with the focused
808 // element. Sends a 'focus' event on the currently focused element 922 // element. Sends a 'focus' event on the currently focused element
809 // so that accessibility focus indicator updates its location. 923 // so that accessibility focus indicator updates its location.
810 if (document.activeElement) 924 if (document.activeElement)
811 document.activeElement.dispatchEvent(new Event('focus')); 925 document.activeElement.dispatchEvent(new Event('focus'));
812 }); 926 });
813 }, 927 },
814 928
815 /** @override */ 929 /** @override */
816 get forceOnlineSignin() {
817 return false;
818 },
819
820 /** @override */
821 get mainInput() { 930 get mainInput() {
822 if (this.expanded) 931 if (this.expanded)
823 return this.enterButtonElement; 932 return this.enterButtonElement;
824 else 933 else
825 return this.nameElement; 934 return this.nameElement;
826 }, 935 },
827 936
828 /** @override */ 937 /** @override */
829 decorate: function() { 938 decorate: function() {
830 UserPod.prototype.decorate.call(this); 939 UserPod.prototype.decorate.call(this);
(...skipping 20 matching lines...) Expand all
851 learnMore = this.querySelector('.side-pane-learn-more'); 960 learnMore = this.querySelector('.side-pane-learn-more');
852 learnMore.addEventListener('click', this.handleLearnMoreEvent); 961 learnMore.addEventListener('click', this.handleLearnMoreEvent);
853 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); 962 learnMore.addEventListener('keydown', this.handleLearnMoreEvent);
854 963
855 this.enterButtonElement.addEventListener('click', (function(e) { 964 this.enterButtonElement.addEventListener('click', (function(e) {
856 this.enterButtonElement.disabled = true; 965 this.enterButtonElement.disabled = true;
857 chrome.send('launchPublicAccount', [this.user.username]); 966 chrome.send('launchPublicAccount', [this.user.username]);
858 }).bind(this)); 967 }).bind(this));
859 }, 968 },
860 969
861 /** 970 /** @override **/
862 * Updates the user pod element.
863 */
864 update: function() { 971 update: function() {
865 UserPod.prototype.update.call(this); 972 UserPod.prototype.update.call(this);
866 this.querySelector('.side-pane-name').textContent = 973 this.querySelector('.side-pane-name').textContent =
867 this.user_.displayName; 974 this.user_.displayName;
868 this.querySelector('.info').textContent = 975 this.querySelector('.info').textContent =
869 loadTimeData.getStringF('publicAccountInfoFormat', 976 loadTimeData.getStringF('publicAccountInfoFormat',
870 this.user_.enterpriseDomain); 977 this.user_.enterpriseDomain);
871 }, 978 },
872 979
873 /** @override */ 980 /** @override */
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 * @param {string} iconURL URL of the button icon 1584 * @param {string} iconURL URL of the button icon
1478 */ 1585 */
1479 showUserPodButton: function(username, iconURL) { 1586 showUserPodButton: function(username, iconURL) {
1480 var pod = this.getPodWithUsername_(username); 1587 var pod = this.getPodWithUsername_(username);
1481 if (pod == null) { 1588 if (pod == null) {
1482 console.error('Unable to show user pod button for ' + username + 1589 console.error('Unable to show user pod button for ' + username +
1483 ': user pod not found.'); 1590 ': user pod not found.');
1484 return; 1591 return;
1485 } 1592 }
1486 1593
1487 pod.customButton.hidden = false; 1594 pod.customButtonElement.hidden = false;
1488 var icon = 1595 var icon =
1489 pod.customButton.querySelector('.custom-button-icon'); 1596 pod.customButtonElement.querySelector('.custom-button-icon');
1490 icon.src = iconURL; 1597 icon.src = iconURL;
1491 }, 1598 },
1492 1599
1493 /** 1600 /**
1601 * Hides button from user pod added by showUserPodButton().
1602 * @param {string} username Username of pod to remove button
1603 */
1604 hideUserPodButton: function(username) {
1605 var pod = this.getPodWithUsername_(username);
1606 if (pod == null) {
1607 console.error('Unable to hide user pod button for ' + username +
1608 ': user pod not found.');
1609 return;
1610 }
1611
1612 pod.customButtonElement.hidden = true;
1613 },
1614
1615 /**
1616 * Sets the authentication type used to authenticate the user.
1617 * @param {string} username Username of selected user
1618 * @param {number} authType Authentication type, must be one of the
1619 * values listed in AUTH_TYPE enum.
1620 * @param {string} value The initial value to use for authentication.
1621 */
1622 setAuthType: function(username, authType, value) {
1623 var pod = this.getPodWithUsername_(username);
1624 if (pod == null) {
1625 console.error('Unable to set auth type for ' + username +
1626 ': user pod not found.');
1627 return;
1628 }
1629 pod.setAuthType(authType, value);
1630 },
1631
1632 /**
1494 * Called when window was resized. 1633 * Called when window was resized.
1495 */ 1634 */
1496 onWindowResize: function() { 1635 onWindowResize: function() {
1497 var layout = this.calculateLayout_(); 1636 var layout = this.calculateLayout_();
1498 if (layout.columns != this.columns || layout.rows != this.rows) 1637 if (layout.columns != this.columns || layout.rows != this.rows)
1499 this.placePods_(); 1638 this.placePods_();
1500 }, 1639 },
1501 1640
1502 /** 1641 /**
1503 * Returns width of podrow having |columns| number of columns. 1642 * Returns width of podrow having |columns| number of columns.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 * Updates current image of a user. 1917 * Updates current image of a user.
1779 * @param {string} username User for which to update the image. 1918 * @param {string} username User for which to update the image.
1780 */ 1919 */
1781 updateUserImage: function(username) { 1920 updateUserImage: function(username) {
1782 var pod = this.getPodWithUsername_(username); 1921 var pod = this.getPodWithUsername_(username);
1783 if (pod) 1922 if (pod)
1784 pod.updateUserImage(); 1923 pod.updateUserImage();
1785 }, 1924 },
1786 1925
1787 /** 1926 /**
1788 * Indicates that the given user must authenticate against GAIA during the
1789 * next sign-in.
1790 * @param {string} username User for whom to enforce GAIA sign-in.
1791 */
1792 forceOnlineSigninForUser: function(username) {
1793 var pod = this.getPodWithUsername_(username);
1794 if (pod) {
1795 pod.user.forceOnlineSignin = true;
1796 pod.update();
1797 } else {
1798 console.log('Failed to update GAIA state for: ' + username);
1799 }
1800 },
1801
1802 /**
1803 * Handler of click event. 1927 * Handler of click event.
1804 * @param {Event} e Click Event object. 1928 * @param {Event} e Click Event object.
1805 * @private 1929 * @private
1806 */ 1930 */
1807 handleClick_: function(e) { 1931 handleClick_: function(e) {
1808 if (this.disabled) 1932 if (this.disabled)
1809 return; 1933 return;
1810 1934
1811 // Clear all menus if the click is outside pod menu and its 1935 // Clear all menus if the click is outside pod menu and its
1812 // button area. 1936 // button area.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 if (this.podsWithPendingImages_.length == 0) { 2138 if (this.podsWithPendingImages_.length == 0) {
2015 this.classList.remove('images-loading'); 2139 this.classList.remove('images-loading');
2016 } 2140 }
2017 } 2141 }
2018 }; 2142 };
2019 2143
2020 return { 2144 return {
2021 PodRow: PodRow 2145 PodRow: PodRow
2022 }; 2146 };
2023 }); 2147 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698