www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 741ca99c10e6ac0637178f601e0c9f8816f3850b
parent d0a99fc0a1519356e48ae795e90f5882820a13b3
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  2 Feb 2016 02:51:52 -0500

Restore open/save dialog when cancelling MIME type intercept

Behavior from #617 apparently got lost in the transition to master

Diffstat:
Mchrome/content/zotero/xpcom/mimeTypeHandler.js | 55++++++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js @@ -320,7 +320,7 @@ Zotero.MIMETypeHandler = new function () { /** * Called when the request is done */ - _StreamListener.prototype.onStopRequest = function(channel, context, status) { + _StreamListener.prototype.onStopRequest = Zotero.Promise.coroutine(function* (channel, context, status) { Zotero.debug("charset is " + channel.contentCharset); var inputStream = this._storageStream.newInputStream(0); @@ -337,34 +337,39 @@ Zotero.MIMETypeHandler = new function () { convStream.close(); inputStream.close(); - var me = this; - Zotero.Promise.resolve( - _typeHandlers[this._contentType](readString, (this._request.name ? this._request.name : null), + var handled = false; + try { + handled = _typeHandlers[this._contentType]( + readString, + this._request.name ? this._request.name : null, this._contentType, - channel) - ) - .catch(function(e) { - Zotero.debug(e, 2); - - // if there was an error, handle using nsIExternalHelperAppService - var externalHelperAppService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"]. - getService(Components.interfaces.nsIExternalHelperAppService); - var frontWindow = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]. - getService(Components.interfaces.nsIWindowWatcher).activeWindow; + channel + ); + } + catch (e) { + Zotero.logError(e); + } + + if (handled === false) { + // Handle using nsIExternalHelperAppService + let externalHelperAppService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"] + .getService(Components.interfaces.nsIExternalHelperAppService); + let frontWindow = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] + .getService(Components.interfaces.nsIWindowWatcher).activeWindow; - var inputStream = me._storageStream.newInputStream(0); - var streamListener = externalHelperAppService.doContent(me._contentType, me._request, frontWindow, null); + let inputStream = this._storageStream.newInputStream(0); + let streamListener = externalHelperAppService.doContent( + this._contentType, this._request, frontWindow, null + ); if (streamListener) { streamListener.onStartRequest(channel, context); - streamListener.onDataAvailable(me._request, context, inputStream, 0, me._storageStream.length); + streamListener.onDataAvailable( + this._request, context, inputStream, 0, this._storageStream.length + ); streamListener.onStopRequest(channel, context, status); } - - // then throw our error - throw e; - }) - .finally(function() { - me._storageStream.close(); - });; - } + } + + this._storageStream.close(); + }); }