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

Unified Diff: chrome/browser/resources/gaia_auth_host/authenticator.js

Issue 905653003: Moved adding listeners on webview from load to constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/gaia_auth_host/authenticator.js
diff --git a/chrome/browser/resources/gaia_auth_host/authenticator.js b/chrome/browser/resources/gaia_auth_host/authenticator.js
index 82bb37a1d59f3ed072f9fb5cdeaec97bae5e6355..ed49d625f0f128d294a4c5d76f65eb0de37d8100 100644
--- a/chrome/browser/resources/gaia_auth_host/authenticator.js
+++ b/chrome/browser/resources/gaia_auth_host/authenticator.js
@@ -90,6 +90,27 @@ cr.define('cr.login', function() {
this.initialFrameUrl_ = null;
this.reloadUrl_ = null;
this.trusted_ = true;
+
+ this.webview_.addEventListener(
+ 'newwindow', this.onNewWindow_.bind(this));
+ this.webview_.addEventListener(
+ 'contentload', this.onContentLoad_.bind(this));
+ this.webview_.addEventListener(
+ 'loadstop', this.onLoadStop_.bind(this));
+ this.webview_.request.onCompleted.addListener(
+ this.onRequestCompleted_.bind(this),
+ {urls: ['<all_urls>'], types: ['main_frame']},
+ ['responseHeaders']);
+ this.webview_.request.onHeadersReceived.addListener(
+ this.onHeadersReceived_.bind(this),
+ {urls: ['<all_urls>'], types: ['main_frame']},
+ ['responseHeaders']);
+ window.addEventListener(
+ 'message', this.onMessageFromWebview_.bind(this), false);
+ window.addEventListener(
+ 'focus', this.onFocus_.bind(this), false);
+ window.addEventListener(
+ 'popstate', this.onPopState_.bind(this), false);
}
// TODO(guohui,xiyuan): no need to inherit EventTarget once we deprecate the
@@ -114,27 +135,6 @@ cr.define('cr.login', function() {
this.authFlow_ = AuthFlow.DEFAULT;
this.webview_.src = this.reloadUrl_;
- this.webview_.addEventListener(
- 'newwindow', this.onNewWindow_.bind(this));
- this.webview_.addEventListener(
- 'contentload', this.onContentLoad_.bind(this));
- this.webview_.addEventListener(
- 'loadstop', this.onLoadStop_.bind(this));
- this.webview_.request.onCompleted.addListener(
- this.onRequestCompleted_.bind(this),
- {urls: ['*://*/*', this.continueUrlWithoutParams_ + '*'],
- types: ['main_frame']},
- ['responseHeaders']);
- this.webview_.request.onHeadersReceived.addListener(
- this.onHeadersReceived_.bind(this),
- {urls: [this.idpOrigin_ + '*'], types: ['main_frame']},
- ['responseHeaders']);
- window.addEventListener(
- 'message', this.onMessageFromWebview_.bind(this), false);
- window.addEventListener(
- 'focus', this.onFocus_.bind(this), false);
- window.addEventListener(
- 'popstate', this.onPopState_.bind(this), false);
this.loaded_ = false;
};
@@ -242,6 +242,10 @@ cr.define('cr.login', function() {
* @private
*/
Authenticator.prototype.onHeadersReceived_ = function(details) {
+ var currentUrl = details.url;
+ if (currentUrl.lastIndexOf(this.idpOrigin_, 0) != 0)
+ return;
+
var headers = details.responseHeaders;
for (var i = 0; headers && i < headers.length; ++i) {
var header = headers[i];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698