mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
1482122303
--HG-- extra : rebase_source : 98337b6a8c07d05e8c961a452dd05a7d75c3c60b
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
|
|
"use strict";
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
const Cr = Components.results;
|
|
const Cu = Components.utils;
|
|
|
|
const PDF_CONTENT_TYPE = "application/pdf";
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
|
|
return Cc["@mozilla.org/childprocessmessagemanager;1"]
|
|
.getService(Ci.nsIMessageSender);
|
|
});
|
|
|
|
function log(aMsg) {
|
|
let msg = "ContentHandler.js: " + (aMsg.join ? aMsg.join("") : aMsg);
|
|
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
|
|
.logStringMessage(msg);
|
|
dump(msg + "\n");
|
|
}
|
|
|
|
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
|
function ContentHandler() {
|
|
}
|
|
|
|
ContentHandler.prototype = {
|
|
handleContent: function handleContent(aMimetype, aContext, aRequest) {
|
|
if (aMimetype != PDF_CONTENT_TYPE)
|
|
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
|
|
|
if (!(aRequest instanceof Ci.nsIChannel))
|
|
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
|
|
|
let detail = {
|
|
"type": aMimetype,
|
|
"url": aRequest.URI.spec
|
|
};
|
|
cpmm.sendAsyncMessage("content-handler", detail);
|
|
|
|
aRequest.cancel(Cr.NS_BINDING_ABORTED);
|
|
},
|
|
|
|
classID: Components.ID("{d18d0216-d50c-11e1-ba54-efb18d0ef0ac}"),
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler])
|
|
};
|
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentHandler]);
|