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

Unified Diff: chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_images_grid.js

Issue 11028121: Convert wallpaper picker to v2 app (Closed) Base URL: http://git.chromium.org/chromium/src.git@AppsV2
Patch Set: Write async loop to make it more readable Created 8 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
Index: chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_images_grid.js
diff --git a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_images_grid.js b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_images_grid.js
index cb42b166e915e4dfae5bc026cf1277da84f886e9..0d2ee49213aa1801ac37d25f13aa634e17a4849e 100644
--- a/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_images_grid.js
+++ b/chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_images_grid.js
@@ -32,11 +32,21 @@ cr.define('wallpapers', function() {
decorate: function() {
GridItem.prototype.decorate.call(this);
var imageEl = cr.doc.createElement('img');
- // Thumbnail
- imageEl.src = this.dataItem.baseURL + ThumbnailSuffix;
- // Remove any garbage added by GridItem and ListItem decorators.
- this.textContent = '';
- this.appendChild(imageEl);
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', this.dataItem.baseURL + ThumbnailSuffix, true);
+ xhr.responseType = 'blob';
+ xhr.send(null);
+ var self = this;
+ xhr.addEventListener('load', function(e) {
+ if (xhr.status === 200) {
+ self.textContent = '';
+ imageEl.src = window.URL.createObjectURL(xhr.response);
+ imageEl.addEventListener('load', function(e) {
+ window.URL.revokeObjectURL(this.src);
+ });
+ self.appendChild(imageEl);
+ }
+ });
},
};

Powered by Google App Engine
This is Rietveld 408576698