Skip to content

Instantly share code, notes, and snippets.

@YungSang
Created January 12, 2013 20:35
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YungSang/4520337 to your computer and use it in GitHub Desktop.
Save YungSang/4520337 to your computer and use it in GitHub Desktop.
[Deprecated] Patch for Tombloo on Firefox 18 これを直接パッチディレクトリに突っ込んで再起動させるといいはず。 ※ この修正は Tombloo 0.4.33 で取り込まれました。
(function() {
addAround(grobal, 'download', function(proceed, args, self) {
try {
return proceed(args);
}
catch (e) {
return _download.apply(self, args);
}
});
function _download(sourceURL, targetFile, useManger){
var d = new Deferred();
var sourceURI = createURI(sourceURL);
if(!targetFile)
targetFile = getDownloadDir();
if(targetFile.exists() && targetFile.isDirectory())
targetFile.append(validateFileName(sourceURI.fileName));
var targetURI = IOService.newFileURI(targetFile);
var p = WebBrowserPersist();
if(useManger)
var download = broad(DownloadManager.addDownload(
DownloadManager.DOWNLOAD_TYPE_DOWNLOAD, sourceURI, targetURI,
null, null, Math.round(Date.now() * 1000), null, p));
p.progressListener = {
onLocationChange : (useManger)? bind('onLocationChange', download) : function(){},
onProgressChange : (useManger)? bind('onProgressChange', download) : function(){},
onSecurityChange : (useManger)? bind('onSecurityChange', download) : function(){},
onStatusChange : (useManger)? bind('onStatusChange', download) : function(){},
onStateChange : function(progress, req, state, status){
useManger && download.onStateChange(progress, req, state, status);
if(state & IWebProgressListener.STATE_STOP){
broad(req);
var res = {
channel : req,
status : req.responseStatus,
statusText : req.responseStatusText,
};
if(!res.status || res.status < 400){
d.callback(targetFile, res);
}else{
error(res);
targetFile.remove(false);
res.message = getMessage('error.http.' + res.status);
d.errback(res);
}
}
},
}
p.persistFlags =
p.PERSIST_FLAGS_FROM_CACHE |
p.PERSIST_FLAGS_REPLACE_EXISTING_FILES |
p.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
p.saveURI(sourceURI, null, null, null, null, targetURI, null);
return d;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment