blob: a129e7d75071dea1b753da4b8158e53ce1b48dfc (
plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const EXPORTED_SYMBOLS = ["MailtoProtocolHandler"];
/**
* Protocol handler for mailto: url.
*
* @implements {nsIProtocolHandler}
*/
class MailtoProtocolHandler {
QueryInterface = ChromeUtils.generateQI([Ci.nsIProtocolHandler]);
scheme = "mailto";
allowPort = false;
newChannel(uri, loadInfo) {
// Create an empty pipe to get an inputStream.
let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
pipe.init(true, true, 0, 0);
pipe.outputStream.close();
// Create a channel so that we can set contentType onto it.
let streamChannel = Cc[
"@mozilla.org/network/input-stream-channel;1"
].createInstance(Ci.nsIInputStreamChannel);
streamChannel.setURI(uri);
streamChannel.contentStream = pipe.inputStream;
let channel = streamChannel.QueryInterface(Ci.nsIChannel);
// With this set, a nsIContentHandler instance will take over to open a
// compose window.
channel.contentType = "application/x-mailto";
channel.loadInfo = loadInfo;
return channel;
}
}
|