-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
26 lines (23 loc) · 924 Bytes
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
class API extends ExtensionAPI {
getAPI(context) {
return {
protocol: {
registerHandler(protocol, uri, name) {
// from WebContentConverter.js
let handler = Cc["@mozilla.org/uriloader/web-handler-app;1"].
createInstance(Ci.nsIWebHandlerApp);
handler.name = name;
handler.uriTemplate = uri;
let eps = Cc["@mozilla.org/uriloader/external-protocol-service;1"].
getService(Ci.nsIExternalProtocolService);
let handlerInfo = eps.getProtocolHandlerInfo(protocol);
handlerInfo.possibleApplicationHandlers.appendElement(handler, false);
let hs = Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService);
hs.store(handlerInfo);
},
},
};
}
}