Index: ui/file_manager/image_loader/piex_loader.js |
diff --git a/ui/file_manager/image_loader/piex_loader.js b/ui/file_manager/image_loader/piex_loader.js |
index e506e3a4d03f208f61e9f521ce9cdfe7c45cbf86..a7b81f4ad4f412fdacc3853c6816ea7891efeec8 100644 |
--- a/ui/file_manager/image_loader/piex_loader.js |
+++ b/ui/file_manager/image_loader/piex_loader.js |
@@ -65,14 +65,14 @@ function PiexLoader() { |
this.naclModule_ = document.createElement('embed'); |
/** |
- * @private {!Promise} |
+ * @private {!Promise<boolean>} |
* @const |
*/ |
this.naclPromise_ = new Promise(function(fulfill) { |
chrome.fileManagerPrivate.isPiexLoaderEnabled(fulfill); |
}).then(function(enabled) { |
if (!enabled) |
- return Promise.reject('PiexLoader is not enabled for chromium build.'); |
+ return false; |
return new Promise(function(fulfill, reject) { |
var embed = this.naclModule_; |
embed.setAttribute('type', 'application/x-pnacl'); |
@@ -99,8 +99,12 @@ function PiexLoader() { |
}.bind(this), true); |
listenerContainer.style.height = '0px'; |
document.body.appendChild(listenerContainer); |
+ return true; |
oka
2017/02/07 17:01:33
wondering why it's not fulfill(true).
hirono
2017/02/09 03:52:55
Yes, the line is wrong. Removed this and updated #
|
}.bind(this)); |
- }.bind(this)); |
+ }.bind(this)).catch(function (error) { |
+ console.error(error); |
+ return false; |
+ }); |
/** |
* @private {!Object<number, PiexRequestCallbacks>} |
@@ -135,7 +139,9 @@ PiexLoader.prototype.onMessage_ = function(event) { |
* @return {!Promise<!PiexLoaderResponse>} |
*/ |
PiexLoader.prototype.load = function(url) { |
- return this.naclPromise_.then(function() { |
+ return this.naclPromise_.then(function(loaded) { |
+ if (!loaded) |
+ return Promise.reject('Piex is not loaded'); |
var message = { |
id: this.requestIdCount_++, |
name: 'loadThumbnail', |
@@ -144,6 +150,9 @@ PiexLoader.prototype.load = function(url) { |
this.naclModule_.postMessage(message); |
return new Promise(function(fulfill, reject) { |
this.requests_[message.id] = {fulfill: fulfill, reject: reject}; |
- }.bind(this)); |
+ }.bind(this)).catch(function(error) { |
+ console.error('PiexLoaderError: ', error); |
+ return Promise.reject(error); |
+ }); |
}.bind(this)); |
}; |