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

Side by Side Diff: trunk/src/chrome/browser/resources/gaia_auth/main.js

Issue 137133007: Revert 246674 "Indicate which authentication flow was used in Us..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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 * Authenticator class wraps the communications between Gaia and its host. 6 * Authenticator class wraps the communications between Gaia and its host.
7 */ 7 */
8 function Authenticator() { 8 function Authenticator() {
9 } 9 }
10 10
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 'newwindow', this.onWebviewNewWindow_.bind(this, gaiaFrame)); 175 'newwindow', this.onWebviewNewWindow_.bind(this, gaiaFrame));
176 } 176 }
177 if (this.constrained_) { 177 if (this.constrained_) {
178 gaiaFrame.request.onCompleted.addListener( 178 gaiaFrame.request.onCompleted.addListener(
179 this.onWebviewRequestCompleted_.bind(this), 179 this.onWebviewRequestCompleted_.bind(this),
180 {urls: ['<all_urls>'], types: ['main_frame']}, 180 {urls: ['<all_urls>'], types: ['main_frame']},
181 ['responseHeaders']); 181 ['responseHeaders']);
182 } 182 }
183 }, 183 },
184 184
185 completeLogin: function() { 185 completeLogin: function(username, password) {
186 var msg = { 186 var msg = {
187 'method': 'completeLogin', 187 'method': 'completeLogin',
188 'email': this.email_, 188 'email': username,
189 'password': this.password_, 189 'password': password
190 'usingSAML': this.isSAMLFlow_
191 }; 190 };
192 window.parent.postMessage(msg, this.parentPage_); 191 window.parent.postMessage(msg, this.parentPage_);
193 if (this.samlSupportChannel_) 192 if (this.samlSupportChannel_)
194 this.samlSupportChannel_.send({name: 'resetAuth'}); 193 this.samlSupportChannel_.send({name: 'resetAuth'});
195 }, 194 },
196 195
197 onPageLoad: function(e) { 196 onPageLoad: function(e) {
198 window.addEventListener('message', this.onMessage.bind(this), false); 197 window.addEventListener('message', this.onMessage.bind(this), false);
199 this.loadFrame_(); 198 this.loadFrame_();
200 }, 199 },
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 gaiaFrame.focus(); 270 gaiaFrame.focus();
272 gaiaFrame.onblur = function() { 271 gaiaFrame.onblur = function() {
273 gaiaFrame.focus(); 272 gaiaFrame.focus();
274 }; 273 };
275 } 274 }
276 this.loaded_ = true; 275 this.loaded_ = true;
277 }, 276 },
278 277
279 onConfirmLogin_: function() { 278 onConfirmLogin_: function() {
280 if (!this.isSAMLFlow_) { 279 if (!this.isSAMLFlow_) {
281 this.completeLogin(); 280 this.completeLogin(this.email_, this.password_);
282 return; 281 return;
283 } 282 }
284 283
285 // Retrieve the e-mail address of the user who just authenticated from GAIA. 284 // Retrieve the e-mail address of the user who just authenticated from GAIA.
286 window.parent.postMessage({method: 'retrieveAuthenticatedUserEmail', 285 window.parent.postMessage({method: 'retrieveAuthenticatedUserEmail',
287 attemptToken: this.attemptToken_}, 286 attemptToken: this.attemptToken_},
288 this.parentPage_); 287 this.parentPage_);
289 288
290 if (!this.password_) { 289 if (!this.password_) {
291 this.samlSupportChannel_.sendWithCallback( 290 this.samlSupportChannel_.sendWithCallback(
292 {name: 'getScrapedPasswords'}, 291 {name: 'getScrapedPasswords'},
293 function(passwords) { 292 function(passwords) {
294 if (passwords.length == 0) { 293 if (passwords.length == 0) {
295 window.parent.postMessage( 294 window.parent.postMessage(
296 {method: 'noPassword', email: this.email_}, 295 {method: 'noPassword', email: this.email_},
297 this.parentPage_); 296 this.parentPage_);
298 } else { 297 } else {
299 window.parent.postMessage( 298 window.parent.postMessage(
300 {method: 'confirmPassword', email: this.email_}, 299 {method: 'confirmPassword', email: this.email_},
301 this.parentPage_); 300 this.parentPage_);
302 } 301 }
303 }.bind(this)); 302 }.bind(this));
304 } 303 }
305 }, 304 },
306 305
307 maybeCompleteSAMLLogin_: function() { 306 maybeCompleteSAMLLogin_: function() {
308 // SAML login is complete when the user's e-mail address has been retrieved 307 // SAML login is complete when the user's e-mail address has been retrieved
309 // from GAIA and the user has successfully confirmed the password. 308 // from GAIA and the user has successfully confirmed the password.
310 if (this.email_ !== null && this.password_ !== null) 309 if (this.email_ !== null && this.password_ !== null)
311 this.completeLogin(); 310 this.completeLogin(this.email_, this.password_);
312 }, 311 },
313 312
314 onVerifyConfirmedPassword_: function(password) { 313 onVerifyConfirmedPassword_: function(password) {
315 this.samlSupportChannel_.sendWithCallback( 314 this.samlSupportChannel_.sendWithCallback(
316 {name: 'getScrapedPasswords'}, 315 {name: 'getScrapedPasswords'},
317 function(passwords) { 316 function(passwords) {
318 for (var i = 0; i < passwords.length; ++i) { 317 for (var i = 0; i < passwords.length; ++i) {
319 if (passwords[i] == password) { 318 if (passwords[i] == password) {
320 this.password_ = passwords[i]; 319 this.password_ = passwords[i];
321 this.maybeCompleteSAMLLogin_(); 320 this.maybeCompleteSAMLLogin_();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } else if (msg.method == 'redirectToSignin' && 364 } else if (msg.method == 'redirectToSignin' &&
366 this.isParentMessage_(e)) { 365 this.isParentMessage_(e)) {
367 $('gaia-frame').src = this.constructInitialFrameUrl_(); 366 $('gaia-frame').src = this.constructInitialFrameUrl_();
368 } else { 367 } else {
369 console.error('Authenticator.onMessage: unknown message + origin!?'); 368 console.error('Authenticator.onMessage: unknown message + origin!?');
370 } 369 }
371 } 370 }
372 }; 371 };
373 372
374 Authenticator.getInstance().initialize(); 373 Authenticator.getInstance().initialize();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698