michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * TelProtocolHandle.js michael@0: * michael@0: * This file implements the URLs for Telephone Calls michael@0: * https://www.ietf.org/rfc/rfc2806.txt michael@0: */ michael@0: michael@0: "use strict"; michael@0: michael@0: const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; michael@0: michael@0: Cu.import('resource://gre/modules/XPCOMUtils.jsm'); michael@0: Cu.import("resource:///modules/TelURIParser.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyServiceGetter(this, "cpmm", michael@0: "@mozilla.org/childprocessmessagemanager;1", michael@0: "nsIMessageSender"); michael@0: michael@0: function TelProtocolHandler() { michael@0: } michael@0: michael@0: TelProtocolHandler.prototype = { michael@0: michael@0: scheme: "tel", michael@0: defaultPort: -1, michael@0: protocolFlags: Ci.nsIProtocolHandler.URI_NORELATIVE | michael@0: Ci.nsIProtocolHandler.URI_NOAUTH | michael@0: Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE | michael@0: Ci.nsIProtocolHandler.URI_DOES_NOT_RETURN_DATA, michael@0: allowPort: function() false, michael@0: michael@0: newURI: function Proto_newURI(aSpec, aOriginCharset) { michael@0: let uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI); michael@0: uri.spec = aSpec; michael@0: return uri; michael@0: }, michael@0: michael@0: newChannel: function Proto_newChannel(aURI) { michael@0: let number = TelURIParser.parseURI('tel', aURI.spec); michael@0: michael@0: if (number) { michael@0: cpmm.sendAsyncMessage("dial-handler", { michael@0: number: number, michael@0: type: "webtelephony/number" }); michael@0: } michael@0: michael@0: throw Components.results.NS_ERROR_ILLEGAL_VALUE; michael@0: }, michael@0: michael@0: classID: Components.ID("{782775dd-7351-45ea-aff1-0ffa872cfdd2}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler]) michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelProtocolHandler]);