summaryrefslogtreecommitdiffstats
path: root/mobile/android/android-components/components/feature/accounts/src/main/assets/extensions/fxawebchannel/background.js
blob: b90f57154a83067fb7f13997a58f5946cf2b1aac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* 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/. */

/*
Establish communication with native application.
*/
const WEB_CHANNEL_BACKGROUND_MESSAGING_ID = "mozacWebchannelBackground";
let port = browser.runtime.connectNative(WEB_CHANNEL_BACKGROUND_MESSAGING_ID);
/*
Handle messages from native application, register content script for specific url.
*/
port.onMessage.addListener( event => {
  if(event.type == "overrideFxAServer"){
    browser.contentScripts.register({
      "matches": [ event.url+"/*" ],
      "js": [{file: "fxawebchannel.js"}],
      "runAt": "document_start"
    });
    port.disconnect();
  }
});