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 0d2ee49213aa1801ac37d25f13aa634e17a4849e..0df65a7cfb5fdc2dd28ca42b87370f644747ae73 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,19 +32,36 @@ cr.define('wallpapers', function() { |
decorate: function() { |
GridItem.prototype.decorate.call(this); |
var imageEl = cr.doc.createElement('img'); |
- 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); |
+ chrome.wallpaperPrivate.getThumbnail(this.dataItem.baseURL, |
+ function(result) { |
+ if (result.success) { |
+ var data = new Int8Array(result.data); |
+ var blob = new Blob([data]); |
+ imageEl.src = window.URL.createObjectURL(blob); |
imageEl.addEventListener('load', function(e) { |
window.URL.revokeObjectURL(this.src); |
}); |
self.appendChild(imageEl); |
+ } else { |
+ var xhr = new XMLHttpRequest(); |
+ xhr.open('GET', self.dataItem.baseURL + ThumbnailSuffix, true); |
+ xhr.responseType = 'arraybuffer'; |
+ xhr.send(null); |
+ xhr.addEventListener('load', function(e) { |
+ if (xhr.status === 200) { |
+ self.textContent = ''; |
+ chrome.wallpaperPrivate.saveThumbnail(xhr.response, |
+ self.dataItem.baseURL); |
+ var data = new Int8Array(xhr.response); |
+ var blob = new Blob([data]); |
flackr
2012/11/27 22:04:36
Combine these two lines, you only use data here.
bshe
2012/11/28 18:54:26
Done.
flackr
2012/12/03 19:02:30
This doesn't look done.
bshe
2012/12/03 19:39:32
Sorry. I changed the one at line 38 but somehow fo
|
+ imageEl.src = window.URL.createObjectURL(blob); |
+ imageEl.addEventListener('load', function(e) { |
+ window.URL.revokeObjectURL(this.src); |
+ }); |
+ self.appendChild(imageEl); |
flackr
2012/11/27 22:04:36
The list of thumbnails grow as we fetch them? We s
bshe
2012/11/28 18:54:26
The img tag is added to a div. And the div has wid
flackr
2012/12/03 19:02:30
Yes that sounds good to me.
|
+ } |
+ }); |
} |
}); |
}, |