| 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 Oobe signin screen implementation. | 6 * @fileoverview Oobe signin screen implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('login', function() { | 9 cr.define('login', function() { |
| 10 // Gaia loading time after which portal check should be fired. | 10 // Gaia loading time after which portal check should be fired. |
| 11 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 5; | 11 /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 5; |
| 12 | 12 |
| 13 // Maximum Gaia loading time in seconds. | 13 // Maximum Gaia loading time in seconds. |
| 14 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; | 14 /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; |
| 15 | 15 |
| 16 // Network state constants. | |
| 17 /** @const */ var NET_STATE = { | |
| 18 OFFLINE: 0, | |
| 19 ONLINE: 1, | |
| 20 PORTAL: 2, | |
| 21 CONNECTING: 3, | |
| 22 UNKNOWN: 4 | |
| 23 }; | |
| 24 | |
| 25 // Frame loading errors. | 16 // Frame loading errors. |
| 26 /** @const */ var NET_ERROR = { | 17 /** @const */ var NET_ERROR = { |
| 27 ABORTED_BY_USER: 3 | 18 ABORTED_BY_USER: 3 |
| 28 }; | 19 }; |
| 29 | 20 |
| 30 /** | 21 /** |
| 31 * Creates a new sign in screen div. | 22 * Creates a new sign in screen div. |
| 32 * @constructor | 23 * @constructor |
| 33 * @extends {HTMLDivElement} | 24 * @extends {HTMLDivElement} |
| 34 */ | 25 */ |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 this.showLoadingUI_(loading); | 169 this.showLoadingUI_(loading); |
| 179 }, | 170 }, |
| 180 | 171 |
| 181 /** | 172 /** |
| 182 * Event handler that is invoked just before the frame is shown. | 173 * Event handler that is invoked just before the frame is shown. |
| 183 * @param {string} data Screen init payload. Url of auth extension start | 174 * @param {string} data Screen init payload. Url of auth extension start |
| 184 * page. | 175 * page. |
| 185 */ | 176 */ |
| 186 onBeforeShow: function(data) { | 177 onBeforeShow: function(data) { |
| 187 chrome.send('loginUIStateChanged', ['gaia-signin', true]); | 178 chrome.send('loginUIStateChanged', ['gaia-signin', true]); |
| 188 $('login-header-bar').signinUIActive = true; | 179 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN; |
| 189 | 180 |
| 190 // Announce the name of the screen, if accessibility is on. | 181 // Announce the name of the screen, if accessibility is on. |
| 191 $('gaia-signin-aria-label').setAttribute( | 182 $('gaia-signin-aria-label').setAttribute( |
| 192 'aria-label', localStrings.getString('signinScreenTitle')); | 183 'aria-label', localStrings.getString('signinScreenTitle')); |
| 193 | 184 |
| 194 // Button header is always visible when sign in is presented. | 185 // Button header is always visible when sign in is presented. |
| 195 // Header is hidden once GAIA reports on successful sign in. | 186 // Header is hidden once GAIA reports on successful sign in. |
| 196 Oobe.getInstance().headerHidden = false; | 187 Oobe.getInstance().headerHidden = false; |
| 197 }, | 188 }, |
| 198 | 189 |
| 199 /** | 190 /** |
| 200 * Event handler that is invoked just before the screen is hidden. | 191 * Event handler that is invoked just before the screen is hidden. |
| 201 */ | 192 */ |
| 202 onBeforeHide: function() { | 193 onBeforeHide: function() { |
| 203 chrome.send('loginUIStateChanged', ['gaia-signin', false]); | 194 chrome.send('loginUIStateChanged', ['gaia-signin', false]); |
| 204 $('login-header-bar').signinUIActive = false; | 195 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.HIDDEN; |
| 205 }, | 196 }, |
| 206 | 197 |
| 207 /** | 198 /** |
| 208 * Loads the authentication extension into the iframe. | 199 * Loads the authentication extension into the iframe. |
| 209 * @param {Object} data Extension parameters bag. | 200 * @param {Object} data Extension parameters bag. |
| 210 * @private | 201 * @private |
| 211 */ | 202 */ |
| 212 loadAuthExtension_: function(data) { | 203 loadAuthExtension_: function(data) { |
| 213 this.silentLoad_ = data.silentLoad; | 204 this.silentLoad_ = data.silentLoad; |
| 214 this.isLocal = data.isLocal; | 205 this.isLocal = data.isLocal; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 * @param {boolean} forceOnline Whether online sign-in should be forced. | 343 * @param {boolean} forceOnline Whether online sign-in should be forced. |
| 353 * If |forceOnline| is false previously used sign-in type will be used. | 344 * If |forceOnline| is false previously used sign-in type will be used. |
| 354 */ | 345 */ |
| 355 reset: function(takeFocus, forceOnline) { | 346 reset: function(takeFocus, forceOnline) { |
| 356 // Reload and show the sign-in UI if needed. | 347 // Reload and show the sign-in UI if needed. |
| 357 if (takeFocus) { | 348 if (takeFocus) { |
| 358 if (!forceOnline && this.isLocal) { | 349 if (!forceOnline && this.isLocal) { |
| 359 // Show 'Cancel' button to allow user to return to the main screen | 350 // Show 'Cancel' button to allow user to return to the main screen |
| 360 // (e.g. this makes sense when connection is back). | 351 // (e.g. this makes sense when connection is back). |
| 361 Oobe.getInstance().headerHidden = false; | 352 Oobe.getInstance().headerHidden = false; |
| 362 $('login-header-bar').signinUIActive = true; | 353 $('login-header-bar').signinUIState = SIGNIN_UI_STATE.GAIA_SIGNIN; |
| 363 // Do nothing, since offline version is reloaded after an error comes. | 354 // Do nothing, since offline version is reloaded after an error comes. |
| 364 } else { | 355 } else { |
| 365 Oobe.showSigninUI(); | 356 Oobe.showSigninUI(); |
| 366 } | 357 } |
| 367 } | 358 } |
| 368 }, | 359 }, |
| 369 | 360 |
| 370 /** | 361 /** |
| 371 * Clears retry data. | 362 * Clears retry data. |
| 372 * @private | 363 * @private |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 // Check current network state if currentScreen is a Gaia signin. | 489 // Check current network state if currentScreen is a Gaia signin. |
| 499 var currentScreen = Oobe.getInstance().currentScreen; | 490 var currentScreen = Oobe.getInstance().currentScreen; |
| 500 if (currentScreen.id == SCREEN_GAIA_SIGNIN) | 491 if (currentScreen.id == SCREEN_GAIA_SIGNIN) |
| 501 chrome.send('showGaiaFrameError', [error]); | 492 chrome.send('showGaiaFrameError', [error]); |
| 502 }; | 493 }; |
| 503 | 494 |
| 504 return { | 495 return { |
| 505 GaiaSigninScreen: GaiaSigninScreen | 496 GaiaSigninScreen: GaiaSigninScreen |
| 506 }; | 497 }; |
| 507 }); | 498 }); |
| OLD | NEW |