Chromium Code Reviews| 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 Offline message screen implementation. | 6 * @fileoverview Offline message screen implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('login', function() { | 9 cr.define('login', function() { |
| 10 // Screens that should have offline message overlay. | 10 // Screens that should have offline message overlay. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 // TODO(altimofeev): Support offline sign-in as well. | 87 // TODO(altimofeev): Support offline sign-in as well. |
| 88 $('error-guest-signin').innerHTML = localStrings.getStringF( | 88 $('error-guest-signin').innerHTML = localStrings.getStringF( |
| 89 'guestSignin', | 89 'guestSignin', |
| 90 '<a id="error-guest-signin-link" class="signin-link" href="#">', | 90 '<a id="error-guest-signin-link" class="signin-link" href="#">', |
| 91 '</a>'); | 91 '</a>'); |
| 92 $('error-guest-signin-link').onclick = function() { | 92 $('error-guest-signin-link').onclick = function() { |
| 93 chrome.send('launchIncognito'); | 93 chrome.send('launchIncognito'); |
| 94 }; | 94 }; |
| 95 }, | 95 }, |
| 96 | 96 |
| 97 onBeforeShow: function() { | 97 onBeforeShow: function(last) { |
| 98 cr.ui.DropDown.setActive('offline-networks-list', true, false); | 98 cr.ui.DropDown.show('offline-networks-list', false, last); |
| 99 | 99 |
| 100 $('error-guest-signin').hidden = $('guestSignin').hidden || | 100 $('error-guest-signin').hidden = $('guestSignin').hidden || |
| 101 !$('add-user-header-bar-item').hidden; | 101 !$('add-user-header-bar-item').hidden; |
| 102 }, | 102 }, |
| 103 | 103 |
| 104 onBeforeHide: function() { | 104 onBeforeHide: function() { |
| 105 cr.ui.DropDown.setActive('offline-networks-list', false, false); | 105 cr.ui.DropDown.hide('offline-networks-list'); |
| 106 }, | 106 }, |
| 107 | 107 |
| 108 update: function() { | 108 update: function() { |
| 109 chrome.send('loginRequestNetworkState', | 109 chrome.send('loginRequestNetworkState', |
| 110 ['login.ErrorMessageScreen.updateState', | 110 ['login.ErrorMessageScreen.updateState', |
| 111 'update']); | 111 'update']); |
| 112 }, | 112 }, |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * Shows or hides offline message based on network on/offline state. | 115 * Shows or hides offline message based on network on/offline state. |
|
whywhat
2011/11/29 07:58:06
Add comments about the parameters, please.
altimofeev
2011/11/29 17:10:46
Done.
| |
| 116 */ | 116 */ |
| 117 updateState_: function(state, network, reason) { | 117 updateState_: function(state, network, reason, last) { |
|
whywhat
2011/11/29 07:58:06
Ditto about last
altimofeev
2011/11/29 17:10:46
Done.
| |
| 118 var currentScreen = Oobe.getInstance().currentScreen; | 118 var currentScreen = Oobe.getInstance().currentScreen; |
| 119 var offlineMessage = this; | 119 var offlineMessage = this; |
| 120 var isOnline = (state == NET_STATE.ONLINE); | 120 var isOnline = (state == NET_STATE.ONLINE); |
| 121 var isUnderCaptivePortal = (state == NET_STATE.PORTAL); | 121 var isUnderCaptivePortal = (state == NET_STATE.PORTAL); |
| 122 var isProxyError = reason == ERROR_REASONS.PROXY_AUTH_CANCELLED || | 122 var isProxyError = reason == ERROR_REASONS.PROXY_AUTH_CANCELLED || |
| 123 reason == ERROR_REASONS.PROXY_CONNECTION_FAILED; | 123 reason == ERROR_REASONS.PROXY_CONNECTION_FAILED; |
| 124 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1; | 124 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1; |
| 125 | 125 |
| 126 if (reason == 'proxy changed' && shouldOverlay && | 126 if (reason == 'proxy changed' && shouldOverlay && |
| 127 !offlineMessage.classList.contains('hidden') && | 127 !offlineMessage.classList.contains('hidden') && |
| 128 offlineMessage.classList.contains('show-captive-portal')) { | 128 offlineMessage.classList.contains('show-captive-portal')) { |
| 129 // Schedules a immediate retry. | 129 // Schedules a immediate retry. |
| 130 currentScreen.doReload(); | 130 currentScreen.doReload(); |
| 131 console.log('Retry page load since proxy settings has been changed'); | 131 console.log('Retry page load since proxy settings has been changed'); |
| 132 } | 132 } |
| 133 | 133 |
| 134 if (!isOnline && shouldOverlay) { | 134 if (!isOnline && shouldOverlay) { |
| 135 console.log('Show offline message, state=' + state + | 135 console.log('Show offline message, state=' + state + |
| 136 ', network=' + network + | 136 ', network=' + network + |
| 137 ', isUnderCaptivePortal=' + isUnderCaptivePortal); | 137 ', isUnderCaptivePortal=' + isUnderCaptivePortal); |
| 138 offlineMessage.onBeforeShow(); | 138 offlineMessage.onBeforeShow(last); |
| 139 | 139 |
| 140 if (isUnderCaptivePortal) { | 140 if (isUnderCaptivePortal) { |
| 141 if (isProxyError) { | 141 if (isProxyError) { |
| 142 offlineMessage.classList.remove('show-offline-message'); | 142 offlineMessage.classList.remove('show-offline-message'); |
| 143 offlineMessage.classList.remove('show-captive-portal'); | 143 offlineMessage.classList.remove('show-captive-portal'); |
| 144 offlineMessage.classList.add('show-proxy-error'); | 144 offlineMessage.classList.add('show-proxy-error'); |
| 145 } else { | 145 } else { |
| 146 $(CURRENT_NETWORK_NAME_ID).textContent = network; | 146 $(CURRENT_NETWORK_NAME_ID).textContent = network; |
| 147 offlineMessage.classList.remove('show-offline-message'); | 147 offlineMessage.classList.remove('show-offline-message'); |
| 148 offlineMessage.classList.remove('show-proxy-error'); | 148 offlineMessage.classList.remove('show-proxy-error'); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 }, | 186 }, |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * Network state changed callback. | 190 * Network state changed callback. |
| 191 * @param {Integer} state Current state of the network (see NET_STATE). | 191 * @param {Integer} state Current state of the network (see NET_STATE). |
| 192 * @param {string} network Name of the current network. | 192 * @param {string} network Name of the current network. |
| 193 * @param {string} reason Reason the callback was called. | 193 * @param {string} reason Reason the callback was called. |
| 194 * @param {int} last Last active network type. | |
| 194 */ | 195 */ |
| 195 ErrorMessageScreen.updateState = function(state, network, reason) { | 196 ErrorMessageScreen.updateState = function(state, network, reason, last) { |
| 196 $('error-message').updateState_(state, network, reason); | 197 $('error-message').updateState_(state, network, reason, last); |
| 197 }; | 198 }; |
| 198 | 199 |
| 199 /** | 200 /** |
| 200 * Handler for iframe's error notification coming from the outside. | 201 * Handler for iframe's error notification coming from the outside. |
| 201 * For more info see C++ class 'SnifferObserver' which calls this method. | 202 * For more info see C++ class 'SnifferObserver' which calls this method. |
| 202 * @param {number} error Error code. | 203 * @param {number} error Error code. |
| 203 */ | 204 */ |
| 204 ErrorMessageScreen.onFrameError = function(error) { | 205 ErrorMessageScreen.onFrameError = function(error) { |
| 205 console.log('Gaia frame error = ' + error); | 206 console.log('Gaia frame error = ' + error); |
| 206 if (error == NET_ERROR.ABORTED_BY_USER) { | 207 if (error == NET_ERROR.ABORTED_BY_USER) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 this.updateState(NET_STATE.PORTAL, network, reason); | 239 this.updateState(NET_STATE.PORTAL, network, reason); |
| 239 // Schedules a retry. | 240 // Schedules a retry. |
| 240 currentScreen.scheduleRetry(); | 241 currentScreen.scheduleRetry(); |
| 241 } | 242 } |
| 242 }; | 243 }; |
| 243 | 244 |
| 244 return { | 245 return { |
| 245 ErrorMessageScreen: ErrorMessageScreen | 246 ErrorMessageScreen: ErrorMessageScreen |
| 246 }; | 247 }; |
| 247 }); | 248 }); |
| OLD | NEW |