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

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

Issue 385073008: Browser-based guest policy implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 Desktop User Chooser UI control 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_: true, 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.ACCOUNT_PICKER, 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 /**
30 * Guest button click handler.
31 * @private
32 */
33 handleGuestClick_: function(e) {
34 chrome.send('launchGuest');
35 e.stopPropagation();
36 },
37
29 /** @override */ 38 /** @override */
30 decorate: function() { 39 decorate: function() {
31 $('add-user-button').addEventListener('click', 40 $('add-user-button').addEventListener('click',
32 this.handleAddUserClick_); 41 this.handleAddUserClick_);
33 $('cancel-add-user-button').addEventListener('click', 42 $('cancel-add-user-button').addEventListener('click',
34 this.handleCancelAddUserClick_); 43 this.handleCancelAddUserClick_);
35 $('guest-user-header-bar-item').addEventListener('click', 44 $('guest-user-header-bar-item').addEventListener('click',
36 this.handleGuestClick_); 45 this.handleGuestClick_);
37 $('guest-user-button').addEventListener('click', 46 $('guest-user-button').addEventListener('click',
38 this.handleGuestClick_); 47 this.handleGuestClick_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Oobe.getInstance().currentScreen.cancel) { 92 Oobe.getInstance().currentScreen.cancel) {
84 Oobe.getInstance().currentScreen.cancel(); 93 Oobe.getInstance().currentScreen.cancel();
85 return; 94 return;
86 } 95 }
87 96
88 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); 97 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER});
89 Oobe.resetSigninUI(true); 98 Oobe.resetSigninUI(true);
90 }, 99 },
91 100
92 /** 101 /**
93 * Guest button click handler.
94 * @private
95 */
96 handleGuestClick_: function(e) {
97 chrome.send('launchGuest');
98 e.stopPropagation();
99 },
100
101 /**
102 * If true then "Browse as Guest" button is shown. 102 * If true then "Browse as Guest" button is shown.
103 * @type {boolean} 103 * @type {boolean}
104 */ 104 */
105 set showGuestButton(value) { 105 set showGuestButton(value) {
106 this.showGuest_ = value; 106 this.showGuest_ = value;
107 this.updateUI_(); 107 this.updateUI_();
108 }, 108 },
109 109
110 /** 110 /**
111 * Update current header bar UI. 111 * Update current header bar UI.
(...skipping 16 matching lines...) Expand all
128 128
129 /** 129 /**
130 * Updates visibility state of action buttons. 130 * Updates visibility state of action buttons.
131 * @private 131 * @private
132 */ 132 */
133 updateUI_: function() { 133 updateUI_: function() {
134 $('add-user-button').hidden = false; 134 $('add-user-button').hidden = false;
135 $('cancel-add-user-button').hidden = !this.allowCancel_; 135 $('cancel-add-user-button').hidden = !this.allowCancel_;
136 $('guest-user-header-bar-item').hidden = false; 136 $('guest-user-header-bar-item').hidden = false;
137 $('add-user-header-bar-item').hidden = false; 137 $('add-user-header-bar-item').hidden = false;
138 $('guest-user-button').hidden = !this.showGuest_;
139 if (!this.showGuest_) {
140 $('guest-user-header-bar-item').removeEventListener('click',
141 this.handleGuestClick_);
142 $('guest-user-button').removeEventListener('click',
143 this.handleGuestClick_);
144 $('guest-user-button').disabled = true;
145 }
138 }, 146 },
139 147
140 /** 148 /**
141 * Animates Header bar to hide from the screen. 149 * Animates Header bar to hide from the screen.
142 * @param {function()} callback will be called once animation is finished. 150 * @param {function()} callback will be called once animation is finished.
143 */ 151 */
144 animateOut: function(callback) { 152 animateOut: function(callback) {
145 var launcher = this; 153 var launcher = this;
146 launcher.addEventListener( 154 launcher.addEventListener(
147 'webkitTransitionEnd', function f(e) { 155 'webkitTransitionEnd', function f(e) {
(...skipping 26 matching lines...) Expand all
174 * Convenience wrapper of animateIn. 182 * Convenience wrapper of animateIn.
175 */ 183 */
176 HeaderBar.animateIn = function() { 184 HeaderBar.animateIn = function() {
177 $('login-header-bar').animateIn(); 185 $('login-header-bar').animateIn();
178 } 186 }
179 187
180 return { 188 return {
181 HeaderBar: HeaderBar 189 HeaderBar: HeaderBar
182 }; 190 };
183 }); 191 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698