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

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: move screenlockPrivate stuff to other CL 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 OFFLINE_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: 'offlinePassword',
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 AUTH_TYPE.OFFLINE_PASSWORD;
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;
Nikita (slow) 2014/02/20 15:12:18 When you return this.nameElement, how does it work
Tim Song 2014/02/20 22:14:01 Now that I think about it, the name element should
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.OFFLINE_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.
Nikita (slow) 2014/02/20 15:12:18 Not the pod itself but nameElement?
Tim Song 2014/02/20 22:14:01 In the mocks, the entire pod is clickable, so I th
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 Oobe.disableSigninUI();
567 } else { 654 chrome.send('authenticateUser',
655 [this.user.username, '']);
Nikita (slow) 2014/02/20 15:12:18 nit: Fits on a single line?
Tim Song 2014/02/20 22:14:01 Done.
656 } else if (this.isAuthTypePassword) {
657 if (!this.passwordElement.value)
658 return false;
568 Oobe.disableSigninUI(); 659 Oobe.disableSigninUI();
569 chrome.send('authenticateUser', 660 chrome.send('authenticateUser',
570 [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);
571 } 665 }
572 666
573 return true; 667 return true;
574 }, 668 },
575 669
576 showSupervisedUserSigninWarning: function() { 670 showSupervisedUserSigninWarning: function() {
577 // Locally managed user token has been invalidated. 671 // Locally managed user token has been invalidated.
578 // 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.
579 this.parentNode.focusPod(this); 673 this.parentNode.focusPod(this);
580 674
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 }, 824 },
731 825
732 /** 826 /**
733 * Handles click event on a user pod. 827 * Handles click event on a user pod.
734 * @param {Event} e Click event. 828 * @param {Event} e Click event.
735 */ 829 */
736 handleClickOnPod_: function(e) { 830 handleClickOnPod_: function(e) {
737 if (this.parentNode.disabled) 831 if (this.parentNode.disabled)
738 return; 832 return;
739 833
740 if (this.forceOnlineSignin && !this.isActionBoxMenuActive) { 834 if (!this.isActionBoxMenuActive) {
741 this.showSigninUI(); 835 if (this.isAuthTypeOnlineSignIn) {
836 this.showSigninUI();
837 } else if (this.isAuthTypeUserClick) {
838 this.parentNode.setActivatedPod(this);
839 }
840
742 // Prevent default so that we don't trigger 'focus' event. 841 // Prevent default so that we don't trigger 'focus' event.
743 e.preventDefault(); 842 e.preventDefault();
744 } 843 }
745 }, 844 },
746 845
747 /** 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 /**
748 * Called when the custom button is clicked. 863 * Called when the custom button is clicked.
749 */ 864 */
750 handleCustomButtonClick_: function() { 865 handleCustomButtonClick_: function() {
751 chrome.send('customButtonClicked', [this.user.username]); 866 chrome.send('customButtonClicked', [this.user.username]);
752 } 867 }
753 }; 868 };
754 869
755 /** 870 /**
756 * Creates a public account user pod. 871 * Creates a public account user pod.
757 * @constructor 872 * @constructor
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 920
806 // Accessibility focus indicator does not move with the focused 921 // Accessibility focus indicator does not move with the focused
807 // element. Sends a 'focus' event on the currently focused element 922 // element. Sends a 'focus' event on the currently focused element
808 // so that accessibility focus indicator updates its location. 923 // so that accessibility focus indicator updates its location.
809 if (document.activeElement) 924 if (document.activeElement)
810 document.activeElement.dispatchEvent(new Event('focus')); 925 document.activeElement.dispatchEvent(new Event('focus'));
811 }); 926 });
812 }, 927 },
813 928
814 /** @override */ 929 /** @override */
815 get forceOnlineSignin() {
816 return false;
817 },
818
819 /** @override */
820 get mainInput() { 930 get mainInput() {
821 if (this.expanded) 931 if (this.expanded)
822 return this.enterButtonElement; 932 return this.enterButtonElement;
823 else 933 else
824 return this.nameElement; 934 return this.nameElement;
825 }, 935 },
826 936
827 /** @override */ 937 /** @override */
828 decorate: function() { 938 decorate: function() {
829 UserPod.prototype.decorate.call(this); 939 UserPod.prototype.decorate.call(this);
(...skipping 20 matching lines...) Expand all
850 learnMore = this.querySelector('.side-pane-learn-more'); 960 learnMore = this.querySelector('.side-pane-learn-more');
851 learnMore.addEventListener('click', this.handleLearnMoreEvent); 961 learnMore.addEventListener('click', this.handleLearnMoreEvent);
852 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); 962 learnMore.addEventListener('keydown', this.handleLearnMoreEvent);
853 963
854 this.enterButtonElement.addEventListener('click', (function(e) { 964 this.enterButtonElement.addEventListener('click', (function(e) {
855 this.enterButtonElement.disabled = true; 965 this.enterButtonElement.disabled = true;
856 chrome.send('launchPublicAccount', [this.user.username]); 966 chrome.send('launchPublicAccount', [this.user.username]);
857 }).bind(this)); 967 }).bind(this));
858 }, 968 },
859 969
860 /** 970 /** @override **/
861 * Updates the user pod element.
862 */
863 update: function() { 971 update: function() {
864 UserPod.prototype.update.call(this); 972 UserPod.prototype.update.call(this);
865 this.querySelector('.side-pane-name').textContent = 973 this.querySelector('.side-pane-name').textContent =
866 this.user_.displayName; 974 this.user_.displayName;
867 this.querySelector('.info').textContent = 975 this.querySelector('.info').textContent =
868 loadTimeData.getStringF('publicAccountInfoFormat', 976 loadTimeData.getStringF('publicAccountInfoFormat',
869 this.user_.enterpriseDomain); 977 this.user_.enterpriseDomain);
870 }, 978 },
871 979
872 /** @override */ 980 /** @override */
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 * @param {string} iconURL URL of the button icon 1566 * @param {string} iconURL URL of the button icon
1459 */ 1567 */
1460 showUserPodButton: function(username, iconURL) { 1568 showUserPodButton: function(username, iconURL) {
1461 var pod = this.getPodWithUsername_(username); 1569 var pod = this.getPodWithUsername_(username);
1462 if (pod == null) { 1570 if (pod == null) {
1463 console.error('Unable to show user pod button for ' + username + 1571 console.error('Unable to show user pod button for ' + username +
1464 ': user pod not found.'); 1572 ': user pod not found.');
1465 return; 1573 return;
1466 } 1574 }
1467 1575
1468 pod.customButton.hidden = false; 1576 pod.customButtonElement.hidden = false;
1469 var icon = 1577 var icon =
1470 pod.customButton.querySelector('.custom-button-icon'); 1578 pod.customButtonElement.querySelector('.custom-button-icon');
1471 icon.src = iconURL; 1579 icon.src = iconURL;
1472 }, 1580 },
1473 1581
1474 /** 1582 /**
1583 * Hides button from user pod added by showUserPodButton().
1584 * @param {string} username Username of pod to remove button
1585 */
1586 hideUserPodButton: function(username) {
1587 var pod = this.getPodWithUsername_(username);
1588 if (pod == null) {
1589 console.error('Unable to hide user pod button for ' + username +
1590 ': user pod not found.');
1591 return;
1592 }
1593
1594 pod.customButtonElement.hidden = true;
1595 },
1596
1597 /**
1598 * Sets the authentication type used to authenticate the user.
1599 * @param {string} username Username of selected user
1600 * @param {number} authType Authentication type, must be one of the
1601 * values listed in AUTH_TYPE enum.
1602 * @param {string} value The initial value to use for authentication.
1603 */
1604 setAuthType: function(username, authType, value) {
1605 var pod = this.getPodWithUsername_(username);
1606 if (pod == null) {
1607 console.error('Unable to set auth type for ' + username +
1608 ': user pod not found.');
1609 return;
1610 }
1611 pod.setAuthType(authType, value);
1612 },
1613
1614 /**
1475 * Called when window was resized. 1615 * Called when window was resized.
1476 */ 1616 */
1477 onWindowResize: function() { 1617 onWindowResize: function() {
1478 var layout = this.calculateLayout_(); 1618 var layout = this.calculateLayout_();
1479 if (layout.columns != this.columns || layout.rows != this.rows) 1619 if (layout.columns != this.columns || layout.rows != this.rows)
1480 this.placePods_(); 1620 this.placePods_();
1481 }, 1621 },
1482 1622
1483 /** 1623 /**
1484 * Returns width of podrow having |columns| number of columns. 1624 * Returns width of podrow having |columns| number of columns.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 * Updates current image of a user. 1892 * Updates current image of a user.
1753 * @param {string} username User for which to update the image. 1893 * @param {string} username User for which to update the image.
1754 */ 1894 */
1755 updateUserImage: function(username) { 1895 updateUserImage: function(username) {
1756 var pod = this.getPodWithUsername_(username); 1896 var pod = this.getPodWithUsername_(username);
1757 if (pod) 1897 if (pod)
1758 pod.updateUserImage(); 1898 pod.updateUserImage();
1759 }, 1899 },
1760 1900
1761 /** 1901 /**
1762 * Indicates that the given user must authenticate against GAIA during the
1763 * next sign-in.
1764 * @param {string} username User for whom to enforce GAIA sign-in.
1765 */
1766 forceOnlineSigninForUser: function(username) {
1767 var pod = this.getPodWithUsername_(username);
1768 if (pod) {
1769 pod.user.forceOnlineSignin = true;
1770 pod.update();
1771 } else {
1772 console.log('Failed to update GAIA state for: ' + username);
1773 }
1774 },
1775
1776 /**
1777 * Handler of click event. 1902 * Handler of click event.
1778 * @param {Event} e Click Event object. 1903 * @param {Event} e Click Event object.
1779 * @private 1904 * @private
1780 */ 1905 */
1781 handleClick_: function(e) { 1906 handleClick_: function(e) {
1782 if (this.disabled) 1907 if (this.disabled)
1783 return; 1908 return;
1784 1909
1785 // Clear all menus if the click is outside pod menu and its 1910 // Clear all menus if the click is outside pod menu and its
1786 // button area. 1911 // button area.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 if (this.podsWithPendingImages_.length == 0) { 2113 if (this.podsWithPendingImages_.length == 0) {
1989 this.classList.remove('images-loading'); 2114 this.classList.remove('images-loading');
1990 } 2115 }
1991 } 2116 }
1992 }; 2117 };
1993 2118
1994 return { 2119 return {
1995 PodRow: PodRow 2120 PodRow: PodRow
1996 }; 2121 };
1997 }); 2122 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698