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

Side by Side Diff: chrome/browser/resources/gaia_auth/background.js

Issue 473153002: Inline sign in extracts gaia id from HTTP header and seeds account tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 6 * @fileoverview
7 * A background script of the auth extension that bridges the communication 7 * A background script of the auth extension that bridges the communication
8 * between the main and injected scripts. 8 * between the main and injected scripts.
9 * 9 *
10 * Here is an overview of the communication flow when SAML is being used: 10 * Here is an overview of the communication flow when SAML is being used:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 continueUrl_: null, 113 continueUrl_: null,
114 114
115 // Whether the extension is loaded in a constrained window. 115 // Whether the extension is loaded in a constrained window.
116 // Set from main auth script. 116 // Set from main auth script.
117 isConstrainedWindow_: null, 117 isConstrainedWindow_: null,
118 118
119 // Email of the newly authenticated user based on the gaia response header 119 // Email of the newly authenticated user based on the gaia response header
120 // 'google-accounts-signin'. 120 // 'google-accounts-signin'.
121 email_: null, 121 email_: null,
122 122
123 // Gaia Id of the newly authenticated user based on the gaia response
124 // header 'google-accounts-signin'.
125 gaiaId_: null,
126
123 // Session index of the newly authenticated user based on the gaia response 127 // Session index of the newly authenticated user based on the gaia response
124 // header 'google-accounts-signin'. 128 // header 'google-accounts-signin'.
125 sessionIndex_: null, 129 sessionIndex_: null,
126 130
127 // Gaia URL base that is set from main auth script. 131 // Gaia URL base that is set from main auth script.
128 gaiaUrl_: null, 132 gaiaUrl_: null,
129 133
130 // Whether to abort the authentication flow and show an error messagen when 134 // Whether to abort the authentication flow and show an error messagen when
131 // content served over an unencrypted connection is detected. 135 // content served over an unencrypted connection is detected.
132 blockInsecureContent_: false, 136 blockInsecureContent_: false,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 details.url.lastIndexOf(this.continueUrl_, 0) == 0) { 218 details.url.lastIndexOf(this.continueUrl_, 0) == 0) {
215 var skipForNow = false; 219 var skipForNow = false;
216 if (details.url.indexOf('ntp=1') >= 0) 220 if (details.url.indexOf('ntp=1') >= 0)
217 skipForNow = true; 221 skipForNow = true;
218 222
219 // TOOD(guohui): Show password confirmation UI. 223 // TOOD(guohui): Show password confirmation UI.
220 var passwords = this.onGetScrapedPasswords_(); 224 var passwords = this.onGetScrapedPasswords_();
221 msg = { 225 msg = {
222 'name': 'completeLogin', 226 'name': 'completeLogin',
223 'email': this.email_, 227 'email': this.email_,
228 'gaiaId': this.gaiaId_,
224 'password': passwords[0], 229 'password': passwords[0],
225 'sessionIndex': this.sessionIndex_, 230 'sessionIndex': this.sessionIndex_,
226 'skipForNow': skipForNow 231 'skipForNow': skipForNow
227 }; 232 };
228 this.channelMain_.send(msg); 233 this.channelMain_.send(msg);
229 } else if (this.isConstrainedWindow_) { 234 } else if (this.isConstrainedWindow_) {
230 // The header google-accounts-embedded is only set on gaia domain. 235 // The header google-accounts-embedded is only set on gaia domain.
231 if (this.gaiaUrl_ && details.url.lastIndexOf(this.gaiaUrl_) == 0) { 236 if (this.gaiaUrl_ && details.url.lastIndexOf(this.gaiaUrl_) == 0) {
232 var headers = details.responseHeaders; 237 var headers = details.responseHeaders;
233 for (var i = 0; headers && i < headers.length; ++i) { 238 for (var i = 0; headers && i < headers.length; ++i) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 for (var i = 0; headers && i < headers.length; ++i) { 278 for (var i = 0; headers && i < headers.length; ++i) {
274 if (headers[i].name.toLowerCase() == 'google-accounts-signin') { 279 if (headers[i].name.toLowerCase() == 'google-accounts-signin') {
275 var headerValues = headers[i].value.toLowerCase().split(','); 280 var headerValues = headers[i].value.toLowerCase().split(',');
276 var signinDetails = {}; 281 var signinDetails = {};
277 headerValues.forEach(function(e) { 282 headerValues.forEach(function(e) {
278 var pair = e.split('='); 283 var pair = e.split('=');
279 signinDetails[pair[0].trim()] = pair[1].trim(); 284 signinDetails[pair[0].trim()] = pair[1].trim();
280 }); 285 });
281 // Remove "" around. 286 // Remove "" around.
282 this.email_ = signinDetails['email'].slice(1, -1); 287 this.email_ = signinDetails['email'].slice(1, -1);
288 this.gaiaId_ = signinDetails['obfuscatedid'].slice(1, -1);
283 this.sessionIndex_ = signinDetails['sessionindex']; 289 this.sessionIndex_ = signinDetails['sessionindex'];
284 break; 290 break;
285 } 291 }
286 } 292 }
287 } 293 }
288 294
289 if (!this.isDesktopFlow_) { 295 if (!this.isDesktopFlow_) {
290 // Check whether GAIA headers indicating the start or end of a SAML 296 // Check whether GAIA headers indicating the start or end of a SAML
291 // redirect are present. If so, synthesize cookies to mark these points. 297 // redirect are present. If so, synthesize cookies to mark these points.
292 for (var i = 0; headers && i < headers.length; ++i) { 298 for (var i = 0; headers && i < headers.length; ++i) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 }, 425 },
420 426
421 onPageLoaded_: function(msg) { 427 onPageLoaded_: function(msg) {
422 if (this.channelMain_) 428 if (this.channelMain_)
423 this.channelMain_.send({name: 'onAuthPageLoaded', url: msg.url}); 429 this.channelMain_.send({name: 'onAuthPageLoaded', url: msg.url});
424 } 430 }
425 }; 431 };
426 432
427 var backgroundBridgeManager = new BackgroundBridgeManager(); 433 var backgroundBridgeManager = new BackgroundBridgeManager();
428 backgroundBridgeManager.run(); 434 backgroundBridgeManager.run();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/gaia_auth/main.js » ('j') | chrome/browser/ui/webui/signin/inline_login_handler_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698