Skip to content

Commit

Permalink
[embedlite-components] Intent protocol handler. Fixes JB#50750 OMP#JO…
Browse files Browse the repository at this point in the history
…LLA-164
  • Loading branch information
Marko Kenttala committed Jun 14, 2021
1 parent 233509b commit 2500b65
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jscomps/EmbedLiteJSComponents.manifest
Expand Up @@ -116,3 +116,7 @@ category app-startup LoginsHelper service,@mozilla.org/embedlite-loginshelper-co
component {08b3fb7b-b5c6-4d3c-b9c0-bde7aa0674f7} EmbedLiteWebrtcUI.js
contract @mozilla.org/embedlite-webrtc-ui;1 {08b3fb7b-b5c6-4d3c-b9c0-bde7aa0674f7}
category app-startup EmbedLiteWebrtcUI service,@mozilla.org/embedlite-webrtc-ui;1

# IntentProtocolHandler.js
component {878c8294-b764-48fd-87be-7d5e7a44faa9} IntentProtocolHandler.js
contract @mozilla.org/network/protocol;1?name=intent {878c8294-b764-48fd-87be-7d5e7a44faa9}
34 changes: 34 additions & 0 deletions jscomps/IntentProtocolHandler.js
@@ -0,0 +1,34 @@
/* 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/. */

/**
* IntentProtocolHandler.js
*/

"use strict";

const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;

Cu.import('resource://gre/modules/XPCOMUtils.jsm');

function IntentProtocolHandler() {
}

IntentProtocolHandler.prototype = {

scheme: "intent",
protocolFlags: Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,

newURI: function(aSpec, aOriginCharset, aBaseURI) {
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
// Just replace intent scheme with https to fix Android google maps links
let uri = ioService.newURI(aSpec.replace('intent:', 'https:'), null, null);
return uri;
},

classID: Components.ID("{878c8294-b764-48fd-87be-7d5e7a44faa9}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler])
};

this.NSGetFactory = XPCOMUtils.generateNSGetFactory([IntentProtocolHandler]);
1 change: 1 addition & 0 deletions jscomps/Makefile.am
Expand Up @@ -24,6 +24,7 @@ jscomps_manifest_DATA = \
EmbedliteDownloadManager.js \
LoginsHelper.js \
EmbedLiteWebrtcUI.js \
IntentProtocolHandler.js \
$(NULL)

AM_CPPFLAGS = $(DEPS_CFLAGS)

0 comments on commit 2500b65

Please sign in to comment.