| 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 // Link which starts guest session for captive portal fixing. | 10 // Link which starts guest session for captive portal fixing. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 chrome.send('launchIncognito'); | 96 chrome.send('launchIncognito'); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 $('error-offline-login').innerHTML = loadTimeData.getStringF( | 99 $('error-offline-login').innerHTML = loadTimeData.getStringF( |
| 100 'offlineLogin', | 100 'offlineLogin', |
| 101 '<a id="error-offline-login-link" class="signin-link" href="#">', | 101 '<a id="error-offline-login-link" class="signin-link" href="#">', |
| 102 '</a>'); | 102 '</a>'); |
| 103 $('error-offline-login-link').onclick = function() { | 103 $('error-offline-login-link').onclick = function() { |
| 104 chrome.send('offlineLogin'); | 104 chrome.send('offlineLogin'); |
| 105 }; | 105 }; |
| 106 this.onContentChange_(); |
| 106 }, | 107 }, |
| 107 | 108 |
| 108 /** | 109 /** |
| 109 * Event handler that is invoked just before the screen in shown. | 110 * Event handler that is invoked just before the screen in shown. |
| 110 * @param {Object} data Screen init payload. | 111 * @param {Object} data Screen init payload. |
| 111 */ | 112 */ |
| 112 onBeforeShow: function(data) { | 113 onBeforeShow: function(data) { |
| 113 cr.ui.Oobe.clearErrors(); | 114 cr.ui.Oobe.clearErrors(); |
| 114 var lastNetworkType = data['lastNetworkType'] || 0; | 115 var lastNetworkType = data['lastNetworkType'] || 0; |
| 115 cr.ui.DropDown.show('offline-networks-list', false, lastNetworkType); | 116 cr.ui.DropDown.show('offline-networks-list', false, lastNetworkType); |
| 116 }, | 117 }, |
| 117 | 118 |
| 118 /** | 119 /** |
| 119 * Event handler that is invoked just before the screen is hidden. | 120 * Event handler that is invoked just before the screen is hidden. |
| 120 */ | 121 */ |
| 121 onBeforeHide: function() { | 122 onBeforeHide: function() { |
| 122 cr.ui.DropDown.hide('offline-networks-list'); | 123 cr.ui.DropDown.hide('offline-networks-list'); |
| 123 }, | 124 }, |
| 124 | 125 |
| 125 /** | 126 /** |
| 127 * Method called after content of the screen changed. |
| 128 * @private |
| 129 */ |
| 130 onContentChange_: function() { |
| 131 if (Oobe.getInstance().currentScreen === this) |
| 132 Oobe.getInstance().updateScreenSize(this); |
| 133 }, |
| 134 |
| 135 /** |
| 126 * Sets current state of the error screen. | 136 * Sets current state of the error screen. |
| 127 * @param {string} state New state of the error screen. | 137 * @param {string} state New state of the error screen. |
| 128 * @private | 138 * @private |
| 129 */ | 139 */ |
| 130 setState_: function(state) { | 140 setState_: function(state) { |
| 131 var states = [SCREEN_STATE.PROXY_ERROR, | 141 var states = [SCREEN_STATE.PROXY_ERROR, |
| 132 SCREEN_STATE.CAPTIVE_PORTAL_ERROR, | 142 SCREEN_STATE.CAPTIVE_PORTAL_ERROR, |
| 133 SCREEN_STATE.TIMEOUT_ERROR, | 143 SCREEN_STATE.TIMEOUT_ERROR, |
| 134 SCREEN_STATE.OFFLINE_ERROR]; | 144 SCREEN_STATE.OFFLINE_ERROR]; |
| 135 for (var i = 0; i < states.length; i++) { | 145 for (var i = 0; i < states.length; i++) { |
| 136 if (states[i] != state) | 146 if (states[i] != state) |
| 137 this.classList.remove(states[i]); | 147 this.classList.remove(states[i]); |
| 138 } | 148 } |
| 139 this.classList.add(state); | 149 this.classList.add(state); |
| 150 this.onContentChange_(); |
| 140 }, | 151 }, |
| 141 | 152 |
| 142 /** | 153 /** |
| 143 * Prepares error screen to show proxy error. | 154 * Prepares error screen to show proxy error. |
| 144 * @private | 155 * @private |
| 145 */ | 156 */ |
| 146 showProxyError_: function() { | 157 showProxyError_: function() { |
| 147 this.setState_(SCREEN_STATE.PROXY_ERROR); | 158 this.setState_(SCREEN_STATE.PROXY_ERROR); |
| 148 if (Oobe.getInstance().currentScreen === this) | |
| 149 Oobe.getInstance().updateScreenSize(this); | |
| 150 }, | 159 }, |
| 151 | 160 |
| 152 /** | 161 /** |
| 153 * Prepares error screen to show captive portal error. | 162 * Prepares error screen to show captive portal error. |
| 154 * @param {string} network Name of the current network | 163 * @param {string} network Name of the current network |
| 155 * @private | 164 * @private |
| 156 */ | 165 */ |
| 157 showCaptivePortalError_: function(network) { | 166 showCaptivePortalError_: function(network) { |
| 158 $(CURRENT_NETWORK_NAME_ID).textContent = network; | 167 $(CURRENT_NETWORK_NAME_ID).textContent = network; |
| 159 this.setState_(SCREEN_STATE.CAPTIVE_PORTAL_ERROR); | 168 this.setState_(SCREEN_STATE.CAPTIVE_PORTAL_ERROR); |
| 160 if (Oobe.getInstance().currentScreen === this) | |
| 161 Oobe.getInstance().updateScreenSize(this); | |
| 162 }, | 169 }, |
| 163 | 170 |
| 164 /** | 171 /** |
| 165 * Prepares error screen to show gaia loading timeout error. | 172 * Prepares error screen to show gaia loading timeout error. |
| 166 * @private | 173 * @private |
| 167 */ | 174 */ |
| 168 showTimeoutError_: function() { | 175 showTimeoutError_: function() { |
| 169 this.setState_(SCREEN_STATE.TIMEOUT_ERROR); | 176 this.setState_(SCREEN_STATE.TIMEOUT_ERROR); |
| 170 if (Oobe.getInstance().currentScreen === this) | |
| 171 Oobe.getInstance().updateScreenSize(this); | |
| 172 }, | 177 }, |
| 173 | 178 |
| 174 /** | 179 /** |
| 175 * Prepares error screen to show offline error. | 180 * Prepares error screen to show offline error. |
| 176 * @private | 181 * @private |
| 177 */ | 182 */ |
| 178 showOfflineError_: function() { | 183 showOfflineError_: function() { |
| 179 this.setState_(SCREEN_STATE.OFFLINE_ERROR); | 184 this.setState_(SCREEN_STATE.OFFLINE_ERROR); |
| 180 if (Oobe.getInstance().currentScreen === this) | |
| 181 Oobe.getInstance().updateScreenSize(this); | |
| 182 }, | 185 }, |
| 183 | 186 |
| 184 /** | 187 /** |
| 185 * Prepares error screen to show guest signin link. | 188 * Prepares error screen to show guest signin link. |
| 186 * @private | 189 * @private |
| 187 */ | 190 */ |
| 188 allowGuestSignin_: function(allowed) { | 191 allowGuestSignin_: function(allowed) { |
| 189 this.classList[allowed ? 'add' : 'remove']('allow-guest-signin'); | 192 this.classList[allowed ? 'add' : 'remove']('allow-guest-signin'); |
| 193 this.onContentChange_(); |
| 190 }, | 194 }, |
| 191 | 195 |
| 192 /** | 196 /** |
| 193 * Prepares error screen to show offline login link. | 197 * Prepares error screen to show offline login link. |
| 194 * @private | 198 * @private |
| 195 */ | 199 */ |
| 196 allowOfflineLogin_: function(allowed) { | 200 allowOfflineLogin_: function(allowed) { |
| 197 this.classList[allowed ? 'add' : 'remove']('allow-offline-login'); | 201 this.classList[allowed ? 'add' : 'remove']('allow-offline-login'); |
| 202 this.onContentChange_(); |
| 198 }, | 203 }, |
| 199 }; | 204 }; |
| 200 | 205 |
| 201 /** | 206 /** |
| 202 * Prepares error screen to show proxy error. | 207 * Prepares error screen to show proxy error. |
| 203 */ | 208 */ |
| 204 ErrorMessageScreen.showProxyError = function() { | 209 ErrorMessageScreen.showProxyError = function() { |
| 205 $('error-message').showProxyError_(); | 210 $('error-message').showProxyError_(); |
| 206 }; | 211 }; |
| 207 | 212 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 * via template. | 261 * via template. |
| 257 */ | 262 */ |
| 258 ErrorMessageScreen.updateLocalizedContent = function() { | 263 ErrorMessageScreen.updateLocalizedContent = function() { |
| 259 $('error-message').updateLocalizedContent_(); | 264 $('error-message').updateLocalizedContent_(); |
| 260 }; | 265 }; |
| 261 | 266 |
| 262 return { | 267 return { |
| 263 ErrorMessageScreen: ErrorMessageScreen | 268 ErrorMessageScreen: ErrorMessageScreen |
| 264 }; | 269 }; |
| 265 }); | 270 }); |
| OLD | NEW |