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 | 10 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } else if (msg.method == 'loginUILoaded' && this.isAuthExtMessage_(e)) { | 253 } else if (msg.method == 'loginUILoaded' && this.isAuthExtMessage_(e)) { |
254 // TODO(altimofeev): there is no guarantee that next 'focusout' event | 254 // TODO(altimofeev): there is no guarantee that next 'focusout' event |
255 // will be caused by the extension, so better approach is direct asking | 255 // will be caused by the extension, so better approach is direct asking |
256 // the extension (and gaia consequently) to not grab the focus. | 256 // the extension (and gaia consequently) to not grab the focus. |
257 if (this.silentLoad_ && this.hasFocused_) { | 257 if (this.silentLoad_ && this.hasFocused_) { |
258 document.addEventListener( | 258 document.addEventListener( |
259 'focusout', this.selfBind_(this.onFocusOut_.bind(this))); | 259 'focusout', this.selfBind_(this.onFocusOut_.bind(this))); |
260 } | 260 } |
261 $('error-message').update(); | 261 $('error-message').update(); |
262 this.loading = false; | 262 this.loading = false; |
| 263 // Show deferred error bubble. |
| 264 if (this.errorBubble_) { |
| 265 this.showErrorBubble(this.errorBubble_[0], this.errorBubble_[1]); |
| 266 this.errorBubble_ = undefined; |
| 267 } |
263 this.clearRetry_(); | 268 this.clearRetry_(); |
264 chrome.send('loginWebuiReady'); | 269 chrome.send('loginWebuiReady'); |
265 } else if (msg.method =='offlineLogin' && this.isAuthExtMessage_(e)) { | 270 } else if (msg.method =='offlineLogin' && this.isAuthExtMessage_(e)) { |
266 this.email = msg.email; | 271 this.email = msg.email; |
267 chrome.send('authenticateUser', [msg.email, msg.password]); | 272 chrome.send('authenticateUser', [msg.email, msg.password]); |
268 this.loading = true; | 273 this.loading = true; |
269 Oobe.getInstance().headerHidden = true; | 274 Oobe.getInstance().headerHidden = true; |
270 } | 275 } |
271 }, | 276 }, |
272 | 277 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 $('guestSignin').innerHTML = localStrings.getStringF( | 358 $('guestSignin').innerHTML = localStrings.getStringF( |
354 'guestSignin', | 359 'guestSignin', |
355 '<a id="guestSigninLink" class="signin-link" href="#">', | 360 '<a id="guestSigninLink" class="signin-link" href="#">', |
356 '</a>'); | 361 '</a>'); |
357 $('createAccountLink').onclick = function() { | 362 $('createAccountLink').onclick = function() { |
358 chrome.send('createAccount'); | 363 chrome.send('createAccount'); |
359 }; | 364 }; |
360 $('guestSigninLink').onclick = function() { | 365 $('guestSigninLink').onclick = function() { |
361 chrome.send('launchIncognito'); | 366 chrome.send('launchIncognito'); |
362 }; | 367 }; |
| 368 }, |
| 369 |
| 370 /** |
| 371 * Shows sign-in error bubble. |
| 372 * @param {number} loginAttempts Number of login attemps tried. |
| 373 * @param {HTMLElement} content Content to show in bubble. |
| 374 */ |
| 375 showErrorBubble: function(loginAttempts, error) { |
| 376 if (this.isLocal) { |
| 377 $('add-user-button').hidden = true; |
| 378 $('cancel-add-user-button').hidden = false; |
| 379 // Reload offline version of the sign-in extension, which will show |
| 380 // error itself. |
| 381 chrome.send('offlineLogin', [this.email]); |
| 382 } else if (!this.loading) { |
| 383 $('bubble').showContentForElement($('login-box'), error, |
| 384 cr.ui.Bubble.Attachment.LEFT); |
| 385 } else { |
| 386 // Defer the bubble until the frame has been loaded. |
| 387 this.errorBubble_ = [loginAttempts, error]; |
| 388 } |
363 } | 389 } |
364 }; | 390 }; |
365 | 391 |
366 /** | 392 /** |
367 * Loads the authentication extension into the iframe. | 393 * Loads the authentication extension into the iframe. |
368 * @param {Object} data Extension parameters bag. | 394 * @param {Object} data Extension parameters bag. |
369 */ | 395 */ |
370 GaiaSigninScreen.loadAuthExtension = function(data) { | 396 GaiaSigninScreen.loadAuthExtension = function(data) { |
371 $('gaia-signin').loadAuthExtension_(data); | 397 $('gaia-signin').loadAuthExtension_(data); |
372 }; | 398 }; |
373 | 399 |
374 /** | 400 /** |
375 * Updates the authentication extension with new parameters, if needed. | 401 * Updates the authentication extension with new parameters, if needed. |
376 * @param {Object} data New extension parameters bag. | 402 * @param {Object} data New extension parameters bag. |
377 */ | 403 */ |
378 GaiaSigninScreen.updateAuthExtension = function(data) { | 404 GaiaSigninScreen.updateAuthExtension = function(data) { |
379 $('gaia-signin').updateAuthExtension_(data); | 405 $('gaia-signin').updateAuthExtension_(data); |
380 }; | 406 }; |
381 | 407 |
382 return { | 408 return { |
383 GaiaSigninScreen: GaiaSigninScreen | 409 GaiaSigninScreen: GaiaSigninScreen |
384 }; | 410 }; |
385 }); | 411 }); |
OLD | NEW |