utils.js: Add coroutine interface to XMLHttpRequest
[conkeror.git] / modules / mime.js
blobafd6e1113639065df36c20b8a312a538f5ab9e07
3 const mime_service = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
5 var mime_type_external_handlers = [
7     [ /^text\/.*$/, getenv("EDITOR")],
8     [/^image\/.*$/, "feh"],
9     [/^video\/.*$/, "mplayer"],
10     [/^audio\/.*$/, "mplayer"],
11     [/^application\/pdf$/, "evince"],
12     [/^application\/postscript$/, "evince"],
13     [/^application\/x-dvi$/, "evince"],
14     [/^.*$/, getenv("EDITOR")]
15     ];
17 function get_external_handler_for_mime_type(mime_type) {
18     return predicate_alist_match(mime_type_external_handlers, mime_type);
21 function mime_type_from_uri(uri) {
22     var type = "application/octet-stream";
23     try {
24         uri = make_uri(uri);
25         type = mime_service.getTypeFromURI(uri);
26     } catch (e) {}
27     return type;
30 function mime_info_from_mime_type(type) {
31     if (type == null)
32         type = "application/octet-stream";
33     try {
34         return mime_service.getFromTypeAndExtension(type, null);
35     } catch (e) {
36         return null;
37     }