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

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

Issue 1411423006: Simplifed logic of showing/hiding cancel buttons on login screens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fix. Created 5 years, 1 month 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
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 Oobe signin screen implementation. 6 * @fileoverview Oobe signin screen implementation.
7 */ 7 */
8 8
9 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { 9 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() {
10 // GAIA animation guard timer. Started when GAIA page is loaded 10 // GAIA animation guard timer. Started when GAIA page is loaded
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * @type {boolean} 93 * @type {boolean}
94 * @private 94 * @private
95 */ 95 */
96 showViewProcessed_: undefined, 96 showViewProcessed_: undefined,
97 97
98 /** 98 /**
99 * Whether user can cancel Gaia screen. 99 * Whether user can cancel Gaia screen.
100 * @type {boolean} 100 * @type {boolean}
101 * @private 101 * @private
102 */ 102 */
103 cancelAllowed_: undefined, 103 cancelable_: false,
104 get cancelable() {
105 // TODO(dzhioev): add cancel and refresh buttons hiding logic here.
106 // http://crbug.com/484514
107 return this.cancelable_;
108 },
109 set cancelable(value) {
110 this.cancelable_ = value;
111 },
104 112
105 /** 113 /**
106 * Whether we should show user pods on the login screen. 114 * Whether we should show user pods on the login screen.
107 * @type {boolean} 115 * @type {boolean}
108 * @private 116 * @private
109 */ 117 */
110 isShowUsers_: undefined, 118 isShowUsers_: undefined,
111 119
112 /** 120 /**
113 * SAML password confirmation attempt count. 121 * SAML password confirmation attempt count.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 this.classList.toggle('full-width', false); 516 this.classList.toggle('full-width', false);
509 if (Oobe.getInstance().currentScreen === this) 517 if (Oobe.getInstance().currentScreen === this)
510 Oobe.getInstance().updateScreenSize(this); 518 Oobe.getInstance().updateScreenSize(this);
511 }, 519 },
512 520
513 /** 521 /**
514 * Updates [Cancel] button state. Allow cancellation of screen only when 522 * Updates [Cancel] button state. Allow cancellation of screen only when
515 * user pods can be displayed. 523 * user pods can be displayed.
516 */ 524 */
517 updateCancelButtonState: function() { 525 updateCancelButtonState: function() {
518 this.cancelAllowed_ = this.isLocal || 526 this.cancelable = this.isLocal ||
519 (this.isShowUsers_ && $('pod-row').pods.length); 527 (this.isShowUsers_ && $('pod-row').pods.length);
520 $('login-header-bar').allowCancel = this.cancelAllowed_; 528 $('close-button-item').hidden = !this.cancelable;
521 $('close-button-item').hidden = !this.cancelAllowed_;
522 }, 529 },
523 530
524 /** 531 /**
525 * Whether the current auth flow is SAML. 532 * Whether the current auth flow is SAML.
526 */ 533 */
527 isSAML: function() { 534 isSAML: function() {
528 return this.gaiaAuthHost_.authFlow == 535 return this.gaiaAuthHost_.authFlow ==
529 cr.login.GaiaAuthHost.AuthFlow.SAML; 536 cr.login.GaiaAuthHost.AuthFlow.SAML;
530 }, 537 },
531 538
(...skipping 11 matching lines...) Expand all
543 * @param {Event} e Property change event. 550 * @param {Event} e Property change event.
544 */ 551 */
545 onAuthFlowChange_: function(e) { 552 onAuthFlowChange_: function(e) {
546 var isSAML = this.isSAML(); 553 var isSAML = this.isSAML();
547 554
548 this.classList.toggle('full-width', isSAML); 555 this.classList.toggle('full-width', isSAML);
549 $('saml-notice-container').hidden = !isSAML; 556 $('saml-notice-container').hidden = !isSAML;
550 557
551 if (Oobe.getInstance().currentScreen === this) { 558 if (Oobe.getInstance().currentScreen === this) {
552 Oobe.getInstance().updateScreenSize(this); 559 Oobe.getInstance().updateScreenSize(this);
553 $('login-header-bar').allowCancel = isSAML || this.cancelAllowed_; 560 $('close-button-item').hidden = !(isSAML || this.cancelable);
554 $('close-button-item').hidden = !(isSAML || this.cancelAllowed_);
555 } 561 }
556 }, 562 },
557 563
558 /** 564 /**
559 * Invoked when the auth host emits 'ready' event. 565 * Invoked when the auth host emits 'ready' event.
560 * @private 566 * @private
561 */ 567 */
562 onAuthReady_: function() { 568 onAuthReady_: function() {
563 showViewProcessed_ = false; 569 showViewProcessed_ = false;
564 this.startLoadAnimationGuardTimer_(); 570 this.startLoadAnimationGuardTimer_();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 }, 827 },
822 828
823 /** 829 /**
824 * Shows sign-in error bubble. 830 * Shows sign-in error bubble.
825 * @param {number} loginAttempts Number of login attemps tried. 831 * @param {number} loginAttempts Number of login attemps tried.
826 * @param {HTMLElement} content Content to show in bubble. 832 * @param {HTMLElement} content Content to show in bubble.
827 */ 833 */
828 showErrorBubble: function(loginAttempts, error) { 834 showErrorBubble: function(loginAttempts, error) {
829 if (this.isLocal) { 835 if (this.isLocal) {
830 $('add-user-button').hidden = true; 836 $('add-user-button').hidden = true;
831 $('cancel-add-user-button').hidden = false;
832 // Reload offline version of the sign-in extension, which will show 837 // Reload offline version of the sign-in extension, which will show
833 // error itself. 838 // error itself.
834 chrome.send('offlineLogin', [this.email]); 839 chrome.send('offlineLogin', [this.email]);
835 } else if (!this.loading) { 840 } else if (!this.loading) {
836 // TODO(dzhioev): investigate if this branch ever get hit. 841 // TODO(dzhioev): investigate if this branch ever get hit.
837 $('bubble').showContentForElement($('gaia-signin-form-container'), 842 $('bubble').showContentForElement($('gaia-signin-form-container'),
838 cr.ui.Bubble.Attachment.LEFT, 843 cr.ui.Bubble.Attachment.LEFT,
839 error); 844 error);
840 } else { 845 } else {
841 // Defer the bubble until the frame has been loaded. 846 // Defer the bubble until the frame has been loaded.
842 this.errorBubble_ = [loginAttempts, error]; 847 this.errorBubble_ = [loginAttempts, error];
843 } 848 }
844 }, 849 },
845 850
846 /** 851 /**
847 * Called when user canceled signin. 852 * Called when user canceled signin.
848 */ 853 */
849 cancel: function() { 854 cancel: function() {
850 if (!this.cancelAllowed_) { 855 if (!this.cancelable) {
851 // In OOBE signin screen, cancel is not allowed because there is 856 // In OOBE signin screen, cancel is not allowed because there is
852 // no other screen to show. If user is in middle of a saml flow, 857 // no other screen to show. If user is in middle of a saml flow,
853 // reset signin screen to get out of the saml flow. 858 // reset signin screen to get out of the saml flow.
854 if (this.isSAML()) 859 if (this.isSAML())
855 Oobe.resetSigninUI(true); 860 Oobe.resetSigninUI(true);
856 861
857 return; 862 return;
858 } 863 }
859 864
860 $('offline-gaia').switchToEmailCard(); 865 $('offline-gaia').switchToEmailCard();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 927 }
923 928
924 this.classList.toggle('whitelist-error', show); 929 this.classList.toggle('whitelist-error', show);
925 this.loading = !show; 930 this.loading = !show;
926 931
927 if (!show) 932 if (!show)
928 Oobe.showSigninUI(); 933 Oobe.showSigninUI();
929 } 934 }
930 }; 935 };
931 }); 936 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698