b2g/components/MailtoProtocolHandler.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
     9 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
    11 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
    12                                    "@mozilla.org/childprocessmessagemanager;1",
    13                                    "nsIMessageSender");
    15 function MailtoProtocolHandler() {
    16 }
    18 MailtoProtocolHandler.prototype = {
    20   scheme: "mailto",
    21   defaultPort: -1,
    22   protocolFlags: Ci.nsIProtocolHandler.URI_NORELATIVE |
    23                  Ci.nsIProtocolHandler.URI_NOAUTH |
    24                  Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
    25                  Ci.nsIProtocolHandler.URI_DOES_NOT_RETURN_DATA,
    26   allowPort: function() false,
    28   newURI: function Proto_newURI(aSpec, aOriginCharset) {
    29     let uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
    30     uri.spec = aSpec;
    31     return uri;
    32   },
    34   newChannel: function Proto_newChannel(aURI) {
    35     cpmm.sendAsyncMessage("mail-handler", {
    36       URI: aURI.spec,
    37       type: "mail" });
    39     throw Components.results.NS_ERROR_ILLEGAL_VALUE;
    40   },
    42   classID: Components.ID("{50777e53-0331-4366-a191-900999be386c}"),
    43   QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler])
    44 };
    46 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MailtoProtocolHandler]);

mercurial