| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 this.showLoadingUI_(loading); | 92 this.showLoadingUI_(loading); |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Event handler that is invoked just before the frame is shown. | 96 * Event handler that is invoked just before the frame is shown. |
| 97 * @param data {string} Screen init payload. Url of auth extension start | 97 * @param data {string} Screen init payload. Url of auth extension start |
| 98 * page. | 98 * page. |
| 99 */ | 99 */ |
| 100 onBeforeShow: function(data) { | 100 onBeforeShow: function(data) { |
| 101 console.log('Opening extension: ' + data.startUrl + | 101 // Announce the name of the screen, if accessibility is on. |
| 102 ', opt_email=' + data.email); | 102 $('gaia-signin-aria-label').setAttribute( |
| 103 'aria-label', localStrings.getString('signinScreenTitle')); |
| 104 |
| 105 // Button header is always visible when sign in is presented. |
| 106 // Header is hidden once GAIA reports on successful sign in. |
| 107 Oobe.getInstance().headerHidden = false; |
| 108 }, |
| 109 |
| 110 setExtensionUrl_: function(data) { |
| 111 $('createAccount').hidden = !data.createAccount; |
| 112 $('guestSignin').hidden = !data.guestSignin; |
| 103 | 113 |
| 104 var params = []; | 114 var params = []; |
| 105 if (data.gaiaOrigin) | 115 if (data.gaiaOrigin) |
| 106 params.push('gaiaOrigin=' + encodeURIComponent(data.gaiaOrigin)); | 116 params.push('gaiaOrigin=' + encodeURIComponent(data.gaiaOrigin)); |
| 107 if (data.hl) | 117 if (data.hl) |
| 108 params.push('hl=' + encodeURIComponent(data.hl)); | 118 params.push('hl=' + encodeURIComponent(data.hl)); |
| 109 if (data.email) | 119 if (data.email) |
| 110 params.push('email=' + encodeURIComponent(data.email)); | 120 params.push('email=' + encodeURIComponent(data.email)); |
| 111 if (data.test_email) | 121 if (data.test_email) |
| 112 params.push('test_email=' + encodeURIComponent(data.test_email)); | 122 params.push('test_email=' + encodeURIComponent(data.test_email)); |
| 113 if (data.test_password) | 123 if (data.test_password) |
| 114 params.push('test_password=' + encodeURIComponent(data.test_password)); | 124 params.push('test_password=' + encodeURIComponent(data.test_password)); |
| 115 | 125 |
| 116 var url = data.startUrl; | 126 var url = data.startUrl; |
| 117 if (params.length) | 127 if (params.length) |
| 118 url += '?' + params.join('&'); | 128 url += '?' + params.join('&'); |
| 119 | 129 |
| 120 $('signin-frame').src = url; | 130 if (data.forceReload || this.extension_url_ != url) { |
| 121 this.extension_url_ = url; | 131 console.log('Opening extension: ' + data.startUrl + |
| 132 ', opt_email=' + data.email); |
| 122 | 133 |
| 123 $('createAccount').hidden = !data.createAccount; | 134 $('signin-frame').src = url; |
| 124 $('guestSignin').hidden = !data.guestSignin; | 135 this.extension_url_ = url; |
| 125 | 136 |
| 126 // Announce the name of the screen, if accessibility is on. | 137 this.loading = true; |
| 127 $('gaia-signin-aria-label').setAttribute( | 138 this.clearRetry_(); |
| 128 'aria-label', localStrings.getString('signinScreenTitle')); | 139 } else if (this.loading) { |
| 129 | 140 // Probably an error has occurred, so trying to reload. |
| 130 // Button header is always visible when sign in is presented. | 141 this.doReload(); |
| 131 // Header is hidden once GAIA reports on successful sign in. | 142 } |
| 132 Oobe.getInstance().headerHidden = false; | |
| 133 | |
| 134 this.loading = true; | |
| 135 this.clearRetry_(); | |
| 136 }, | 143 }, |
| 137 | 144 |
| 138 /** | 145 /** |
| 139 * Checks if message comes from the loaded authentication extension. | 146 * Checks if message comes from the loaded authentication extension. |
| 140 * @param e {object} Payload of the received HTML5 message. | 147 * @param e {object} Payload of the received HTML5 message. |
| 141 * @type {bool} | 148 * @type {bool} |
| 142 */ | 149 */ |
| 143 isAuthExtMessage_: function(e) { | 150 isAuthExtMessage_: function(e) { |
| 144 return this.extension_url_ != null && | 151 return this.extension_url_ != null && |
| 145 this.extension_url_.indexOf(e.origin) == 0 && | 152 this.extension_url_.indexOf(e.origin) == 0 && |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 215 |
| 209 var delay = Math.pow(2, this.retryCount_) * 5; | 216 var delay = Math.pow(2, this.retryCount_) * 5; |
| 210 delay = Math.max(MIN_DELAY, Math.min(MAX_DELAY, delay)) * 1000; | 217 delay = Math.max(MIN_DELAY, Math.min(MAX_DELAY, delay)) * 1000; |
| 211 | 218 |
| 212 ++this.retryCount_; | 219 ++this.retryCount_; |
| 213 this.retryTimer_ = window.setTimeout(this.doReload.bind(this), delay); | 220 this.retryTimer_ = window.setTimeout(this.doReload.bind(this), delay); |
| 214 console.log('GaiaSigninScreen scheduleRetry in ' + delay + 'ms.'); | 221 console.log('GaiaSigninScreen scheduleRetry in ' + delay + 'ms.'); |
| 215 } | 222 } |
| 216 }; | 223 }; |
| 217 | 224 |
| 225 GaiaSigninScreen.setExtensionUrl = function(data) { |
| 226 $('gaia-signin').setExtensionUrl_(data); |
| 227 }; |
| 228 |
| 218 return { | 229 return { |
| 219 GaiaSigninScreen: GaiaSigninScreen | 230 GaiaSigninScreen: GaiaSigninScreen |
| 220 }; | 231 }; |
| 221 }); | 232 }); |
| OLD | NEW |