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

Side by Side Diff: chrome/browser/resources/user_chooser/header_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: clean up JS code Created 7 years, 6 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) 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 Login UI header bar implementation. 6 * @fileoverview Login UI header 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 $('sign-out-user-button').addEventListener('click',
Nikita (slow) 2013/06/11 18:22:16 You probably don't need sign out?
noms 2013/06/12 20:41:54 Done.
44 this.handleSignoutClick_); 40 this.handleSignoutClick_);
45 $('cancel-multiple-sign-in-button').addEventListener('click', 41 $('add-user-button').hidden = false;
Nikita (slow) 2013/06/11 18:22:16 Call updateUI_() instead?
noms 2013/06/12 20:41:54 Done.
46 this.handleCancelMultipleSignInClick_);
47
48 if (loadTimeData.getBoolean('enableAppMode') &&
49 document.documentElement.getAttribute('screen') == 'login') {
50 login.AppsMenuButton.decorate($('show-apps-button'));
51 }
52 }, 42 },
53 43
54 /** 44 /**
55 * Tab index value for all button elements. 45 * Tab index value for all button elements.
56 * @type {number} 46 * @type {number}
57 */ 47 */
58 set buttonsTabIndex(tabIndex) { 48 set buttonsTabIndex(tabIndex) {
59 var buttons = this.getElementsByTagName('button'); 49 var buttons = this.getElementsByTagName('button');
60 for (var i = 0, button; button = buttons[i]; ++i) { 50 for (var i = 0, button; button = buttons[i]; ++i) {
61 button.tabIndex = tabIndex; 51 button.tabIndex = tabIndex;
62 } 52 }
63 }, 53 },
64 54
65 /** 55 /**
66 * Disables the header bar and all of its elements. 56 * Disables the header bar and all of its elements.
67 * @type {boolean} 57 * @type {boolean}
68 */ 58 */
69 set disabled(value) { 59 set disabled(value) {
70 var buttons = this.getElementsByTagName('button'); 60 var buttons = this.getElementsByTagName('button');
71 for (var i = 0, button; button = buttons[i]; ++i) 61 for (var i = 0, button; button = buttons[i]; ++i)
72 if (!button.classList.contains('button-restricted')) 62 if (!button.classList.contains('button-restricted'))
73 button.disabled = value; 63 button.disabled = value;
74 }, 64 },
75 65
76 /** 66 /**
77 * Add user button click handler. 67 * Add user button click handler.
78 * @private 68 * @private
79 */ 69 */
80 handleAddUserClick_: function(e) { 70 handleAddUserClick_: function(e) {
81 Oobe.showSigninUI(); 71 chrome.send('addUser');
82 // Prevent further propagation of click event. Otherwise, the click event 72 // Prevent further propagation of click event. Otherwise, the click event
83 // handler of document object will set wallpaper to user's wallpaper when 73 // handler of document object will set wallpaper to user's wallpaper when
84 // there is only one existing user. See http://crbug.com/166477 74 // there is only one existing user. See http://crbug.com/166477
85 e.stopPropagation(); 75 e.stopPropagation();
86 }, 76 },
87 77
88 /** 78 /**
89 * Cancel add user button click handler. 79 * Cancel add user button click handler.
90 * @private 80 * @private
91 */ 81 */
92 handleCancelAddUserClick_: function(e) { 82 handleCancelAddUserClick_: function(e) {
93 // Let screen handle cancel itself if that is capable of doing so. 83 // Let screen handle cancel itself if that is capable of doing so.
94 if (Oobe.getInstance().currentScreen && 84 if (Oobe.getInstance().currentScreen &&
95 Oobe.getInstance().currentScreen.cancel) { 85 Oobe.getInstance().currentScreen.cancel) {
96 Oobe.getInstance().currentScreen.cancel(); 86 Oobe.getInstance().currentScreen.cancel();
97 return; 87 return;
98 } 88 }
99 89
100 $('pod-row').loadLastWallpaper();
101
102 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); 90 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER});
103 Oobe.resetSigninUI(true); 91 Oobe.resetSigninUI(true);
104 }, 92 },
105 93
106 /** 94 /**
107 * Guest button click handler. 95 * Guest button click handler.
108 * @private 96 * @private
109 */ 97 */
110 handleGuestClick_: function(e) { 98 handleGuestClick_: function(e) {
111 Oobe.disableSigninUI(); 99 chrome.send('launchGuest');
112 chrome.send('launchIncognito');
113 e.stopPropagation(); 100 e.stopPropagation();
114 }, 101 },
115 102
116 /** 103 /**
117 * Sign out button click handler. 104 * Sign out button click handler.
118 * @private 105 * @private
119 */ 106 */
120 handleSignoutClick_: function(e) { 107 handleSignoutClick_: function(e) {
121 this.disabled = true; 108 this.disabled = true;
122 chrome.send('signOutUser'); 109 chrome.send('signOutUser');
123 e.stopPropagation(); 110 e.stopPropagation();
124 }, 111 },
125 112
126 /** 113 /**
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 /**
145 * If true then "Browse as Guest" button is shown. 114 * If true then "Browse as Guest" button is shown.
146 * @type {boolean} 115 * @type {boolean}
147 */ 116 */
148 set showGuestButton(value) { 117 set showGuestButton(value) {
149 this.showGuest_ = value; 118 this.showGuest_ = value;
150 this.updateUI_(); 119 this.updateUI_();
151 }, 120 },
152 121
153 /** 122 /**
154 * Update current header bar UI. 123 * Update current header bar UI.
(...skipping 21 matching lines...) Expand all
176 set hasApps(value) { 145 set hasApps(value) {
177 this.hasApps_ = value; 146 this.hasApps_ = value;
178 this.updateUI_(); 147 this.updateUI_();
179 }, 148 },
180 149
181 /** 150 /**
182 * Updates visibility state of action buttons. 151 * Updates visibility state of action buttons.
183 * @private 152 * @private
184 */ 153 */
185 updateUI_: function() { 154 updateUI_: function() {
186 var gaiaIsActive = (this.signinUIState_ == SIGNIN_UI_STATE.GAIA_SIGNIN); 155 $('add-user-button').hidden = false;
187 var accountPickerIsActive = 156 $('cancel-add-user-button').hidden = !this.allowCancel_;
188 (this.signinUIState_ == SIGNIN_UI_STATE.ACCOUNT_PICKER); 157 $('guest-user-header-bar-item').hidden = false;
189 var managedUserCreationDialogIsActive = 158 $('add-user-header-bar-item').hidden = false;
190 (this.signinUIState_ == SIGNIN_UI_STATE.MANAGED_USER_CREATION_FLOW); 159 $('apps-header-bar-item').hidden = true;
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 }, 160 },
214 161
215 /** 162 /**
216 * Animates Header bar to hide from the screen. 163 * Animates Header bar to hide from the screen.
217 * @param {function()} callback will be called once animation is finished. 164 * @param {function()} callback will be called once animation is finished.
218 */ 165 */
219 animateOut: function(callback) { 166 animateOut: function(callback) {
220 var launcher = this; 167 var launcher = this;
221 launcher.addEventListener( 168 launcher.addEventListener(
222 'webkitTransitionEnd', function f(e) { 169 'webkitTransitionEnd', function f(e) {
(...skipping 26 matching lines...) Expand all
249 * Convenience wrapper of animateIn. 196 * Convenience wrapper of animateIn.
250 */ 197 */
251 HeaderBar.animateIn = function() { 198 HeaderBar.animateIn = function() {
252 $('login-header-bar').animateIn(); 199 $('login-header-bar').animateIn();
253 } 200 }
254 201
255 return { 202 return {
256 HeaderBar: HeaderBar 203 HeaderBar: HeaderBar
257 }; 204 };
258 }); 205 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698