| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 11 /** |
| 12 * Creates a header bar element. | 12 * Creates a header bar element. |
| 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 /** @inheritDoc */ | 21 /** @inheritDoc */ |
| 22 decorate: function() { | 22 decorate: function() { |
| 23 $('shutdown-header-bar-item').addEventListener('click', | 23 $('shutdown-header-bar-item').addEventListener('click', |
| 24 this.handleShutdownClick_); | 24 this.handleShutdownClick_); |
| 25 $('shutdown-button').addEventListener('click', | 25 $('shutdown-button').addEventListener('click', |
| 26 this.handleShutdownClick_); | 26 this.handleShutdownClick_); |
| 27 $('add-user-button').addEventListener('click', function(e) { | 27 $('add-user-button').addEventListener('click', function(e) { |
| 28 if (window.navigator.onLine) { | 28 chrome.send('loginRequestNetworkState', |
| 29 Oobe.showSigninUI(); | 29 ['login.HeaderBar.updateState']); |
| 30 } else { | |
| 31 $('bubble').showTextForElement($('add-user-button'), | |
| 32 localStrings.getString('addUserOfflineMessage')); | |
| 33 } | |
| 34 }); | 30 }); |
| 35 $('cancel-add-user-button').addEventListener('click', function(e) { | 31 $('cancel-add-user-button').addEventListener('click', function(e) { |
| 36 this.hidden = true; | 32 this.hidden = true; |
| 37 $('add-user-button').hidden = false; | 33 $('add-user-button').hidden = false; |
| 38 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); | 34 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); |
| 39 }); | 35 }); |
| 40 }, | 36 }, |
| 41 | 37 |
| 42 /** | 38 /** |
| 43 * Shutdown button click handler. | 39 * Shutdown button click handler. |
| 44 * @private | 40 * @private |
| 45 */ | 41 */ |
| 46 handleShutdownClick_: function(e) { | 42 handleShutdownClick_: function(e) { |
| 47 chrome.send('shutdownSystem'); | 43 chrome.send('shutdownSystem'); |
| 48 } | 44 } |
| 49 }; | 45 }; |
| 50 | 46 |
| 47 /** |
| 48 * Network state changed callback. |
| 49 * @param {Integer} state Current state of the network: 0 - offline; |
| 50 * 1 - online; 2 - under the captive portal. |
| 51 */ |
| 52 HeaderBar.updateState = function(state) { |
| 53 var isOffline = state == 0; |
| 54 if (!isOffline) { |
| 55 Oobe.showSigninUI(); |
| 56 } else { |
| 57 $('bubble').showTextForElement($('add-user-button'), |
| 58 localStrings.getString('addUserOfflineMessage')); |
| 59 } |
| 60 } |
| 61 |
| 51 return { | 62 return { |
| 52 HeaderBar: HeaderBar | 63 HeaderBar: HeaderBar |
| 53 }; | 64 }; |
| 54 }); | 65 }); |
| OLD | NEW |