| 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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 /** | 73 /** |
| 74 * Updates localized content of the screen that is not updated via template. | 74 * Updates localized content of the screen that is not updated via template. |
| 75 */ | 75 */ |
| 76 updateLocalizedContent_: function() { | 76 updateLocalizedContent_: function() { |
| 77 $('captive-portal-message-text').innerHTML = localStrings.getStringF( | 77 $('captive-portal-message-text').innerHTML = localStrings.getStringF( |
| 78 'captivePortalMessage', | 78 'captivePortalMessage', |
| 79 '<b id="' + CURRENT_NETWORK_NAME_ID + '"></b>', | 79 '<b id="' + CURRENT_NETWORK_NAME_ID + '"></b>', |
| 80 '<a id="' + FIX_CAPTIVE_PORTAL_ID + '" class="signin-link" href="#">', | 80 '<a id="' + FIX_CAPTIVE_PORTAL_ID + '" class="signin-link" href="#">', |
| 81 '</a>'); | 81 '</a>'); |
| 82 $(FIX_CAPTIVE_PORTAL_ID).onclick = function() { | 82 $(FIX_CAPTIVE_PORTAL_ID).onclick = function() { |
| 83 chrome.send('fixCaptivePortal'); | 83 chrome.send('showCaptivePortal'); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 $('proxy-message-text').innerHTML = localStrings.getStringF( | 86 $('proxy-message-text').innerHTML = localStrings.getStringF( |
| 87 'proxyMessageText', | 87 'proxyMessageText', |
| 88 '<a id="' + RELOAD_PAGE_ID + '" class="signin-link" href="#">', | 88 '<a id="' + RELOAD_PAGE_ID + '" class="signin-link" href="#">', |
| 89 '</a>'); | 89 '</a>'); |
| 90 $(RELOAD_PAGE_ID).onclick = function() { | 90 $(RELOAD_PAGE_ID).onclick = function() { |
| 91 var currentScreen = Oobe.getInstance().currentScreen; | 91 var currentScreen = Oobe.getInstance().currentScreen; |
| 92 // Schedules a immediate retry. | 92 // Schedules a immediate retry. |
| 93 currentScreen.doReload(); | 93 currentScreen.doReload(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 */ | 140 */ |
| 141 updateState_: function(state, network, reason, lastNetworkType) { | 141 updateState_: function(state, network, reason, lastNetworkType) { |
| 142 var currentScreen = Oobe.getInstance().currentScreen; | 142 var currentScreen = Oobe.getInstance().currentScreen; |
| 143 var offlineMessage = this; | 143 var offlineMessage = this; |
| 144 var isOnline = (state == NET_STATE.ONLINE); | 144 var isOnline = (state == NET_STATE.ONLINE); |
| 145 var isUnderCaptivePortal = (state == NET_STATE.PORTAL); | 145 var isUnderCaptivePortal = (state == NET_STATE.PORTAL); |
| 146 var isProxyError = reason == ERROR_REASONS.PROXY_AUTH_CANCELLED || | 146 var isProxyError = reason == ERROR_REASONS.PROXY_AUTH_CANCELLED || |
| 147 reason == ERROR_REASONS.PROXY_CONNECTION_FAILED; | 147 reason == ERROR_REASONS.PROXY_CONNECTION_FAILED; |
| 148 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1 && | 148 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1 && |
| 149 !currentScreen.isLocal; | 149 !currentScreen.isLocal; |
| 150 var isTimeout = false; |
| 150 | 151 |
| 151 if (reason == ERROR_REASONS.PROXY_CONFIG_CHANGED && shouldOverlay && | 152 if (reason == ERROR_REASONS.PROXY_CONFIG_CHANGED && shouldOverlay && |
| 152 !offlineMessage.classList.contains('hidden') && | 153 !offlineMessage.classList.contains('hidden') && |
| 153 offlineMessage.classList.contains('show-captive-portal')) { | 154 offlineMessage.classList.contains('show-captive-portal')) { |
| 154 // Schedules a immediate retry. | 155 // Schedules a immediate retry. |
| 155 currentScreen.doReload(); | 156 currentScreen.doReload(); |
| 156 console.log('Retry page load since proxy settings has been changed'); | 157 console.log('Retry page load since proxy settings has been changed'); |
| 157 } | 158 } |
| 158 | 159 |
| 159 // Fake portal state for loading timeout. | 160 // Fake portal state for loading timeout. |
| 160 if (reason == ERROR_REASONS.LOADING_TIMEOUT) { | 161 if (reason == ERROR_REASONS.LOADING_TIMEOUT) { |
| 161 isOnline = false; | 162 isOnline = false; |
| 162 isUnderCaptivePortal = true; | 163 isUnderCaptivePortal = true; |
| 164 isTimeout = true; |
| 163 } | 165 } |
| 164 | 166 |
| 167 // Portal was detected via generate_204 redirect on Chrome side. |
| 168 // Subsequent call to show dialog if it's already shown does nothing. |
| 165 if (reason == ERROR_REASONS.PORTAL_DETECTED) { | 169 if (reason == ERROR_REASONS.PORTAL_DETECTED) { |
| 166 isOnline = false; | 170 isOnline = false; |
| 167 isUnderCaptivePortal = true; | 171 isUnderCaptivePortal = true; |
| 168 } | 172 } |
| 169 | 173 |
| 170 if (!isOnline && shouldOverlay) { | 174 if (!isOnline && shouldOverlay) { |
| 171 console.log('Show offline message: state=' + state + | 175 console.log('Show offline message: state=' + state + |
| 172 ', network=' + network + ', reason=' + reason, | 176 ', network=' + network + ', reason=' + reason, |
| 173 ', isUnderCaptivePortal=' + isUnderCaptivePortal); | 177 ', isUnderCaptivePortal=' + isUnderCaptivePortal); |
| 174 | 178 |
| 175 | 179 |
| 176 offlineMessage.onBeforeShow(lastNetworkType); | 180 offlineMessage.onBeforeShow(lastNetworkType); |
| 177 | 181 |
| 178 if (isUnderCaptivePortal && !isProxyError) | 182 if (isUnderCaptivePortal && !isProxyError) { |
| 179 chrome.send('fixCaptivePortal'); | 183 // In case of timeout we're suspecting that network might be |
| 180 else | 184 // a captive portal but would like to check that first. |
| 185 // Otherwise (signal from flimflam / generate_204 got redirected) |
| 186 // show dialog right away. |
| 187 if (isTimeout) |
| 188 chrome.send('fixCaptivePortal'); |
| 189 else |
| 190 chrome.send('showCaptivePortal'); |
| 191 } else { |
| 181 chrome.send('hideCaptivePortal'); | 192 chrome.send('hideCaptivePortal'); |
| 193 } |
| 182 | 194 |
| 183 if (isUnderCaptivePortal) { | 195 if (isUnderCaptivePortal) { |
| 184 if (isProxyError) { | 196 if (isProxyError) { |
| 185 offlineMessage.classList.remove('show-offline-message'); | 197 offlineMessage.classList.remove('show-offline-message'); |
| 186 offlineMessage.classList.remove('show-captive-portal'); | 198 offlineMessage.classList.remove('show-captive-portal'); |
| 187 offlineMessage.classList.add('show-proxy-error'); | 199 offlineMessage.classList.add('show-proxy-error'); |
| 188 } else { | 200 } else { |
| 189 $(CURRENT_NETWORK_NAME_ID).textContent = network; | 201 $(CURRENT_NETWORK_NAME_ID).textContent = network; |
| 190 offlineMessage.classList.remove('show-offline-message'); | 202 offlineMessage.classList.remove('show-offline-message'); |
| 191 offlineMessage.classList.remove('show-proxy-error'); | 203 offlineMessage.classList.remove('show-proxy-error'); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 * via template. | 321 * via template. |
| 310 */ | 322 */ |
| 311 ErrorMessageScreen.updateLocalizedContent = function() { | 323 ErrorMessageScreen.updateLocalizedContent = function() { |
| 312 $('error-message').updateLocalizedContent_(); | 324 $('error-message').updateLocalizedContent_(); |
| 313 }; | 325 }; |
| 314 | 326 |
| 315 return { | 327 return { |
| 316 ErrorMessageScreen: ErrorMessageScreen | 328 ErrorMessageScreen: ErrorMessageScreen |
| 317 }; | 329 }; |
| 318 }); | 330 }); |
| OLD | NEW |