| Index: chrome/browser/resources/chromeos/login/screen_offline_message.js
|
| diff --git a/chrome/browser/resources/chromeos/login/screen_offline_message.js b/chrome/browser/resources/chromeos/login/screen_offline_message.js
|
| index 7bb6c7d063ee841cada2a7f3ae4614b092e26df2..1d52a989c8859e3b8b05d8756cd16f20b2b3f16e 100644
|
| --- a/chrome/browser/resources/chromeos/login/screen_offline_message.js
|
| +++ b/chrome/browser/resources/chromeos/login/screen_offline_message.js
|
| @@ -33,10 +33,9 @@ cr.define('login', function() {
|
|
|
| /** @inheritDoc */
|
| decorate: function() {
|
| - window.addEventListener('online',
|
| - this.handleNetworkStateChange_.bind(this));
|
| - window.addEventListener('offline',
|
| - this.handleNetworkStateChange_.bind(this));
|
| + chrome.send('loginAddNetworkStateObserver',
|
| + ['login.OfflineMessageScreen.updateState']);
|
| +
|
| cr.ui.DropDown.decorate($('offline-networks-list'));
|
| },
|
|
|
| @@ -48,20 +47,26 @@ cr.define('login', function() {
|
| cr.ui.DropDown.setActive('offline-networks-list', false);
|
| },
|
|
|
| + update: function() {
|
| + chrome.send('loginRequestNetworkState',
|
| + ['login.OfflineMessageScreen.updateState']);
|
| + },
|
| +
|
| /**
|
| * Shows or hides offline message based on network on/offline state.
|
| */
|
| - update: function() {
|
| + updateState: function(state) {
|
| var currentScreen = Oobe.getInstance().currentScreen;
|
| var offlineMessage = this;
|
| - var isOffline = !window.navigator.onLine;
|
| + var isOnline = state == 1;
|
| + var isUnderCaptivePortal = state == 2;
|
| var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1;
|
|
|
| - if (isOffline && shouldOverlay) {
|
| + if (!isOnline && shouldOverlay) {
|
| offlineMessage.onBeforeShow();
|
|
|
| - $('offline-message-text').hidden = false;
|
| - $('captive-portal-message-text').hidden = true;
|
| + $('offline-message-text').hidden = isUnderCaptivePortal;
|
| + $('captive-portal-message-text').hidden = !isUnderCaptivePortal;
|
|
|
| offlineMessage.classList.remove('hidden');
|
| offlineMessage.classList.remove('faded');
|
| @@ -92,13 +97,15 @@ cr.define('login', function() {
|
| }
|
| }
|
| },
|
| + };
|
|
|
| - /**
|
| - * Handler of online/offline event.
|
| - */
|
| - handleNetworkStateChange_: function() {
|
| - this.update();
|
| - }
|
| + /**
|
| + * Network state changed callback.
|
| + * @param {Integer} state Current state of the network: 0 - offline;
|
| + * 1 - online; 2 - under the captive portal.
|
| + */
|
| + OfflineMessageScreen.updateState = function(state) {
|
| + $('offline-message').updateState(state);
|
| };
|
|
|
| /**
|
|
|