b2g/components/MailtoProtocolHandler.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/b2g/components/MailtoProtocolHandler.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
    1.11 +
    1.12 +Cu.import('resource://gre/modules/XPCOMUtils.jsm');
    1.13 +
    1.14 +XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
    1.15 +                                   "@mozilla.org/childprocessmessagemanager;1",
    1.16 +                                   "nsIMessageSender");
    1.17 +
    1.18 +function MailtoProtocolHandler() {
    1.19 +}
    1.20 +
    1.21 +MailtoProtocolHandler.prototype = {
    1.22 +
    1.23 +  scheme: "mailto",
    1.24 +  defaultPort: -1,
    1.25 +  protocolFlags: Ci.nsIProtocolHandler.URI_NORELATIVE |
    1.26 +                 Ci.nsIProtocolHandler.URI_NOAUTH |
    1.27 +                 Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
    1.28 +                 Ci.nsIProtocolHandler.URI_DOES_NOT_RETURN_DATA,
    1.29 +  allowPort: function() false,
    1.30 +
    1.31 +  newURI: function Proto_newURI(aSpec, aOriginCharset) {
    1.32 +    let uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
    1.33 +    uri.spec = aSpec;
    1.34 +    return uri;
    1.35 +  },
    1.36 +
    1.37 +  newChannel: function Proto_newChannel(aURI) {
    1.38 +    cpmm.sendAsyncMessage("mail-handler", {
    1.39 +      URI: aURI.spec,
    1.40 +      type: "mail" });
    1.41 +
    1.42 +    throw Components.results.NS_ERROR_ILLEGAL_VALUE;
    1.43 +  },
    1.44 +
    1.45 +  classID: Components.ID("{50777e53-0331-4366-a191-900999be386c}"),
    1.46 +  QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler])
    1.47 +};
    1.48 +
    1.49 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MailtoProtocolHandler]);

mercurial