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

Side by Side Diff: ui/login/account_picker/user_pod_row.js

Issue 1219763002: Fix VK flashing after clicking action area on user pod (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview User pod row implementation. 6 * @fileoverview User pod row implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 /** 10 /**
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 */ 2251 */
2252 addUserPod: function(user) { 2252 addUserPod: function(user) {
2253 var userPod = this.createUserPod(user); 2253 var userPod = this.createUserPod(user);
2254 this.appendChild(userPod); 2254 this.appendChild(userPod);
2255 userPod.initialize(); 2255 userPod.initialize();
2256 }, 2256 },
2257 2257
2258 /** 2258 /**
2259 * Runs app with a given id from the list of loaded apps. 2259 * Runs app with a given id from the list of loaded apps.
2260 * @param {!string} app_id of an app to run. 2260 * @param {!string} app_id of an app to run.
2261 * @param {boolean=} opt_diagnostic_mode Whether to run the app in 2261 * @param {boolean=} opt_diagnosticMode Whether to run the app in
2262 * diagnostic mode. Default is false. 2262 * diagnostic mode. Default is false.
2263 */ 2263 */
2264 findAndRunAppForTesting: function(app_id, opt_diagnostic_mode) { 2264 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) {
2265 var app = this.getPodWithAppId_(app_id); 2265 var app = this.getPodWithAppId_(app_id);
2266 if (app) { 2266 if (app) {
2267 var activationEvent = cr.doc.createEvent('MouseEvents'); 2267 var activationEvent = cr.doc.createEvent('MouseEvents');
2268 var ctrlKey = opt_diagnostic_mode; 2268 var ctrlKey = opt_diagnosticMode;
2269 activationEvent.initMouseEvent('click', true, true, null, 2269 activationEvent.initMouseEvent('click', true, true, null,
2270 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); 2270 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null);
2271 app.dispatchEvent(activationEvent); 2271 app.dispatchEvent(activationEvent);
2272 } 2272 }
2273 }, 2273 },
2274 2274
2275 /** 2275 /**
2276 * Removes user pod from pod row. 2276 * Removes user pod from pod row.
2277 * @param {string} email User's email. 2277 * @param {string} email User's email.
2278 */ 2278 */
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 */ 2723 */
2724 isFocused: function(pod) { 2724 isFocused: function(pod) {
2725 return this.focusedPod_ == pod; 2725 return this.focusedPod_ == pod;
2726 }, 2726 },
2727 2727
2728 /** 2728 /**
2729 * Focuses a given user pod or clear focus when given null. 2729 * Focuses a given user pod or clear focus when given null.
2730 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). 2730 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus).
2731 * @param {boolean=} opt_force If true, forces focus update even when 2731 * @param {boolean=} opt_force If true, forces focus update even when
2732 * podToFocus is already focused. 2732 * podToFocus is already focused.
2733 * @param {boolean=} opt_skipInputFocus If true, don't focus on the input
2734 * box of user pod.
2733 */ 2735 */
2734 focusPod: function(podToFocus, opt_force) { 2736 focusPod: function(podToFocus, opt_force, opt_skipInputFocus) {
2735 if (this.isFocused(podToFocus) && !opt_force) { 2737 if (this.isFocused(podToFocus) && !opt_force) {
2736 // Calling focusPod w/o podToFocus means reset. 2738 // Calling focusPod w/o podToFocus means reset.
2737 if (!podToFocus) 2739 if (!podToFocus)
2738 Oobe.clearErrors(); 2740 Oobe.clearErrors();
2739 this.keyboardActivated_ = false;
2740 return; 2741 return;
2741 } 2742 }
2742 2743
2743 // Make sure there's only one focusPod operation happening at a time. 2744 // Make sure there's only one focusPod operation happening at a time.
2744 if (this.insideFocusPod_) { 2745 if (this.insideFocusPod_) {
2745 this.keyboardActivated_ = false;
2746 return; 2746 return;
2747 } 2747 }
2748 this.insideFocusPod_ = true; 2748 this.insideFocusPod_ = true;
2749 2749
2750 for (var i = 0, pod; pod = this.pods[i]; ++i) { 2750 for (var i = 0, pod; pod = this.pods[i]; ++i) {
2751 if (!this.alwaysFocusSinglePod) { 2751 if (!this.alwaysFocusSinglePod) {
2752 pod.isActionBoxMenuActive = false; 2752 pod.isActionBoxMenuActive = false;
2753 } 2753 }
2754 if (pod != podToFocus) { 2754 if (pod != podToFocus) {
2755 pod.isActionBoxMenuHovered = false; 2755 pod.isActionBoxMenuHovered = false;
(...skipping 12 matching lines...) Expand all
2768 if (!this.isFocused(podToFocus)) 2768 if (!this.isFocused(podToFocus))
2769 Oobe.clearErrors(); 2769 Oobe.clearErrors();
2770 2770
2771 var hadFocus = !!this.focusedPod_; 2771 var hadFocus = !!this.focusedPod_;
2772 this.focusedPod_ = podToFocus; 2772 this.focusedPod_ = podToFocus;
2773 if (podToFocus) { 2773 if (podToFocus) {
2774 podToFocus.classList.remove('faded'); 2774 podToFocus.classList.remove('faded');
2775 podToFocus.classList.add('focused'); 2775 podToFocus.classList.add('focused');
2776 if (!podToFocus.multiProfilesPolicyApplied) { 2776 if (!podToFocus.multiProfilesPolicyApplied) {
2777 podToFocus.classList.toggle('signing-in', false); 2777 podToFocus.classList.toggle('signing-in', false);
2778 podToFocus.focusInput(); 2778 if (!opt_skipInputFocus)
2779 podToFocus.focusInput();
2779 } else { 2780 } else {
2780 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 2781 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
2782 // Note it is not necessary to skip this focus request when
2783 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
2784 // is false, it doesn't focus on the password input box by default.
2781 podToFocus.focus(); 2785 podToFocus.focus();
2782 } 2786 }
2783 2787
2784 // focusPod() automatically loads wallpaper 2788 // focusPod() automatically loads wallpaper
2785 if (!podToFocus.user.isApp) 2789 if (!podToFocus.user.isApp)
2786 chrome.send('focusPod', [podToFocus.user.username]); 2790 chrome.send('focusPod', [podToFocus.user.username]);
2787 this.firstShown_ = false; 2791 this.firstShown_ = false;
2788 this.lastFocusedPod_ = podToFocus; 2792 this.lastFocusedPod_ = podToFocus;
2789 this.scrollFocusedPodIntoView(); 2793 this.scrollFocusedPodIntoView();
2790 } 2794 }
2791 this.insideFocusPod_ = false; 2795 this.insideFocusPod_ = false;
2792 this.keyboardActivated_ = false;
2793 }, 2796 },
2794 2797
2795 /** 2798 /**
2796 * Resets wallpaper to the last active user's wallpaper, if any. 2799 * Resets wallpaper to the last active user's wallpaper, if any.
2797 */ 2800 */
2798 loadLastWallpaper: function() { 2801 loadLastWallpaper: function() {
2799 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) 2802 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp)
2800 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); 2803 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]);
2801 }, 2804 },
2802 2805
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2991 else 2994 else
2992 e.target.userTypeBubbleElement.classList.add('bubble-shown'); 2995 e.target.userTypeBubbleElement.classList.add('bubble-shown');
2993 } else 2996 } else
2994 this.focusPod(e.target); 2997 this.focusPod(e.target);
2995 return; 2998 return;
2996 } 2999 }
2997 3000
2998 var pod = findAncestorByClass(e.target, 'pod'); 3001 var pod = findAncestorByClass(e.target, 'pod');
2999 if (pod && pod.parentNode == this) { 3002 if (pod && pod.parentNode == this) {
3000 // Focus on a control of a pod but not on the action area button. 3003 // Focus on a control of a pod but not on the action area button.
3001 if (!pod.classList.contains('focused') && 3004 if (!pod.classList.contains('focused')) {
3002 !e.target.classList.contains('action-box-button')) { 3005 if (e.target.classList.contains('action-box-area') ||
3003 this.focusPod(pod); 3006 e.target.classList.contains('remove-warning-button')) {
3007 // focusPod usually moves focus on the password input box which
3008 // triggers virtual keyboard to show up. But the focus may move to a
3009 // non text input element shortly by e.target.focus. Hence, a
3010 // virtual keyboard flicking might be observed. We need to manually
3011 // prevent focus on password input box to avoid virtual keyboard
3012 // flicking in this case. See crbug.com/396016 for details.
3013 this.focusPod(pod, false, true /* opt_skipInputFocus */);
3014 } else {
3015 this.focusPod(pod);
3016 }
3004 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3017 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3005 e.target.focus(); 3018 e.target.focus();
3006 } 3019 }
3007 return; 3020 return;
3008 } 3021 }
3009 3022
3010 // Clears pod focus when we reach here. It means new focus is neither 3023 // Clears pod focus when we reach here. It means new focus is neither
3011 // on a pod nor on a button/input for a pod. 3024 // on a pod nor on a button/input for a pod.
3012 // Do not "defocus" user pod when it is a single pod. 3025 // Do not "defocus" user pod when it is a single pod.
3013 // That means that 'focused' class will not be removed and 3026 // That means that 'focused' class will not be removed and
(...skipping 11 matching lines...) Expand all
3025 * Handler of keydown event. 3038 * Handler of keydown event.
3026 * @param {Event} e KeyDown Event object. 3039 * @param {Event} e KeyDown Event object.
3027 */ 3040 */
3028 handleKeyDown: function(e) { 3041 handleKeyDown: function(e) {
3029 if (this.disabled) 3042 if (this.disabled)
3030 return; 3043 return;
3031 var editing = e.target.tagName == 'INPUT' && e.target.value; 3044 var editing = e.target.tagName == 'INPUT' && e.target.value;
3032 switch (e.keyIdentifier) { 3045 switch (e.keyIdentifier) {
3033 case 'Left': 3046 case 'Left':
3034 if (!editing) { 3047 if (!editing) {
3035 this.keyboardActivated_ = true;
3036 if (this.focusedPod_ && this.focusedPod_.previousElementSibling) 3048 if (this.focusedPod_ && this.focusedPod_.previousElementSibling)
3037 this.focusPod(this.focusedPod_.previousElementSibling); 3049 this.focusPod(this.focusedPod_.previousElementSibling);
3038 else 3050 else
3039 this.focusPod(this.lastElementChild); 3051 this.focusPod(this.lastElementChild);
3040 3052
3041 e.stopPropagation(); 3053 e.stopPropagation();
3042 } 3054 }
3043 break; 3055 break;
3044 case 'Right': 3056 case 'Right':
3045 if (!editing) { 3057 if (!editing) {
3046 this.keyboardActivated_ = true;
3047 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) 3058 if (this.focusedPod_ && this.focusedPod_.nextElementSibling)
3048 this.focusPod(this.focusedPod_.nextElementSibling); 3059 this.focusPod(this.focusedPod_.nextElementSibling);
3049 else 3060 else
3050 this.focusPod(this.firstElementChild); 3061 this.focusPod(this.firstElementChild);
3051 3062
3052 e.stopPropagation(); 3063 e.stopPropagation();
3053 } 3064 }
3054 break; 3065 break;
3055 case 'Enter': 3066 case 'Enter':
3056 if (this.focusedPod_) { 3067 if (this.focusedPod_) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 if (pod && pod.multiProfilesPolicyApplied) { 3163 if (pod && pod.multiProfilesPolicyApplied) {
3153 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3164 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3154 } 3165 }
3155 } 3166 }
3156 }; 3167 };
3157 3168
3158 return { 3169 return {
3159 PodRow: PodRow 3170 PodRow: PodRow
3160 }; 3171 };
3161 }); 3172 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698