diff --git a/browser/extensions/fxmonitor/background.js b/browser/extensions/fxmonitor/background.js new file mode 100644 index 000000000000..5439e8f5ce2a --- /dev/null +++ b/browser/extensions/fxmonitor/background.js @@ -0,0 +1 @@ +browser.fxmonitor.start(); diff --git a/browser/extensions/fxmonitor/manifest.json b/browser/extensions/fxmonitor/manifest.json new file mode 100644 index 000000000000..5bc089c659d2 --- /dev/null +++ b/browser/extensions/fxmonitor/manifest.json @@ -0,0 +1,24 @@ +{ + "manifest_version": 2, + "name": "Firefox Monitor", + "version": "2.0", + "background": { + "scripts": ["background.js"] + }, + "applications": { + "gecko": { + "id": "fxmonitor@mozilla.org", + "strict_min_version": "62.0" + } + }, + "experiment_apis": { + "fxmonitor": { + "schema": "./privileged/schema.json", + "parent": { + "scopes": ["addon_parent"], + "script": "./privileged/api.js", + "paths": [["fxmonitor"]] + } + } + } +} diff --git a/browser/extensions/fxmonitor/moz.build b/browser/extensions/fxmonitor/moz.build new file mode 100644 index 000000000000..9b643ba5139c --- /dev/null +++ b/browser/extensions/fxmonitor/moz.build @@ -0,0 +1,19 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +with Files("**"): + BUG_COMPONENT = ("Firefox", "Firefox Monitor") + +FINAL_TARGET_FILES.features['fxmonitor@mozilla.org'] += [ + 'background.js', + 'manifest.json' +] + +FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['privileged'] += [ + 'privileged/api.js', + 'privileged/FirefoxMonitor.jsm', + 'privileged/schema.json' +] diff --git a/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm b/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm new file mode 100644 index 000000000000..283e2785c8c1 --- /dev/null +++ b/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm @@ -0,0 +1,14 @@ +ChromeUtils.defineModuleGetter(this, "Preferences", + "resource://gre/modules/Preferences.jsm"); + +this.FirefoxMonitor = { + kEnabledPref: "extensions.fxmonitor.enabled", + extension: null, + init(aExtension) { + this.extension = aExtension; + + if (!Preferences.get(this.kEnabledPref, false)) { + return; + } + }, +}; diff --git a/browser/extensions/fxmonitor/privileged/api.js b/browser/extensions/fxmonitor/privileged/api.js new file mode 100644 index 000000000000..c3fd1f2f4433 --- /dev/null +++ b/browser/extensions/fxmonitor/privileged/api.js @@ -0,0 +1,18 @@ +ChromeUtils.defineModuleGetter(this, "Services", + "resource://gre/modules/Services.jsm"); + +this.fxmonitor = class extends ExtensionAPI { + getAPI(context) { + const FirefoxMonitorContainer = {}; + Services.scriptloader.loadSubScript( + context.extension.getURL("privileged/FirefoxMonitor.jsm"), + FirefoxMonitorContainer); + return { + fxmonitor: { + async start() { + FirefoxMonitorContainer.FirefoxMonitor.init(context.extension); + }, + }, + }; + } +}; diff --git a/browser/extensions/fxmonitor/privileged/schema.json b/browser/extensions/fxmonitor/privileged/schema.json new file mode 100644 index 000000000000..c5edd97db9ef --- /dev/null +++ b/browser/extensions/fxmonitor/privileged/schema.json @@ -0,0 +1,13 @@ +[ + { + "namespace": "fxmonitor", + "functions": [ + { + "name": "start", + "type": "function", + "async": true, + "parameters": [] + } + ] + } +] diff --git a/browser/extensions/moz.build b/browser/extensions/moz.build index 66ac545f478c..dc177048ab8a 100644 --- a/browser/extensions/moz.build +++ b/browser/extensions/moz.build @@ -7,6 +7,7 @@ DIRS += [ 'aushelper', 'formautofill', + 'fxmonitor', 'onboarding', 'pdfjs', 'pocket',