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

Unified Diff: chrome/browser/resources/image_loader/request.js

Issue 48553003: Fix thumbnails in the guest mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 7 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 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/image_loader/request.js
diff --git a/chrome/browser/resources/image_loader/request.js b/chrome/browser/resources/image_loader/request.js
index 40c3b40cbd0bbf4f9f2dbb6c8fdd3b03d787f104..11fc7c1ec6c158a49245efa3aadbf65871d59b70 100644
--- a/chrome/browser/resources/image_loader/request.js
+++ b/chrome/browser/resources/image_loader/request.js
@@ -260,7 +260,7 @@ AuthorizedXHR.prototype.load = function(url, onSuccess, onFailure) {
onInnerFailure();
return;
}
- this.xhr_ = AuthorizedXHR.loadWithToken_(
+ this.xhr_ = AuthorizedXHR.load_(
token, url, onInnerSuccess, onInnerFailure);
}.bind(this));
}.bind(this);
@@ -272,6 +272,12 @@ AuthorizedXHR.prototype.load = function(url, onSuccess, onFailure) {
requestTokenAndCall(true, onMaybeSuccess, onMaybeFailure);
}.bind(this);
+ // Do not request a token for local resources, since it is not necessary.
+ if (url.indexOf('filesystem:') === 0) {
+ this.xhr_ = AuthorizedXHR.load_(null, url, onMaybeSuccess, onMaybeFailure);
+ return;
+ }
+
// Make the request with reusing the current token. If it fails, then retry.
requestTokenAndCall(false, onMaybeSuccess, maybeRetryCall);
};
@@ -280,15 +286,17 @@ AuthorizedXHR.prototype.load = function(url, onSuccess, onFailure) {
* Fetches data using authorized XmlHttpRequest with the provided OAuth2 token.
* If the token is invalid, the request will fail.
*
- * @param {string} token OAuth2 token to be injected to the request.
+ * @param {?string} token OAuth2 token to be injected to the request. Null for
+ * no token.
* @param {string} url URL to the resource to be fetched.
* @param {function(string, Blob}) onSuccess Success callback with the content
* type and the fetched data.
* @param {function(number=)} onFailure Failure callback with the error code
* if available.
+ * @return {AuthorizedXHR} XHR instance.
* @private
*/
-AuthorizedXHR.loadWithToken_ = function(token, url, onSuccess, onFailure) {
+AuthorizedXHR.load_ = function(token, url, onSuccess, onFailure) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
@@ -306,11 +314,14 @@ AuthorizedXHR.loadWithToken_ = function(token, url, onSuccess, onFailure) {
// Perform a xhr request.
try {
xhr.open('GET', url, true);
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
+ if (token)
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.send();
} catch (e) {
onFailure();
}
+
+ return xhr;
};
/**
« 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