Skip to content

Commit

Permalink
Fixes #7. Cliget no longer breaks external view source.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidka committed Oct 19, 2013
1 parent e33dcad commit 4dc44fc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,21 @@ exports.main = function() {

var contractId = '@mozilla.org/uriloader/external-helper-app-service;1';

// Implement the service by subclassing Unknown
// Implement a wrapper around external helper app service
var DownloadHelper = Class({
extends: Unknown,

interfaces: ['nsIExternalHelperAppService'],

get wrappedJSObject() this,

originalService: Cc[contractId].getService(Ci.nsIExternalHelperAppService),
originalService: Cc[contractId].getService(),

applyDecodingForExtension: function(aExtension, aEncodingType) {
return this.originalService.applyDecodingForExtension(aExtension, aEncodingType);
QueryInterface: function(interface) {
var srv = this.originalService.QueryInterface(interface);
for (let i in srv)
if (!(i in this))
this[i] = function() {
return srv[i].apply(srv, arguments);
};
return this;
},

doContent: function(aMimeContentType, aRequest, aWindowContext, aForceSave) {
Expand All @@ -295,7 +298,8 @@ var DownloadHelper = Class({

if (recentChannels.length >= 10)
recentChannels.splice(0, recentChannels.length - 10);
return this.originalService.doContent(aMimeContentType, aRequest, aWindowContext, aForceSave);
return this.originalService.QueryInterface(Ci.nsIExternalHelperAppService)
.doContent(aMimeContentType, aRequest, aWindowContext, aForceSave);
}
});

Expand Down

0 comments on commit 4dc44fc

Please sign in to comment.