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

Side by Side Diff: chrome/browser/resources/user_chooser/control_bar.js

Issue 16104008: First try at a user management screen for the desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and review comments Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 Login UI header bar implementation. 6 * @fileoverview Desktop User Chooser UI control bar implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 /** 10 /**
11 * Creates a header bar element. 11 * Creates a header bar element.
12 * @constructor 12 * @constructor
13 * @extends {HTMLDivElement} 13 * @extends {HTMLDivElement}
14 */ 14 */
15 var HeaderBar = cr.ui.define('div'); 15 var HeaderBar = cr.ui.define('div');
16 16
17 HeaderBar.prototype = { 17 HeaderBar.prototype = {
18 __proto__: HTMLDivElement.prototype, 18 __proto__: HTMLDivElement.prototype,
19 19
20 // Whether guest button should be shown when header bar is in normal mode. 20 // Whether guest button should be shown when header bar is in normal mode.
21 showGuest_: false, 21 showGuest_: true,
22 22
23 // Current UI state of the sign-in screen. 23 // Current UI state of the sign-in screen.
24 signinUIState_: SIGNIN_UI_STATE.HIDDEN, 24 signinUIState_: SIGNIN_UI_STATE.ACCOUNT_PICKER,
25 25
26 // Whether to show kiosk apps menu. 26 // Whether to show kiosk apps menu.
27 hasApps_: false, 27 hasApps_: false,
28 28
29 /** @override */ 29 /** @override */
30 decorate: function() { 30 decorate: function() {
31 $('shutdown-header-bar-item').addEventListener('click',
32 this.handleShutdownClick_);
33 $('shutdown-button').addEventListener('click',
34 this.handleShutdownClick_);
35 $('add-user-button').addEventListener('click', 31 $('add-user-button').addEventListener('click',
36 this.handleAddUserClick_); 32 this.handleAddUserClick_);
37 $('cancel-add-user-button').addEventListener('click', 33 $('cancel-add-user-button').addEventListener('click',
38 this.handleCancelAddUserClick_); 34 this.handleCancelAddUserClick_);
39 $('guest-user-header-bar-item').addEventListener('click', 35 $('guest-user-header-bar-item').addEventListener('click',
40 this.handleGuestClick_); 36 this.handleGuestClick_);
41 $('guest-user-button').addEventListener('click', 37 $('guest-user-button').addEventListener('click',
42 this.handleGuestClick_); 38 this.handleGuestClick_);
43 $('sign-out-user-button').addEventListener('click', 39 this.updateUI_();
44 this.handleSignoutClick_);
45 $('cancel-multiple-sign-in-button').addEventListener('click',
46 this.handleCancelMultipleSignInClick_);
47
48 if (loadTimeData.getBoolean('enableAppMode') &&
49 document.documentElement.getAttribute('screen') == 'login') {
50 login.AppsMenuButton.decorate($('show-apps-button'));
51 }
52 }, 40 },
53 41
54 /** 42 /**
55 * Tab index value for all button elements. 43 * Tab index value for all button elements.
56 * @type {number} 44 * @type {number}
57 */ 45 */
58 set buttonsTabIndex(tabIndex) { 46 set buttonsTabIndex(tabIndex) {
59 var buttons = this.getElementsByTagName('button'); 47 var buttons = this.getElementsByTagName('button');
60 for (var i = 0, button; button = buttons[i]; ++i) { 48 for (var i = 0, button; button = buttons[i]; ++i) {
61 button.tabIndex = tabIndex; 49 button.tabIndex = tabIndex;
62 } 50 }
63 }, 51 },
64 52
65 /** 53 /**
66 * Disables the header bar and all of its elements. 54 * Disables the header bar and all of its elements.
67 * @type {boolean} 55 * @type {boolean}
68 */ 56 */
69 set disabled(value) { 57 set disabled(value) {
70 var buttons = this.getElementsByTagName('button'); 58 var buttons = this.getElementsByTagName('button');
71 for (var i = 0, button; button = buttons[i]; ++i) 59 for (var i = 0, button; button = buttons[i]; ++i)
72 if (!button.classList.contains('button-restricted')) 60 if (!button.classList.contains('button-restricted'))
73 button.disabled = value; 61 button.disabled = value;
74 }, 62 },
75 63
76 /** 64 /**
77 * Add user button click handler. 65 * Add user button click handler.
78 * @private 66 * @private
79 */ 67 */
80 handleAddUserClick_: function(e) { 68 handleAddUserClick_: function(e) {
81 Oobe.showSigninUI(); 69 chrome.send('addUser');
82 // Prevent further propagation of click event. Otherwise, the click event 70 // Prevent further propagation of click event. Otherwise, the click event
83 // handler of document object will set wallpaper to user's wallpaper when 71 // handler of document object will set wallpaper to user's wallpaper when
84 // there is only one existing user. See http://crbug.com/166477 72 // there is only one existing user. See http://crbug.com/166477
85 e.stopPropagation(); 73 e.stopPropagation();
86 }, 74 },
87 75
88 /** 76 /**
89 * Cancel add user button click handler. 77 * Cancel add user button click handler.
90 * @private 78 * @private
91 */ 79 */
92 handleCancelAddUserClick_: function(e) { 80 handleCancelAddUserClick_: function(e) {
93 // Let screen handle cancel itself if that is capable of doing so. 81 // Let screen handle cancel itself if that is capable of doing so.
94 if (Oobe.getInstance().currentScreen && 82 if (Oobe.getInstance().currentScreen &&
95 Oobe.getInstance().currentScreen.cancel) { 83 Oobe.getInstance().currentScreen.cancel) {
96 Oobe.getInstance().currentScreen.cancel(); 84 Oobe.getInstance().currentScreen.cancel();
97 return; 85 return;
98 } 86 }
99 87
100 $('pod-row').loadLastWallpaper();
101
102 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); 88 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER});
103 Oobe.resetSigninUI(true); 89 Oobe.resetSigninUI(true);
104 }, 90 },
105 91
106 /** 92 /**
107 * Guest button click handler. 93 * Guest button click handler.
108 * @private 94 * @private
109 */ 95 */
110 handleGuestClick_: function(e) { 96 handleGuestClick_: function(e) {
111 Oobe.disableSigninUI(); 97 chrome.send('launchGuest');
112 chrome.send('launchIncognito');
113 e.stopPropagation(); 98 e.stopPropagation();
114 }, 99 },
115 100
116 /**
117 * Sign out button click handler.
118 * @private
119 */
120 handleSignoutClick_: function(e) {
121 this.disabled = true;
122 chrome.send('signOutUser');
123 e.stopPropagation();
124 },
125
126 /**
127 * Shutdown button click handler.
128 * @private
129 */
130 handleShutdownClick_: function(e) {
131 chrome.send('shutdownSystem');
132 e.stopPropagation();
133 },
134
135 /**
136 * Cancel user adding button handler.
137 * @private
138 */
139 handleCancelMultipleSignInClick_: function(e) {
140 chrome.send('cancelUserAdding');
141 e.stopPropagation();
142 },
143
144 /** 101 /**
145 * If true then "Browse as Guest" button is shown. 102 * If true then "Browse as Guest" button is shown.
146 * @type {boolean} 103 * @type {boolean}
147 */ 104 */
148 set showGuestButton(value) { 105 set showGuestButton(value) {
149 this.showGuest_ = value; 106 this.showGuest_ = value;
150 this.updateUI_(); 107 this.updateUI_();
151 }, 108 },
152 109
153 /** 110 /**
154 * Update current header bar UI. 111 * Update current header bar UI.
155 * @type {number} state Current state of the sign-in screen 112 * @type {number} state Current state of the sign-in screen
156 * (see SIGNIN_UI_STATE). 113 * (see SIGNIN_UI_STATE).
157 */ 114 */
158 set signinUIState(state) { 115 set signinUIState(state) {
159 this.signinUIState_ = state; 116 this.signinUIState_ = state;
160 this.updateUI_(); 117 this.updateUI_();
161 }, 118 },
162 119
163 /** 120 /**
164 * Whether the Cancel button is enabled during Gaia sign-in. 121 * Whether the Cancel button is enabled during Gaia sign-in.
165 * @type {boolean} 122 * @type {boolean}
166 */ 123 */
167 set allowCancel(value) { 124 set allowCancel(value) {
168 this.allowCancel_ = value; 125 this.allowCancel_ = value;
169 this.updateUI_(); 126 this.updateUI_();
170 }, 127 },
171 128
172 /** 129 /**
173 * Update whether there are kiosk apps.
174 * @type {boolean}
175 */
176 set hasApps(value) {
177 this.hasApps_ = value;
178 this.updateUI_();
179 },
180
181 /**
182 * Updates visibility state of action buttons. 130 * Updates visibility state of action buttons.
183 * @private 131 * @private
184 */ 132 */
185 updateUI_: function() { 133 updateUI_: function() {
186 var gaiaIsActive = (this.signinUIState_ == SIGNIN_UI_STATE.GAIA_SIGNIN); 134 $('add-user-button').hidden = false;
187 var accountPickerIsActive = 135 $('cancel-add-user-button').hidden = !this.allowCancel_;
188 (this.signinUIState_ == SIGNIN_UI_STATE.ACCOUNT_PICKER); 136 $('guest-user-header-bar-item').hidden = false;
189 var managedUserCreationDialogIsActive = 137 $('add-user-header-bar-item').hidden = false;
190 (this.signinUIState_ == SIGNIN_UI_STATE.MANAGED_USER_CREATION_FLOW);
191 var wrongHWIDWarningIsActive =
192 (this.signinUIState_ == SIGNIN_UI_STATE.WRONG_HWID_WARNING);
193 var isMultiProfilesUI = Oobe.getInstance().isSignInToAddScreen();
194
195 $('add-user-button').hidden = !accountPickerIsActive || isMultiProfilesUI;
196 $('cancel-add-user-button').hidden = accountPickerIsActive ||
197 !this.allowCancel_ ||
198 wrongHWIDWarningIsActive ||
199 isMultiProfilesUI;
200 $('guest-user-header-bar-item').hidden = gaiaIsActive ||
201 managedUserCreationDialogIsActive ||
202 !this.showGuest_ ||
203 wrongHWIDWarningIsActive ||
204 isMultiProfilesUI;
205 $('add-user-header-bar-item').hidden =
206 $('add-user-button').hidden && $('cancel-add-user-button').hidden;
207 $('apps-header-bar-item').hidden = !this.hasApps_ ||
208 (!gaiaIsActive && !accountPickerIsActive);
209 $('cancel-multiple-sign-in-item').hidden = !isMultiProfilesUI;
210
211 if (!$('apps-header-bar-item').hidden)
212 $('show-apps-button').didShow();
213 }, 138 },
214 139
215 /** 140 /**
216 * Animates Header bar to hide from the screen. 141 * Animates Header bar to hide from the screen.
217 * @param {function()} callback will be called once animation is finished. 142 * @param {function()} callback will be called once animation is finished.
218 */ 143 */
219 animateOut: function(callback) { 144 animateOut: function(callback) {
220 var launcher = this; 145 var launcher = this;
221 launcher.addEventListener( 146 launcher.addEventListener(
222 'webkitTransitionEnd', function f(e) { 147 'webkitTransitionEnd', function f(e) {
(...skipping 26 matching lines...) Expand all
249 * Convenience wrapper of animateIn. 174 * Convenience wrapper of animateIn.
250 */ 175 */
251 HeaderBar.animateIn = function() { 176 HeaderBar.animateIn = function() {
252 $('login-header-bar').animateIn(); 177 $('login-header-bar').animateIn();
253 } 178 }
254 179
255 return { 180 return {
256 HeaderBar: HeaderBar 181 HeaderBar: HeaderBar
257 }; 182 };
258 }); 183 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698