| OLD | NEW |
| 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 * | 12 * |
| 13 * @constructor | 13 * @constructor |
| 14 * @extends {HTMLDivElement} | 14 * @extends {HTMLDivElement} |
| 15 */ | 15 */ |
| 16 var HeaderBar = cr.ui.define('div'); | 16 var HeaderBar = cr.ui.define('div'); |
| 17 | 17 |
| 18 HeaderBar.prototype = { | 18 HeaderBar.prototype = { |
| 19 __proto__: HTMLDivElement.prototype, | 19 __proto__: HTMLDivElement.prototype, |
| 20 | 20 |
| 21 // Whether guest button should be shown when header bar is in normal mode. | 21 // Whether guest button should be shown when header bar is in normal mode. |
| 22 showGuest_: false, | 22 showGuest_: false, |
| 23 | 23 |
| 24 // Whehter MinuteMaid flow is active. |
| 25 isMinuteMaid_: false, |
| 26 |
| 24 // Whether the reboot button should be shown the when header bar is in | 27 // Whether the reboot button should be shown the when header bar is in |
| 25 // normal mode. | 28 // normal mode. |
| 26 showReboot_: false, | 29 showReboot_: false, |
| 27 | 30 |
| 28 // Whether the shutdown button should be shown when the header bar is in | 31 // Whether the shutdown button should be shown when the header bar is in |
| 29 // normal mode. | 32 // normal mode. |
| 30 showShutdown_: true, | 33 showShutdown_: true, |
| 31 | 34 |
| 35 // Whether the create supervised user button should be shown when the header |
| 36 // bar is in normal mode. It will be shown in "More settings" menu. |
| 37 showCreateSupervised_: false, |
| 38 |
| 32 // Current UI state of the sign-in screen. | 39 // Current UI state of the sign-in screen. |
| 33 signinUIState_: SIGNIN_UI_STATE.HIDDEN, | 40 signinUIState_: SIGNIN_UI_STATE.HIDDEN, |
| 34 | 41 |
| 35 // Whether to show kiosk apps menu. | 42 // Whether to show kiosk apps menu. |
| 36 hasApps_: false, | 43 hasApps_: false, |
| 37 | 44 |
| 38 /** @override */ | 45 /** @override */ |
| 39 decorate: function() { | 46 decorate: function() { |
| 47 document.addEventListener('click', this.handleClick_.bind(this)); |
| 40 $('shutdown-header-bar-item').addEventListener('click', | 48 $('shutdown-header-bar-item').addEventListener('click', |
| 41 this.handleShutdownClick_); | 49 this.handleShutdownClick_); |
| 42 $('shutdown-button').addEventListener('click', | 50 $('shutdown-button').addEventListener('click', |
| 43 this.handleShutdownClick_); | 51 this.handleShutdownClick_); |
| 44 $('restart-header-bar-item').addEventListener('click', | 52 $('restart-header-bar-item').addEventListener('click', |
| 45 this.handleShutdownClick_); | 53 this.handleShutdownClick_); |
| 46 $('restart-button').addEventListener('click', | 54 $('restart-button').addEventListener('click', |
| 47 this.handleShutdownClick_); | 55 this.handleShutdownClick_); |
| 48 $('add-user-button').addEventListener('click', | 56 $('add-user-button').addEventListener('click', |
| 49 this.handleAddUserClick_); | 57 this.handleAddUserClick_); |
| 58 $('more-settings-button').addEventListener('click', |
| 59 this.handleMoreSettingsClick_.bind(this)); |
| 50 $('cancel-add-user-button').addEventListener('click', | 60 $('cancel-add-user-button').addEventListener('click', |
| 51 this.handleCancelAddUserClick_); | 61 this.handleCancelAddUserClick_); |
| 52 $('guest-user-header-bar-item').addEventListener('click', | 62 $('guest-user-header-bar-item').addEventListener('click', |
| 53 this.handleGuestClick_); | 63 this.handleGuestClick_); |
| 54 $('guest-user-button').addEventListener('click', | 64 $('guest-user-button').addEventListener('click', |
| 55 this.handleGuestClick_); | 65 this.handleGuestClick_); |
| 56 $('sign-out-user-button').addEventListener('click', | 66 $('sign-out-user-button').addEventListener('click', |
| 57 this.handleSignoutClick_); | 67 this.handleSignoutClick_); |
| 58 $('cancel-multiple-sign-in-button').addEventListener('click', | 68 $('cancel-multiple-sign-in-button').addEventListener('click', |
| 59 this.handleCancelMultipleSignInClick_); | 69 this.handleCancelMultipleSignInClick_); |
| 60 $('cancel-consumer-management-enrollment-button').addEventListener( | 70 $('cancel-consumer-management-enrollment-button').addEventListener( |
| 61 'click', | 71 'click', |
| 62 this.handleCancelConsumerManagementEnrollmentClick_); | 72 this.handleCancelConsumerManagementEnrollmentClick_); |
| 73 this.addSupervisedUserMenu.addEventListener('click', |
| 74 this.handleAddSupervisedUserClick_.bind(this)); |
| 63 if (Oobe.getInstance().displayType == DISPLAY_TYPE.LOGIN || | 75 if (Oobe.getInstance().displayType == DISPLAY_TYPE.LOGIN || |
| 64 Oobe.getInstance().displayType == DISPLAY_TYPE.OOBE) { | 76 Oobe.getInstance().displayType == DISPLAY_TYPE.OOBE) { |
| 65 if (Oobe.getInstance().newKioskUI) | 77 if (Oobe.getInstance().newKioskUI) |
| 66 chrome.send('initializeKioskApps'); | 78 chrome.send('initializeKioskApps'); |
| 67 else | 79 else |
| 68 login.AppsMenuButton.decorate($('show-apps-button')); | 80 login.AppsMenuButton.decorate($('show-apps-button')); |
| 69 } | 81 } |
| 70 this.updateUI_(); | 82 this.updateUI_(); |
| 71 }, | 83 }, |
| 72 | 84 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 87 * | 99 * |
| 88 * @type {boolean} | 100 * @type {boolean} |
| 89 */ | 101 */ |
| 90 set disabled(value) { | 102 set disabled(value) { |
| 91 var buttons = this.getElementsByTagName('button'); | 103 var buttons = this.getElementsByTagName('button'); |
| 92 for (var i = 0, button; button = buttons[i]; ++i) | 104 for (var i = 0, button; button = buttons[i]; ++i) |
| 93 if (!button.classList.contains('button-restricted')) | 105 if (!button.classList.contains('button-restricted')) |
| 94 button.disabled = value; | 106 button.disabled = value; |
| 95 }, | 107 }, |
| 96 | 108 |
| 109 get getMoreSettingsMenu() { |
| 110 return $('more-settings-header-bar-item'); |
| 111 }, |
| 112 |
| 113 get addSupervisedUserMenu() { |
| 114 return this.querySelector('.add-supervised-user-menu'); |
| 115 }, |
| 116 |
| 117 /** |
| 118 * Whether action box button is in active state. |
| 119 * @type {boolean} |
| 120 */ |
| 121 get isMoreSettingsActive() { |
| 122 return this.getMoreSettingsMenu.classList.contains('active'); |
| 123 }, |
| 124 set isMoreSettingsActive(active) { |
| 125 if (active == this.isMoreSettingsActive) |
| 126 return; |
| 127 if (active) { |
| 128 this.getMoreSettingsMenu.classList.add('active'); |
| 129 } else { |
| 130 this.getMoreSettingsMenu.classList.remove('active'); |
| 131 } |
| 132 }, |
| 133 |
| 134 |
| 97 /** | 135 /** |
| 98 * Add user button click handler. | 136 * Add user button click handler. |
| 99 * | 137 * |
| 100 * @private | 138 * @private |
| 101 */ | 139 */ |
| 102 handleAddUserClick_: function(e) { | 140 handleAddUserClick_: function(e) { |
| 103 Oobe.showSigninUI(); | 141 Oobe.showSigninUI(); |
| 104 // Prevent further propagation of click event. Otherwise, the click event | 142 // Prevent further propagation of click event. Otherwise, the click event |
| 105 // handler of document object will set wallpaper to user's wallpaper when | 143 // handler of document object will set wallpaper to user's wallpaper when |
| 106 // there is only one existing user. See http://crbug.com/166477 | 144 // there is only one existing user. See http://crbug.com/166477 |
| 107 e.stopPropagation(); | 145 e.stopPropagation(); |
| 108 }, | 146 }, |
| 109 | 147 |
| 148 handleMoreSettingsClick_: function(e) { |
| 149 this.isMoreSettingsActive = !this.isMoreSettingsActive; |
| 150 e.stopPropagation(); |
| 151 }, |
| 152 |
| 153 handleClick_: function(e) { |
| 154 this.isMoreSettingsActive = false; |
| 155 }, |
| 156 |
| 157 handleAddSupervisedUserClick_: function(e) { |
| 158 chrome.send('showSupervisedUserCreationScreen'); |
| 159 e.preventDefault(); |
| 160 }, |
| 110 /** | 161 /** |
| 111 * Cancel add user button click handler. | 162 * Cancel add user button click handler. |
| 112 * | 163 * |
| 113 * @private | 164 * @private |
| 114 */ | 165 */ |
| 115 handleCancelAddUserClick_: function(e) { | 166 handleCancelAddUserClick_: function(e) { |
| 116 // Let screen handle cancel itself if that is capable of doing so. | 167 // Let screen handle cancel itself if that is capable of doing so. |
| 117 if (Oobe.getInstance().currentScreen && | 168 if (Oobe.getInstance().currentScreen && |
| 118 Oobe.getInstance().currentScreen.cancel) { | 169 Oobe.getInstance().currentScreen.cancel) { |
| 119 Oobe.getInstance().currentScreen.cancel(); | 170 Oobe.getInstance().currentScreen.cancel(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 /** | 232 /** |
| 182 * If true then "Browse as Guest" button is shown. | 233 * If true then "Browse as Guest" button is shown. |
| 183 * | 234 * |
| 184 * @type {boolean} | 235 * @type {boolean} |
| 185 */ | 236 */ |
| 186 set showGuestButton(value) { | 237 set showGuestButton(value) { |
| 187 this.showGuest_ = value; | 238 this.showGuest_ = value; |
| 188 this.updateUI_(); | 239 this.updateUI_(); |
| 189 }, | 240 }, |
| 190 | 241 |
| 242 set minuteMaid(value) { |
| 243 this.isMinuteMaid_ = value; |
| 244 this.updateUI_(); |
| 245 }, |
| 246 |
| 247 set showCreateSupervisedButton(value) { |
| 248 this.showCreateSupervised_ = value; |
| 249 this.updateUI_(); |
| 250 }, |
| 251 |
| 191 /** | 252 /** |
| 192 * If true the "Restart" button is shown. | 253 * If true the "Restart" button is shown. |
| 193 * | 254 * |
| 194 * @type {boolean} | 255 * @type {boolean} |
| 195 */ | 256 */ |
| 196 set showRebootButton(value) { | 257 set showRebootButton(value) { |
| 197 this.showReboot_ = value; | 258 this.showReboot_ = value; |
| 198 this.updateUI_(); | 259 this.updateUI_(); |
| 199 }, | 260 }, |
| 200 | 261 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 (this.signinUIState_ == SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM); | 321 (this.signinUIState_ == SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM); |
| 261 var isEnrollingConsumerManagement = (this.signinUIState_ == | 322 var isEnrollingConsumerManagement = (this.signinUIState_ == |
| 262 SIGNIN_UI_STATE.CONSUMER_MANAGEMENT_ENROLLMENT); | 323 SIGNIN_UI_STATE.CONSUMER_MANAGEMENT_ENROLLMENT); |
| 263 var isMultiProfilesUI = | 324 var isMultiProfilesUI = |
| 264 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | 325 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
| 265 var isLockScreen = | 326 var isLockScreen = |
| 266 (Oobe.getInstance().displayType == DISPLAY_TYPE.LOCK); | 327 (Oobe.getInstance().displayType == DISPLAY_TYPE.LOCK); |
| 267 | 328 |
| 268 $('add-user-button').hidden = | 329 $('add-user-button').hidden = |
| 269 !accountPickerIsActive || isMultiProfilesUI || isLockScreen; | 330 !accountPickerIsActive || isMultiProfilesUI || isLockScreen; |
| 270 $('cancel-add-user-button').hidden = accountPickerIsActive || | 331 $('more-settings-header-bar-item').hidden = !this.isMinuteMaid_ || |
| 332 !gaiaIsActive || |
| 333 !this.showCreateSupervised_; |
| 334 $('cancel-add-user-button').hidden = |
| 335 (gaiaIsActive && this.isMinuteMaid_) || |
| 336 accountPickerIsActive || |
| 271 !this.allowCancel_ || | 337 !this.allowCancel_ || |
| 272 wrongHWIDWarningIsActive || | 338 wrongHWIDWarningIsActive || |
| 273 isMultiProfilesUI; | 339 isMultiProfilesUI; |
| 274 $('guest-user-header-bar-item').hidden = gaiaIsActive || | 340 $('guest-user-header-bar-item').hidden = |
| 341 (gaiaIsActive && !this.isMinuteMaid_) || |
| 275 supervisedUserCreationDialogIsActive || | 342 supervisedUserCreationDialogIsActive || |
| 276 !this.showGuest_ || | 343 !this.showGuest_ || |
| 277 wrongHWIDWarningIsActive || | 344 wrongHWIDWarningIsActive || |
| 278 isSamlPasswordConfirm || | 345 isSamlPasswordConfirm || |
| 279 isMultiProfilesUI; | 346 isMultiProfilesUI; |
| 280 $('restart-header-bar-item').hidden = !this.showReboot_; | 347 $('restart-header-bar-item').hidden = !this.showReboot_; |
| 281 $('shutdown-header-bar-item').hidden = !this.showShutdown_; | 348 $('shutdown-header-bar-item').hidden = !this.showShutdown_; |
| 282 $('sign-out-user-item').hidden = !isLockScreen; | 349 $('sign-out-user-item').hidden = !isLockScreen; |
| 283 | 350 |
| 284 $('add-user-header-bar-item').hidden = | 351 $('add-user-header-bar-item').hidden = |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 * Convenience wrapper of animateIn. | 424 * Convenience wrapper of animateIn. |
| 358 */ | 425 */ |
| 359 HeaderBar.animateIn = function(fast, callback) { | 426 HeaderBar.animateIn = function(fast, callback) { |
| 360 $('login-header-bar').animateIn(fast, callback); | 427 $('login-header-bar').animateIn(fast, callback); |
| 361 }; | 428 }; |
| 362 | 429 |
| 363 return { | 430 return { |
| 364 HeaderBar: HeaderBar | 431 HeaderBar: HeaderBar |
| 365 }; | 432 }; |
| 366 }); | 433 }); |
| OLD | NEW |