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

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

Issue 8372093: [cros,login] Pre-load login extension in the background. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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
OLDNEW
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
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) {
xiyuan 2011/11/03 16:52:33 When will the two "else" branch below get hit? It
altimofeev 2011/11/03 17:22:32 * "!this.loading": first click on 'Add new user' b
xiyuan 2011/11/03 17:36:04 In this case, if Gaia is loaded successfully, "log
altimofeev 2011/11/07 16:21:59 Done - moved the logic fully to the C++ part.
129 140 chrome.send('loginWebuiReady');
130 // Button header is always visible when sign in is presented. 141 } else {
131 // Header is hidden once GAIA reports on successful sign in. 142 this.doReload();
132 Oobe.getInstance().headerHidden = false; 143 }
133
134 this.loading = true;
135 this.clearRetry_();
136 }, 144 },
137 145
138 /** 146 /**
139 * Checks if message comes from the loaded authentication extension. 147 * Checks if message comes from the loaded authentication extension.
140 * @param e {object} Payload of the received HTML5 message. 148 * @param e {object} Payload of the received HTML5 message.
141 * @type {bool} 149 * @type {bool}
142 */ 150 */
143 isAuthExtMessage_: function(e) { 151 isAuthExtMessage_: function(e) {
144 return this.extension_url_ != null && 152 return this.extension_url_ != null &&
145 this.extension_url_.indexOf(e.origin) == 0 && 153 this.extension_url_.indexOf(e.origin) == 0 &&
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 216
209 var delay = Math.pow(2, this.retryCount_) * 5; 217 var delay = Math.pow(2, this.retryCount_) * 5;
210 delay = Math.max(MIN_DELAY, Math.min(MAX_DELAY, delay)) * 1000; 218 delay = Math.max(MIN_DELAY, Math.min(MAX_DELAY, delay)) * 1000;
211 219
212 ++this.retryCount_; 220 ++this.retryCount_;
213 this.retryTimer_ = window.setTimeout(this.doReload.bind(this), delay); 221 this.retryTimer_ = window.setTimeout(this.doReload.bind(this), delay);
214 console.log('GaiaSigninScreen scheduleRetry in ' + delay + 'ms.'); 222 console.log('GaiaSigninScreen scheduleRetry in ' + delay + 'ms.');
215 } 223 }
216 }; 224 };
217 225
226 GaiaSigninScreen.setExtensionUrl = function(data) {
227 $('gaia-signin').setExtensionUrl_(data);
228 };
229
218 return { 230 return {
219 GaiaSigninScreen: GaiaSigninScreen 231 GaiaSigninScreen: GaiaSigninScreen
220 }; 232 };
221 }); 233 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698