diff --git a/.eslintignore b/.eslintignore index c9e1fb45a4a2..834daf99c050 100644 --- a/.eslintignore +++ b/.eslintignore @@ -222,9 +222,6 @@ mobile/android/tests/browser/chrome/tp5/ mobile/android/app/mobile.js mobile/android/app/geckoview-prefs.js -# Uses `#expand` -mobile/android/chrome/content/about.js - # Not much JS to lint and non-standard at that mobile/android/installer/ mobile/android/locales/ diff --git a/mobile/android/chrome/content/.eslintrc.js b/mobile/android/chrome/content/.eslintrc.js deleted file mode 100644 index 39df19f8a9c8..000000000000 --- a/mobile/android/chrome/content/.eslintrc.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -module.exports = { - "rules": { - "complexity": ["error", 20], - - // Disabled stuff - "no-console": 0, // TODO: Can we use console? - "no-cond-assign": 0, - "no-fallthrough": 0, - } -}; diff --git a/mobile/android/chrome/content/CastingApps.js b/mobile/android/chrome/content/CastingApps.js deleted file mode 100644 index 1fde2530d97e..000000000000 --- a/mobile/android/chrome/content/CastingApps.js +++ /dev/null @@ -1,857 +0,0 @@ -// -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- -/* 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/. */ -"use strict"; - -ChromeUtils.defineModuleGetter( - this, - "PageActions", - "resource://gre/modules/PageActions.jsm" -); - -// Define service devices. We should consider moving these to their respective -// JSM files, but we left them here to allow for better lazy JSM loading. -var rokuDevice = { - id: "roku:ecp", - target: "roku:ecp", - factory: function(aService) { - const { RokuApp } = ChromeUtils.import( - "resource://gre/modules/RokuApp.jsm" - ); - return new RokuApp(aService); - }, - types: ["video/mp4"], - extensions: ["mp4"], -}; - -var mediaPlayerDevice = { - id: "media:router", - target: "media:router", - factory: function(aService) { - const { MediaPlayerApp } = ChromeUtils.import( - "resource://gre/modules/MediaPlayerApp.jsm" - ); - return new MediaPlayerApp(aService); - }, - types: ["video/mp4", "video/webm", "application/x-mpegurl"], - extensions: ["mp4", "webm", "m3u", "m3u8"], - init: function() { - GlobalEventDispatcher.registerListener(this, [ - "MediaPlayer:Added", - "MediaPlayer:Changed", - "MediaPlayer:Removed", - ]); - }, - onEvent: function(event, data, callback) { - if (event === "MediaPlayer:Added") { - let service = this.toService(data); - SimpleServiceDiscovery.addService(service); - } else if (event === "MediaPlayer:Changed") { - let service = this.toService(data); - SimpleServiceDiscovery.updateService(service); - } else if (event === "MediaPlayer:Removed") { - SimpleServiceDiscovery.removeService(data.id); - } - }, - toService: function(display) { - // Convert the native data into something matching what is created in _processService() - return { - location: display.location, - target: "media:router", - friendlyName: display.friendlyName, - uuid: display.uuid, - manufacturer: display.manufacturer, - modelName: display.modelName, - }; - }, -}; - -var CastingApps = { - _castMenuId: -1, - _blocked: null, - _bound: null, - _interval: 120 * 1000, // 120 seconds - - init: function ca_init() { - if (!this.isCastingEnabled()) { - return; - } - - // Register targets - SimpleServiceDiscovery.registerDevice(rokuDevice); - - // MediaPlayerDevice will notify us any time the native device list changes. - mediaPlayerDevice.init(); - SimpleServiceDiscovery.registerDevice(mediaPlayerDevice); - - // Search for devices continuously - SimpleServiceDiscovery.search(this._interval); - - this._castMenuId = NativeWindow.contextmenus.add( - Strings.browser.GetStringFromName("contextmenu.sendToDevice"), - this.filterCast, - this.handleContextMenu.bind(this) - ); - - GlobalEventDispatcher.registerListener(this, [ - "Casting:Play", - "Casting:Pause", - "Casting:Stop", - ]); - - Services.obs.addObserver(this, "ssdp-service-found"); - Services.obs.addObserver(this, "ssdp-service-lost"); - Services.obs.addObserver(this, "application-background"); - Services.obs.addObserver(this, "application-foreground"); - - BrowserApp.deck.addEventListener("TabSelect", this, true); - BrowserApp.deck.addEventListener("pageshow", this, true); - BrowserApp.deck.addEventListener("playing", this, true); - BrowserApp.deck.addEventListener("ended", this, true); - BrowserApp.deck.addEventListener("MozAutoplayMediaBlocked", this, true); - // Note that the XBL binding is untrusted - BrowserApp.deck.addEventListener( - "MozNoControlsVideoBindingAttached", - this, - true, - true - ); - }, - - _mirrorStarted: function(stopMirrorCallback) { - this.stopMirrorCallback = stopMirrorCallback; - NativeWindow.menu.update(this.mirrorStartMenuId, { visible: false }); - NativeWindow.menu.update(this.mirrorStopMenuId, { visible: true }); - }, - - serviceAdded: function(aService) {}, - - serviceLost: function(aService) {}, - - isCastingEnabled: function isCastingEnabled() { - return Services.prefs.getBoolPref("browser.casting.enabled"); - }, - - onEvent: function(event, message, callback) { - switch (event) { - case "Casting:Play": - if (this.session && this.session.remoteMedia.status == "paused") { - this.session.remoteMedia.play(); - } - break; - case "Casting:Pause": - if (this.session && this.session.remoteMedia.status == "started") { - this.session.remoteMedia.pause(); - } - break; - case "Casting:Stop": - if (this.session) { - this.closeExternal(); - } - break; - } - }, - - observe: function(aSubject, aTopic, aData) { - switch (aTopic) { - case "ssdp-service-found": - this.serviceAdded(SimpleServiceDiscovery.findServiceForID(aData)); - break; - case "ssdp-service-lost": - this.serviceLost(SimpleServiceDiscovery.findServiceForID(aData)); - break; - case "application-background": - // Turn off polling while in the background - this._interval = SimpleServiceDiscovery.search(0); - SimpleServiceDiscovery.stopSearch(); - break; - case "application-foreground": - // Turn polling on when app comes back to foreground - SimpleServiceDiscovery.search(this._interval); - break; - } - }, - - handleEvent: function(aEvent) { - switch (aEvent.type) { - case "TabSelect": { - let tab = BrowserApp.getTabForBrowser(aEvent.target); - this._updatePageActionForTab(tab, aEvent); - break; - } - case "pageshow": { - let tab = BrowserApp.getTabForWindow(aEvent.originalTarget.defaultView); - this._updatePageActionForTab(tab, aEvent); - break; - } - case "playing": - case "ended": { - let video = aEvent.target; - if (video instanceof HTMLVideoElement) { - // If playing, send the