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

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: 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 * @enum {number} 71 * @enum {number}
72 * @const 72 * @const
73 */ 73 */
74 var UserPodTabOrder = { 74 var UserPodTabOrder = {
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 /**
82 * Supported authentication types. Keep in sync with the enum in
83 * chrome/browser/chromeos/login/login_display.h
84 * @enum {number}
85 * @const
86 */
87 var AUTH_TYPE = {
88 SYSTEM_PASSWORD: 0,
89 ONLINE_SIGN_IN: 1,
90 NUMERIC_PIN: 2,
91 USER_CLICK: 3,
92 };
93
94 /**
95 * Names of authentication types.
96 */
97 var AUTH_TYPE_NAMES = {
98 0: 'systemPassword',
99 1: 'onlineSignIn',
100 2: 'numericPin',
101 3: 'userClick',
102 };
103
81 // Focus and tab order are organized as follows: 104 // Focus and tab order are organized as follows:
82 // 105 //
83 // (1) all user pods have tab index 1 so they are traversed first; 106 // (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 107 // (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; 108 // 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; 109 // (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; 110 // (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. 111 // (5) lastly, focus jumps to the Status Area and back to user pods.
89 // 112 //
90 // 'Focus' event is handled by a capture handler for the whole document 113 // 'Focus' event is handled by a capture handler for the whole document
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * @type {Object} 150 * @type {Object}
128 */ 151 */
129 UserPod.userImageSalt_ = {}; 152 UserPod.userImageSalt_ = {};
130 153
131 UserPod.prototype = { 154 UserPod.prototype = {
132 __proto__: HTMLDivElement.prototype, 155 __proto__: HTMLDivElement.prototype,
133 156
134 /** @override */ 157 /** @override */
135 decorate: function() { 158 decorate: function() {
136 this.tabIndex = UserPodTabOrder.POD_INPUT; 159 this.tabIndex = UserPodTabOrder.POD_INPUT;
137 this.customButton.tabIndex = UserPodTabOrder.POD_INPUT; 160 this.customButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
138 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.ACTION_BOX; 161 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.ACTION_BOX;
139 162
140 this.addEventListener('click', 163 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this));
141 this.handleClickOnPod_.bind(this)); 164 this.addEventListener('click', this.handleClickOnPod_.bind(this));
142 165
143 this.signinButtonElement.addEventListener('click', 166 this.signinButtonElement.addEventListener('click',
144 this.activate.bind(this)); 167 this.activate.bind(this));
145 168
146 this.actionBoxAreaElement.addEventListener('mousedown', 169 this.actionBoxAreaElement.addEventListener('mousedown',
147 stopEventPropagation); 170 stopEventPropagation);
148 this.actionBoxAreaElement.addEventListener('click', 171 this.actionBoxAreaElement.addEventListener('click',
149 this.handleActionAreaButtonClick_.bind(this)); 172 this.handleActionAreaButtonClick_.bind(this));
150 this.actionBoxAreaElement.addEventListener('keydown', 173 this.actionBoxAreaElement.addEventListener('keydown',
151 this.handleActionAreaButtonKeyDown_.bind(this)); 174 this.handleActionAreaButtonKeyDown_.bind(this));
152 175
153 this.actionBoxMenuRemoveElement.addEventListener('click', 176 this.actionBoxMenuRemoveElement.addEventListener('click',
154 this.handleRemoveCommandClick_.bind(this)); 177 this.handleRemoveCommandClick_.bind(this));
155 this.actionBoxMenuRemoveElement.addEventListener('keydown', 178 this.actionBoxMenuRemoveElement.addEventListener('keydown',
156 this.handleRemoveCommandKeyDown_.bind(this)); 179 this.handleRemoveCommandKeyDown_.bind(this));
157 this.actionBoxMenuRemoveElement.addEventListener('blur', 180 this.actionBoxMenuRemoveElement.addEventListener('blur',
158 this.handleRemoveCommandBlur_.bind(this)); 181 this.handleRemoveCommandBlur_.bind(this));
159 182
160 if (this.actionBoxRemoveUserWarningButtonElement) { 183 if (this.actionBoxRemoveUserWarningButtonElement) {
161 this.actionBoxRemoveUserWarningButtonElement.addEventListener( 184 this.actionBoxRemoveUserWarningButtonElement.addEventListener(
162 'click', 185 'click',
163 this.handleRemoveUserConfirmationClick_.bind(this)); 186 this.handleRemoveUserConfirmationClick_.bind(this));
164 } 187 }
165 188
166 this.customButton.addEventListener('click', 189 this.customButtonElement.addEventListener('click',
167 this.handleCustomButtonClick_.bind(this)); 190 this.handleCustomButtonClick_.bind(this));
168 }, 191 },
169 192
170 /** 193 /**
171 * Initializes the pod after its properties set and added to a pod row. 194 * Initializes the pod after its properties set and added to a pod row.
172 */ 195 */
173 initialize: function() { 196 initialize: function() {
174 this.passwordElement.addEventListener('keydown', 197 this.passwordElement.addEventListener('keydown',
175 this.parentNode.handleKeyDown.bind(this.parentNode)); 198 this.parentNode.handleKeyDown.bind(this.parentNode));
176 this.passwordElement.addEventListener('keypress', 199 this.passwordElement.addEventListener('keypress',
177 this.handlePasswordKeyPress_.bind(this)); 200 this.handlePasswordKeyPress_.bind(this));
178 201
179 this.imageElement.addEventListener('load', 202 this.imageElement.addEventListener('load',
180 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); 203 this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
204
205 var initialAuthType = this.user.initialAuthType ?
206 this.user.initialAuthType : AUTH_TYPE.SYSTEM_PASSWORD;
xiyuan 2014/02/16 18:38:14 nit: var initialAuthType = this.user.initialAuthTy
Tim Song 2014/02/18 23:32:44 Done.
207 this.setAuthType(initialAuthType, null);
181 }, 208 },
182 209
183 /** 210 /**
184 * Resets tab order for pod elements to its initial state. 211 * Resets tab order for pod elements to its initial state.
185 */ 212 */
186 resetTabOrder: function() { 213 resetTabOrder: function() {
214 // Note: the |mainInput| can be the pod itself.
215 this.mainInput.tabIndex = -1;
187 this.tabIndex = UserPodTabOrder.POD_INPUT; 216 this.tabIndex = UserPodTabOrder.POD_INPUT;
188 this.mainInput.tabIndex = -1;
189 }, 217 },
190 218
191 /** 219 /**
192 * Handles keypress event (i.e. any textual input) on password input. 220 * Handles keypress event (i.e. any textual input) on password input.
193 * @param {Event} e Keypress Event object. 221 * @param {Event} e Keypress Event object.
194 * @private 222 * @private
195 */ 223 */
196 handlePasswordKeyPress_: function(e) { 224 handlePasswordKeyPress_: function(e) {
197 // When tabbing from the system tray a tab key press is received. Suppress 225 // When tabbing from the system tray a tab key press is received. Suppress
198 // this so as not to type a tab character into the password field. 226 // 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
243 271
244 /** 272 /**
245 * Gets password field. 273 * Gets password field.
246 * @type {!HTMLInputElement} 274 * @type {!HTMLInputElement}
247 */ 275 */
248 get passwordElement() { 276 get passwordElement() {
249 return this.querySelector('.password'); 277 return this.querySelector('.password');
250 }, 278 },
251 279
252 /** 280 /**
281 * Gets the password label, which is used to show a message where the
282 * password field is normally.
283 * @type {!HTMLInputElement}
284 */
285 get passwordLabelElement() {
286 return this.querySelector('.password-label');
287 },
288
289 /**
253 * Gets Caps Lock hint image. 290 * Gets Caps Lock hint image.
254 * @type {!HTMLImageElement} 291 * @type {!HTMLImageElement}
255 */ 292 */
256 get capslockHintElement() { 293 get capslockHintElement() {
257 return this.querySelector('.capslock-hint'); 294 return this.querySelector('.capslock-hint');
258 }, 295 },
259 296
260 /** 297 /**
261 * Gets user sign in button. 298 * Gets user sign in button.
262 * @type {!HTMLButtonElement} 299 * @type {!HTMLButtonElement}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 */ 405 */
369 get lockedIndicatorElement() { 406 get lockedIndicatorElement() {
370 return this.querySelector('.locked-indicator'); 407 return this.querySelector('.locked-indicator');
371 }, 408 },
372 409
373 /** 410 /**
374 * Gets the custom button. This button is normally hidden, but can be shown 411 * Gets the custom button. This button is normally hidden, but can be shown
375 * using the chrome.screenlockPrivate API. 412 * using the chrome.screenlockPrivate API.
376 * @type {!HTMLInputElement} 413 * @type {!HTMLInputElement}
377 */ 414 */
378 get customButton() { 415 get customButtonElement() {
379 return this.querySelector('.custom-button'); 416 return this.querySelector('.custom-button');
380 }, 417 },
381 418
382 /** 419 /**
383 * Updates the user pod element. 420 * Updates the user pod element.
384 */ 421 */
385 update: function() { 422 update: function() {
386 this.imageElement.src = 'chrome://userimage/' + this.user.username + 423 this.imageElement.src = 'chrome://userimage/' + this.user.username +
387 '?id=' + UserPod.userImageSalt_[this.user.username]; 424 '?id=' + UserPod.userImageSalt_[this.user.username];
388 425
389 this.nameElement.textContent = this.user_.displayName; 426 this.nameElement.textContent = this.user_.displayName;
390 this.signedInIndicatorElement.hidden = !this.user_.signedIn; 427 this.signedInIndicatorElement.hidden = !this.user_.signedIn;
391 428
392 var forceOnlineSignin = this.forceOnlineSignin; 429 this.customButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
393 this.passwordElement.hidden = forceOnlineSignin; 430 if (this.isAuthTypeUserClick) {
394 this.signinButtonElement.hidden = !forceOnlineSignin; 431 this.passwordLabelElement.textContent = this.authValue;
432 this.customButtonElement.tabIndex = -1;
433 }
395 434
396 this.updateActionBoxArea(); 435 this.updateActionBoxArea();
397 436
398 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( 437 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF(
399 'passwordFieldAccessibleName', this.user_.emailAddress)); 438 'passwordFieldAccessibleName', this.user_.emailAddress));
400 439
401 this.customizeUserPodPerUserType(); 440 this.customizeUserPodPerUserType();
402 }, 441 },
403 442
404 updateActionBoxArea: function() { 443 updateActionBoxArea: function() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 user_: undefined, 500 user_: undefined,
462 get user() { 501 get user() {
463 return this.user_; 502 return this.user_;
464 }, 503 },
465 set user(userDict) { 504 set user(userDict) {
466 this.user_ = userDict; 505 this.user_ = userDict;
467 this.update(); 506 this.update();
468 }, 507 },
469 508
470 /** 509 /**
471 * Whether this user must authenticate against GAIA.
472 */
473 get forceOnlineSignin() {
474 return this.user.forceOnlineSignin && !this.user.signedIn;
475 },
476
477 /**
478 * Gets main input element. 510 * Gets main input element.
479 * @type {(HTMLButtonElement|HTMLInputElement)} 511 * @type {(HTMLButtonElement|HTMLInputElement)}
480 */ 512 */
481 get mainInput() { 513 get mainInput() {
482 if (!this.signinButtonElement.hidden) 514 if (this.isAuthTypePassword) {
515 return this.passwordElement.hidden ?
516 this.nameElement : this.passwordElement;
517 } else if (this.isAuthTypeOnlineSignIn) {
483 return this.signinButtonElement; 518 return this.signinButtonElement;
484 else 519 } else if (this.isAuthTypeUserClick) {
485 return this.passwordElement; 520 return this;
521 }
486 }, 522 },
487 523
488 /** 524 /**
489 * Whether action box button is in active state. 525 * Whether action box button is in active state.
490 * @type {boolean} 526 * @type {boolean}
491 */ 527 */
492 get isActionBoxMenuActive() { 528 get isActionBoxMenuActive() {
493 return this.actionBoxAreaElement.classList.contains('active'); 529 return this.actionBoxAreaElement.classList.contains('active');
494 }, 530 },
495 set isActionBoxMenuActive(active) { 531 set isActionBoxMenuActive(active) {
(...skipping 30 matching lines...) Expand all
526 if (hovered) { 562 if (hovered) {
527 this.actionBoxAreaElement.classList.add('hovered'); 563 this.actionBoxAreaElement.classList.add('hovered');
528 this.classList.add('hovered'); 564 this.classList.add('hovered');
529 } else { 565 } else {
530 this.actionBoxAreaElement.classList.remove('hovered'); 566 this.actionBoxAreaElement.classList.remove('hovered');
531 this.classList.remove('hovered'); 567 this.classList.remove('hovered');
532 } 568 }
533 }, 569 },
534 570
535 /** 571 /**
572 * Set the authentication type for the pod.
573 * @param {number} An auth type value defined in the AUTH_TYPE enum.
574 * @param {string} authValue The initial value used for the auth type.
575 */
576 setAuthType: function(authType, authValue) {
577 this.authType_ = authType;
578 this.authValue_ = authValue;
579 this.setAttribute('auth-type', AUTH_TYPE_NAMES[this.authType_]);
580 this.update();
581 this.reset(this.parentNode.isFocused(this));
582 },
583
584 /**
585 * The auth type of the user pod. This value is one of the enum
586 * values in AUTH_TYPE.
587 * @type {number}
588 */
589 get authType() {
590 return this.authType_;
591 },
592
593 /**
594 * The initial value used for the pod's authentication type.
595 * eg. a prepopulated password input when using password authentication.
596 */
597 get authValue() {
598 return this.authValue_;
599 },
600
601 /**
602 * True if the the user pod uses a password to authenticate.
603 * @type {bool}
604 */
605 get isAuthTypePassword() {
606 return this.authType_ == AUTH_TYPE.SYSTEM_PASSWORD;
607 },
608
609 /**
610 * True if the the user pod uses a user click to authenticate.
611 * @type {bool}
612 */
613 get isAuthTypeUserClick() {
614 return this.authType_ == AUTH_TYPE.USER_CLICK;
615 },
616
617 /**
618 * True if the the user pod uses a online sign in to authenticate.
619 * @type {bool}
620 */
621 get isAuthTypeOnlineSignIn() {
622 return this.authType_ == AUTH_TYPE.ONLINE_SIGN_IN;
623 },
624
625 /**
536 * Updates the image element of the user. 626 * Updates the image element of the user.
537 */ 627 */
538 updateUserImage: function() { 628 updateUserImage: function() {
539 UserPod.userImageSalt_[this.user.username] = new Date().getTime(); 629 UserPod.userImageSalt_[this.user.username] = new Date().getTime();
540 this.update(); 630 this.update();
541 }, 631 },
542 632
543 /** 633 /**
544 * Focuses on input element. 634 * Focuses on input element.
545 */ 635 */
546 focusInput: function() { 636 focusInput: function() {
547 var forceOnlineSignin = this.forceOnlineSignin;
548 this.signinButtonElement.hidden = !forceOnlineSignin;
549 this.passwordElement.hidden = forceOnlineSignin;
550
551 // Move tabIndex from the whole pod to the main input. 637 // Move tabIndex from the whole pod to the main input.
638 // Note: the |mainInput| can be the pod itself.
552 this.tabIndex = -1; 639 this.tabIndex = -1;
553 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; 640 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT;
554 this.mainInput.focus(); 641 this.mainInput.focus();
555 }, 642 },
556 643
557 /** 644 /**
558 * Activates the pod. 645 * Activates the pod.
559 * @param {Event} e Event object. 646 * @param {Event} e Event object.
560 * @return {boolean} True if activated successfully. 647 * @return {boolean} True if activated successfully.
561 */ 648 */
562 activate: function(e) { 649 activate: function(e) {
563 if (this.forceOnlineSignin) { 650 if (this.isAuthTypeOnlineSignIn) {
564 this.showSigninUI(); 651 this.showSigninUI();
565 } else if (!this.passwordElement.value) { 652 } else if (this.isAuthTypeUserClick) {
566 return false; 653 chrome.send('authenticateUser',
567 } else { 654 [this.user.username, '']);
655 } else if (this.isAuthTypePassword) {
656 if (!this.passwordElement.value)
657 return false;
568 Oobe.disableSigninUI(); 658 Oobe.disableSigninUI();
569 chrome.send('authenticateUser', 659 chrome.send('authenticateUser',
570 [this.user.username, this.passwordElement.value]); 660 [this.user.username, this.passwordElement.value]);
661 } else {
662 console.error('Activating user pod with invalid authentication type: ' +
663 this.authType);
571 } 664 }
572 665
573 return true; 666 return true;
574 }, 667 },
575 668
576 showSupervisedUserSigninWarning: function() { 669 showSupervisedUserSigninWarning: function() {
577 // Locally managed user token has been invalidated. 670 // Locally managed user token has been invalidated.
578 // Make sure that pod is focused i.e. "Sign in" button is seen. 671 // Make sure that pod is focused i.e. "Sign in" button is seen.
579 this.parentNode.focusPod(this); 672 this.parentNode.focusPod(this);
580 673
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 }, 823 },
731 824
732 /** 825 /**
733 * Handles click event on a user pod. 826 * Handles click event on a user pod.
734 * @param {Event} e Click event. 827 * @param {Event} e Click event.
735 */ 828 */
736 handleClickOnPod_: function(e) { 829 handleClickOnPod_: function(e) {
737 if (this.parentNode.disabled) 830 if (this.parentNode.disabled)
738 return; 831 return;
739 832
740 if (this.forceOnlineSignin && !this.isActionBoxMenuActive) { 833 if (!this.isActionBoxMenuActive) {
741 this.showSigninUI(); 834 if (this.isAuthTypeOnlineSignIn) {
835 this.showSigninUI();
836 } else if (this.isAuthTypeUserClick) {
837 this.parentNode.setActivatedPod(this);
838 }
839
742 // Prevent default so that we don't trigger 'focus' event. 840 // Prevent default so that we don't trigger 'focus' event.
743 e.preventDefault(); 841 e.preventDefault();
744 } 842 }
745 }, 843 },
746 844
747 /** 845 /**
846 * Handles keydown event for a user pod.
847 * @param {Event} e Key event.
848 */
849 handlePodKeyDown_: function(e) {
850 if (!this.isAuthTypeUserClick || this.disabled)
851 return;
852 switch (e.keyIdentifier) {
853 case 'Enter':
854 case 'U+0020': // Space
855 if (this.parentNode.isFocused(this))
856 this.parentNode.setActivatedPod(this);
857 break;
858 }
859 },
860
861 /**
748 * Called when the custom button is clicked. 862 * Called when the custom button is clicked.
749 */ 863 */
750 handleCustomButtonClick_: function() { 864 handleCustomButtonClick_: function() {
751 chrome.send('customButtonClicked', [this.user.username]); 865 chrome.send('customButtonClicked', [this.user.username]);
752 } 866 }
753 }; 867 };
754 868
755 /** 869 /**
756 * Creates a public account user pod. 870 * Creates a public account user pod.
757 * @constructor 871 * @constructor
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 919
806 // Accessibility focus indicator does not move with the focused 920 // Accessibility focus indicator does not move with the focused
807 // element. Sends a 'focus' event on the currently focused element 921 // element. Sends a 'focus' event on the currently focused element
808 // so that accessibility focus indicator updates its location. 922 // so that accessibility focus indicator updates its location.
809 if (document.activeElement) 923 if (document.activeElement)
810 document.activeElement.dispatchEvent(new Event('focus')); 924 document.activeElement.dispatchEvent(new Event('focus'));
811 }); 925 });
812 }, 926 },
813 927
814 /** @override */ 928 /** @override */
815 get forceOnlineSignin() {
816 return false;
817 },
818
819 /** @override */
820 get mainInput() { 929 get mainInput() {
821 if (this.expanded) 930 if (this.expanded)
822 return this.enterButtonElement; 931 return this.enterButtonElement;
823 else 932 else
824 return this.nameElement; 933 return this.nameElement;
825 }, 934 },
826 935
827 /** @override */ 936 /** @override */
828 decorate: function() { 937 decorate: function() {
829 UserPod.prototype.decorate.call(this); 938 UserPod.prototype.decorate.call(this);
(...skipping 20 matching lines...) Expand all
850 learnMore = this.querySelector('.side-pane-learn-more'); 959 learnMore = this.querySelector('.side-pane-learn-more');
851 learnMore.addEventListener('click', this.handleLearnMoreEvent); 960 learnMore.addEventListener('click', this.handleLearnMoreEvent);
852 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); 961 learnMore.addEventListener('keydown', this.handleLearnMoreEvent);
853 962
854 this.enterButtonElement.addEventListener('click', (function(e) { 963 this.enterButtonElement.addEventListener('click', (function(e) {
855 this.enterButtonElement.disabled = true; 964 this.enterButtonElement.disabled = true;
856 chrome.send('launchPublicAccount', [this.user.username]); 965 chrome.send('launchPublicAccount', [this.user.username]);
857 }).bind(this)); 966 }).bind(this));
858 }, 967 },
859 968
860 /** 969 /** @override **/
861 * Updates the user pod element.
862 */
863 update: function() { 970 update: function() {
864 UserPod.prototype.update.call(this); 971 UserPod.prototype.update.call(this);
865 this.querySelector('.side-pane-name').textContent = 972 this.querySelector('.side-pane-name').textContent =
866 this.user_.displayName; 973 this.user_.displayName;
867 this.querySelector('.info').textContent = 974 this.querySelector('.info').textContent =
868 loadTimeData.getStringF('publicAccountInfoFormat', 975 loadTimeData.getStringF('publicAccountInfoFormat',
869 this.user_.enterpriseDomain); 976 this.user_.enterpriseDomain);
870 }, 977 },
871 978
872 /** @override */ 979 /** @override */
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 * @param {string} iconURL URL of the button icon 1542 * @param {string} iconURL URL of the button icon
1436 */ 1543 */
1437 showUserPodButton: function(username, iconURL) { 1544 showUserPodButton: function(username, iconURL) {
1438 var pod = this.getPodWithUsername_(username); 1545 var pod = this.getPodWithUsername_(username);
1439 if (pod == null) { 1546 if (pod == null) {
1440 console.error('Unable to show user pod button for ' + username + 1547 console.error('Unable to show user pod button for ' + username +
1441 ': user pod not found.'); 1548 ': user pod not found.');
1442 return; 1549 return;
1443 } 1550 }
1444 1551
1445 pod.customButton.hidden = false; 1552 pod.customButtonElement.hidden = false;
1446 var icon = 1553 var icon =
1447 pod.customButton.querySelector('.custom-button-icon'); 1554 pod.customButtonElement.querySelector('.custom-button-icon');
1448 icon.src = iconURL; 1555 icon.src = iconURL;
1449 }, 1556 },
1450 1557
1451 /** 1558 /**
1559 * Hides button from user pod added by showUserPodButton().
1560 * @param {string} username Username of pod to remove button
1561 */
1562 hideUserPodButton: function(username) {
1563 var pod = this.getPodWithUsername_(username);
1564 if (pod == null) {
1565 console.error('Unable to hide user pod button for ' + username +
1566 ': user pod not found.');
1567 return;
1568 }
1569
1570 pod.customButtonElement.hidden = true;
1571 },
1572
1573 /**
1574 * Sets the authentication type used to authenticate the user.
1575 * @param {string} username Username of selected user
1576 * @param {number} authType Authentication type, must be one of the
1577 * values listed in AUTH_TYPE enum.
1578 * @param {string} value The initial value to use for authentication.
1579 */
1580 setAuthType: function(username, authType, value) {
1581 var pod = this.getPodWithUsername_(username);
1582 if (pod == null) {
1583 console.error('Unable to set auth type for ' + username +
1584 ': user pod not found.');
1585 return;
1586 }
1587 pod.setAuthType(authType, value);
1588 },
1589
1590 /**
1452 * Called when window was resized. 1591 * Called when window was resized.
1453 */ 1592 */
1454 onWindowResize: function() { 1593 onWindowResize: function() {
1455 var layout = this.calculateLayout_(); 1594 var layout = this.calculateLayout_();
1456 if (layout.columns != this.columns || layout.rows != this.rows) 1595 if (layout.columns != this.columns || layout.rows != this.rows)
1457 this.placePods_(); 1596 this.placePods_();
1458 }, 1597 },
1459 1598
1460 /** 1599 /**
1461 * Returns width of podrow having |columns| number of columns. 1600 * Returns width of podrow having |columns| number of columns.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 * Updates current image of a user. 1868 * Updates current image of a user.
1730 * @param {string} username User for which to update the image. 1869 * @param {string} username User for which to update the image.
1731 */ 1870 */
1732 updateUserImage: function(username) { 1871 updateUserImage: function(username) {
1733 var pod = this.getPodWithUsername_(username); 1872 var pod = this.getPodWithUsername_(username);
1734 if (pod) 1873 if (pod)
1735 pod.updateUserImage(); 1874 pod.updateUserImage();
1736 }, 1875 },
1737 1876
1738 /** 1877 /**
1739 * Indicates that the given user must authenticate against GAIA during the
1740 * next sign-in.
1741 * @param {string} username User for whom to enforce GAIA sign-in.
1742 */
1743 forceOnlineSigninForUser: function(username) {
1744 var pod = this.getPodWithUsername_(username);
1745 if (pod) {
1746 pod.user.forceOnlineSignin = true;
1747 pod.update();
1748 } else {
1749 console.log('Failed to update GAIA state for: ' + username);
1750 }
1751 },
1752
1753 /**
1754 * Handler of click event. 1878 * Handler of click event.
1755 * @param {Event} e Click Event object. 1879 * @param {Event} e Click Event object.
1756 * @private 1880 * @private
1757 */ 1881 */
1758 handleClick_: function(e) { 1882 handleClick_: function(e) {
1759 if (this.disabled) 1883 if (this.disabled)
1760 return; 1884 return;
1761 1885
1762 // Clear all menus if the click is outside pod menu and its 1886 // Clear all menus if the click is outside pod menu and its
1763 // button area. 1887 // button area.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 if (this.podsWithPendingImages_.length == 0) { 2083 if (this.podsWithPendingImages_.length == 0) {
1960 this.classList.remove('images-loading'); 2084 this.classList.remove('images-loading');
1961 } 2085 }
1962 } 2086 }
1963 }; 2087 };
1964 2088
1965 return { 2089 return {
1966 PodRow: PodRow 2090 PodRow: PodRow
1967 }; 2091 };
1968 }); 2092 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698