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

Unified Diff: chrome/browser/resources/gaia_auth/background.js

Issue 171533014: Revert of Implement inline signin with iframe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/gaia_auth/background.js
diff --git a/chrome/browser/resources/gaia_auth/background.js b/chrome/browser/resources/gaia_auth/background.js
index dcbeb0c7dd69389486efa9a656efac7ee0c2d69c..a571c10e8561c6e0d9fb885300f8adfb7e7cdb45 100644
--- a/chrome/browser/resources/gaia_auth/background.js
+++ b/chrome/browser/resources/gaia_auth/background.js
@@ -32,21 +32,6 @@
}
BackgroundBridge.prototype = {
- // Continue URL that is set from main auth script.
- continueUrl_: null,
-
- // Whether the extension is loaded in a constrained window.
- // Set from main auth script.
- isConstrainedWindow_: null,
-
- // Email of the newly authenticated user based on the gaia response header
- // 'google-accounts-signin'.
- email_: null,
-
- // Session index of the newly authenticated user based on the gaia response
- // header 'google-accounts-signin'.
- sessionIndex_: null,
-
// Gaia URL base that is set from main auth script.
gaiaUrl_: null,
@@ -56,8 +41,8 @@
passwordStore_: {},
- channelMain_: {},
- channelInjected_: {},
+ channelMain_: null,
+ channelInjected_: null,
run: function() {
chrome.runtime.onConnect.addListener(this.onConnect_.bind(this));
@@ -94,129 +79,31 @@
* Sets up the communication channel with the main script.
*/
setupForAuthMain_: function(port) {
- var currentChannel = new Channel();
- currentChannel.init(port);
-
- // Registers for desktop related messages.
- currentChannel.registerMessage(
- 'initDesktopFlow', this.onInitDesktopFlow_.bind(this));
-
- // Registers for SAML related messages.
- currentChannel.registerMessage(
+ this.channelMain_ = new Channel();
+ this.channelMain_.init(port);
+ this.channelMain_.registerMessage(
'setGaiaUrl', this.onSetGaiaUrl_.bind(this));
- currentChannel.registerMessage(
+ this.channelMain_.registerMessage(
'resetAuth', this.onResetAuth_.bind(this));
- currentChannel.registerMessage(
+ this.channelMain_.registerMessage(
'startAuth', this.onAuthStarted_.bind(this));
- currentChannel.registerMessage(
+ this.channelMain_.registerMessage(
'getScrapedPasswords',
this.onGetScrapedPasswords_.bind(this));
-
- this.channelMain_[this.getTabIdFromPort_(port)] = currentChannel;
-
},
/**
* Sets up the communication channel with the injected script.
*/
setupForInjected_: function(port) {
- var currentChannel = new Channel();
- currentChannel.init(port);
-
- var tabId = this.getTabIdFromPort_(port);
- currentChannel.registerMessage(
- 'apiCall', this.onAPICall_.bind(this, tabId));
- currentChannel.registerMessage(
+ this.channelInjected_ = new Channel();
+ this.channelInjected_.init(port);
+ this.channelInjected_.registerMessage(
+ 'apiCall', this.onAPICall_.bind(this));
+ this.channelInjected_.registerMessage(
'updatePassword', this.onUpdatePassword_.bind(this));
- currentChannel.registerMessage(
- 'pageLoaded', this.onPageLoaded_.bind(this, tabId));
-
- this.channelInjected_[this.getTabIdFromPort_(port)] = currentChannel;
- },
-
- getTabIdFromPort_: function(port) {
- return port.sender.tab ? port.sender.tab.id : -1;
- },
-
- /**
- * Handler for 'initDesktopFlow' signal sent from the main script.
- * Only called in desktop mode.
- */
- onInitDesktopFlow_: function(msg) {
- this.gaiaUrl_ = msg.gaiaUrl;
- this.continueUrl_ = msg.continueUrl;
- this.isConstrainedWindow_ = msg.isConstrainedWindow;
-
- var urls = [];
- var filter = {urls: urls, types: ['sub_frame']};
- var optExtraInfoSpec = [];
- if (msg.isConstrainedWindow) {
- urls.push('<all_urls>');
- optExtraInfoSpec.push('responseHeaders');
- } else {
- urls.push(this.continueUrl_ + '*');
- }
-
- chrome.webRequest.onCompleted.addListener(
- this.onRequestCompletedInDesktopMode_.bind(this),
- filter, optExtraInfoSpec);
- chrome.webRequest.onHeadersReceived.addListener(
- this.onHeadersReceivedInDesktopMode_.bind(this),
- {urls: [this.gaiaUrl_ + '*'], types: ['sub_frame']},
- ['responseHeaders']);
- },
-
- /**
- * Event listener for webRequest.onCompleted in desktop mode.
- */
- onRequestCompletedInDesktopMode_: function(details) {
- var msg = null;
- if (details.url.lastIndexOf(this.continueUrl_, 0) == 0) {
- var skipForNow = false;
- if (details.url.indexOf('ntp=1') >= 0) {
- skipForNow = true;
- }
- msg = {
- 'name': 'completeLogin',
- 'email': this.email_,
- 'sessionIndex': this.sessionIndex_,
- 'skipForNow': skipForNow
- };
- } else if (this.isConstrainedWindow_) {
- var headers = details.responseHeaders;
- for (var i = 0; headers && i < headers.length; ++i) {
- if (headers[i].name.toLowerCase() == 'google-accounts-embedded') {
- return;
- }
- }
- msg = {
- 'name': 'switchToFullTab',
- 'url': details.url
- };
- }
-
- if (msg != null)
- this.channelMain_[details.tabId].send(msg);
- },
-
- /**
- * Event listener for webRequest.onHeadersReceived in desktop mode.
- */
- onHeadersReceivedInDesktopMode_: function(details) {
- var headers = details.responseHeaders;
- for (var i = 0; headers && i < headers.length; ++i) {
- if (headers[i].name.toLowerCase() == 'google-accounts-signin') {
- var headerValues = headers[i].value.toLowerCase().split(',');
- var signinDetails = {};
- headerValues.forEach(function(e) {
- var pair = e.split('=');
- signinDetails[pair[0].trim()] = pair[1].trim();
- });
- this.email_ = signinDetails['email'].slice(1, -1); // Remove "" around.
- this.sessionIndex_ = signinDetails['sessionindex'];
- return;
- }
- }
+ this.channelInjected_.registerMessage(
+ 'pageLoaded', this.onPageLoaded_.bind(this));
},
/**
@@ -266,10 +153,8 @@
return Object.keys(passwords);
},
- onAPICall_: function(tabId, msg) {
- if (tabId in this.channelMain_) {
- this.channelMain_[tabId].send(msg);
- }
+ onAPICall_: function(msg) {
+ this.channelMain_.send(msg);
},
onUpdatePassword_: function(msg) {
@@ -279,10 +164,8 @@
this.passwordStore_[msg.id] = msg.password;
},
- onPageLoaded_: function(tabId, msg) {
- if (tabId in this.channelMain_) {
- this.channelMain_[tabId].send({name: 'onAuthPageLoaded', url: msg.url});
- }
+ onPageLoaded_: function(msg) {
+ this.channelMain_.send({name: 'onAuthPageLoaded', url: msg.url});
}
};
« no previous file with comments | « chrome/browser/resources/component_extension_resources.grd ('k') | chrome/browser/resources/gaia_auth/desktop_injected.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698