Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_error_message.js

Issue 12207077: Refactored error screen logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
11 /** @const */ var FIX_CAPTIVE_PORTAL_ID = 'captive-portal-fix-link'; 11 /** @const */ var FIX_CAPTIVE_PORTAL_ID = 'captive-portal-fix-link';
12 12
13 /** @const */ var FIX_PROXY_SETTINGS_ID = 'proxy-settings-fix-link'; 13 /** @const */ var FIX_PROXY_SETTINGS_ID = 'proxy-settings-fix-link';
14 14
15 // Id of the element which holds current network name. 15 // Id of the element which holds current network name.
16 /** @const */ var CURRENT_NETWORK_NAME_ID = 'captive-portal-network-name'; 16 /** @const */ var CURRENT_NETWORK_NAME_ID = 'captive-portal-network-name';
17 17
18 // Link which triggers frame reload. 18 // Link which triggers frame reload.
19 /** @const */ var RELOAD_PAGE_ID = 'proxy-error-retry-link'; 19 /** @const */ var RELOAD_PAGE_ID = 'proxy-error-retry-link';
20 20
21 // Possible states of the error screen.
22 /** @const */ var SCREEN_STATE = {
23 PROXY_ERROR: 'show-proxy-error',
24 CAPTIVE_PORTAL_ERROR: 'show-captive-portal-error',
25 TIMEOUT_ERROR: 'show-timeout-error',
26 OFFLINE_ERROR: 'show-offline-error'
27 };
28
21 /** 29 /**
22 * Creates a new offline message screen div. 30 * Creates a new offline message screen div.
23 * @constructor 31 * @constructor
24 * @extends {HTMLDivElement} 32 * @extends {HTMLDivElement}
25 */ 33 */
26 var ErrorMessageScreen = cr.ui.define('div'); 34 var ErrorMessageScreen = cr.ui.define('div');
27 35
28 /** 36 /**
29 * Registers with Oobe. 37 * Registers with Oobe.
30 */ 38 */
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }, 116 },
109 117
110 /** 118 /**
111 * Event handler that is invoked just before the screen is hidden. 119 * Event handler that is invoked just before the screen is hidden.
112 */ 120 */
113 onBeforeHide: function() { 121 onBeforeHide: function() {
114 cr.ui.DropDown.hide('offline-networks-list'); 122 cr.ui.DropDown.hide('offline-networks-list');
115 }, 123 },
116 124
117 /** 125 /**
126 * Sets current state of the error screen.
127 * @param {String} state New state of the error screen.
128 * @private
129 */
130 setState_: function(state) {
131 var states = [SCREEN_STATE.PROXY_ERROR,
132 SCREEN_STATE.CAPTIVE_PORTAL_ERROR,
133 SCREEN_STATE.TIMEOUT_ERROR,
134 SCREEN_STATE.OFFLINE_ERROR];
135 for (var i = 0; i < states.length; i++) {
136 if (states[i] != state)
137 this.classList.remove(states[i]);
138 }
139 this.classList.add(state);
140 },
141
142 /**
118 * Prepares error screen to show proxy error. 143 * Prepares error screen to show proxy error.
119 * @private 144 * @private
120 */ 145 */
121 showProxyError_: function() { 146 showProxyError_: function() {
122 this.classList.remove('show-offline-message'); 147 this.setState_(SCREEN_STATE.PROXY_ERROR);
123 this.classList.remove('show-captive-portal');
124 this.classList.add('show-proxy-error');
125 if (Oobe.getInstance().currentScreen === this) 148 if (Oobe.getInstance().currentScreen === this)
126 Oobe.getInstance().updateScreenSize(this); 149 Oobe.getInstance().updateScreenSize(this);
127 }, 150 },
128 151
129 /** 152 /**
130 * Prepares error screen to show captive portal error. 153 * Prepares error screen to show captive portal error.
131 * @param {string} network Name of the current network 154 * @param {string} network Name of the current network
132 * @private 155 * @private
133 */ 156 */
134 showCaptivePortalError_: function(network) { 157 showCaptivePortalError_: function(network) {
135 $(CURRENT_NETWORK_NAME_ID).textContent = network; 158 $(CURRENT_NETWORK_NAME_ID).textContent = network;
136 this.classList.remove('show-offline-message'); 159 this.setState_(SCREEN_STATE.CAPTIVE_PORTAL_ERROR);
137 this.classList.remove('show-proxy-error');
138 this.classList.add('show-captive-portal');
139 if (Oobe.getInstance().currentScreen === this) 160 if (Oobe.getInstance().currentScreen === this)
140 Oobe.getInstance().updateScreenSize(this); 161 Oobe.getInstance().updateScreenSize(this);
141 }, 162 },
163
164 /**
165 * Prepares error screen to show gaia loading timeout error.
166 * @private
167 */
168 showTimeoutError_: function() {
169 this.setState_(SCREEN_STATE.TIMEOUT_ERROR);
170 if (Oobe.getInstance().currentScreen === this)
171 Oobe.getInstance().updateScreenSize(this);
172 },
142 173
143 /** 174 /**
144 * Prepares error screen to show offline error. 175 * Prepares error screen to show offline error.
145 * @private 176 * @private
146 */ 177 */
147 showOfflineError_: function() { 178 showOfflineError_: function() {
148 this.classList.remove('show-captive-portal'); 179 this.setState_(SCREEN_STATE.OFFLINE_ERROR);
149 this.classList.remove('show-proxy-error');
150 this.classList.add('show-offline-message');
151 if (Oobe.getInstance().currentScreen === this) 180 if (Oobe.getInstance().currentScreen === this)
152 Oobe.getInstance().updateScreenSize(this); 181 Oobe.getInstance().updateScreenSize(this);
153 }, 182 },
154 183
155 /** 184 /**
156 * Prepares error screen to show guest signin link. 185 * Prepares error screen to show guest signin link.
157 * @private 186 * @private
158 */ 187 */
159 allowGuestSignin_: function(allowed) { 188 allowGuestSignin_: function(allowed) {
160 this.classList[allowed ? 'add' : 'remove']('allow-guest-signin'); 189 this.classList[allowed ? 'add' : 'remove']('allow-guest-signin');
(...skipping 17 matching lines...) Expand all
178 207
179 /** 208 /**
180 * Prepares error screen to show captive portal error. 209 * Prepares error screen to show captive portal error.
181 * @param {string} network Name of the current network 210 * @param {string} network Name of the current network
182 */ 211 */
183 ErrorMessageScreen.showCaptivePortalError = function(network) { 212 ErrorMessageScreen.showCaptivePortalError = function(network) {
184 $('error-message').showCaptivePortalError_(network); 213 $('error-message').showCaptivePortalError_(network);
185 }; 214 };
186 215
187 /** 216 /**
217 * Prepares error screen to show gaia loading timeout error.
218 */
219 ErrorMessageScreen.showTimeoutError = function() {
220 $('error-message').showTimeoutError_();
221 };
222
223 /**
188 * Prepares error screen to show offline error. 224 * Prepares error screen to show offline error.
189 */ 225 */
190 ErrorMessageScreen.showOfflineError = function() { 226 ErrorMessageScreen.showOfflineError = function() {
191 $('error-message').showOfflineError_(); 227 $('error-message').showOfflineError_();
192 }; 228 };
193 229
194 /** 230 /**
195 * Prepares error screen to show guest signin link. 231 * Prepares error screen to show guest signin link.
196 * @param {boolean} allowed True if signin link should be visible. 232 * @param {boolean} allowed True if signin link should be visible.
197 */ 233 */
(...skipping 22 matching lines...) Expand all
220 * via template. 256 * via template.
221 */ 257 */
222 ErrorMessageScreen.updateLocalizedContent = function() { 258 ErrorMessageScreen.updateLocalizedContent = function() {
223 $('error-message').updateLocalizedContent_(); 259 $('error-message').updateLocalizedContent_();
224 }; 260 };
225 261
226 return { 262 return {
227 ErrorMessageScreen: ErrorMessageScreen 263 ErrorMessageScreen: ErrorMessageScreen
228 }; 264 };
229 }); 265 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698