Index: ui/file_manager/image_loader/request.js |
diff --git a/ui/file_manager/image_loader/request.js b/ui/file_manager/image_loader/request.js |
index 49fdd37e0f278cb7dbc470e56de837836f207b1b..29b701892838e95aeb63e940553438018ac4a53f 100644 |
--- a/ui/file_manager/image_loader/request.js |
+++ b/ui/file_manager/image_loader/request.js |
@@ -8,7 +8,8 @@ |
* priority: (number|undefined), |
* taskId: number, |
* timestamp: (number|undefined), |
- * url: string |
+ * url: string, |
+ * orientation: ImageOrientation |
* }} |
*/ |
var LoadImageRequest; |
@@ -19,11 +20,12 @@ var LoadImageRequest; |
* |
* @param {string} id Request ID. |
* @param {Cache} cache Cache object. |
+ * @param {!PiexLoader} piexLoader Piex loader for RAW file. |
* @param {LoadImageRequest} request Request message as a hash array. |
* @param {function(Object)} callback Callback used to send the response. |
* @constructor |
*/ |
-function Request(id, cache, request, callback) { |
+function Request(id, cache, piexLoader, request, callback) { |
/** |
* @type {string} |
* @private |
@@ -37,6 +39,12 @@ function Request(id, cache, request, callback) { |
this.cache_ = cache; |
/** |
+ * @type {!PiexLoader} |
+ * @private |
+ */ |
+ this.piexLoader_ = piexLoader; |
+ |
+ /** |
* @type {LoadImageRequest} |
* @private |
*/ |
@@ -226,11 +234,24 @@ Request.prototype.downloadOriginal_ = function(onSuccess, onFailure) { |
return; |
} |
+ // Load RAW images by using Piex loader instead of XHR. |
+ if (FileType.getTypeForName(this.request_.url).type === 'raw') { |
+ this.piexLoader_.load(this.request_.url).then(function(data) { |
+ var blob = new Blob([data.thumbnail], {type: 'image/jpeg'}); |
+ var url = URL.createObjectURL(blob); |
+ this.image_.src = url; |
+ this.request_.orientation = data.orientation; |
+ }.bind(this), function(error) { |
+ console.error('PiexLoaderError: ', error); |
+ onFailure(); |
+ }); |
+ return; |
+ } |
+ |
// Fetch the image via authorized XHR and parse it. |
var parseImage = function(contentType, blob) { |
if (contentType) |
this.contentType_ = contentType; |
- |
this.image_.src = URL.createObjectURL(blob); |
}.bind(this); |