Bug 1428048 - Remove dead code browser/modules/CastingApps.jsm and its reference; r=florian
authorAleksandr Nazarkin <anazarkin1@gmail.com>
Fri, 02 Mar 2018 11:51:45 -0500
changeset 461417 2dfee3d72b6cec00f050e8883527d09d8e7ff637
parent 461384 d25c533d1f1297b9bac5d65f1b9d77deb3bc836e
child 461418 304c6387dab25b59139c20d08fe0f6843b1cbcde
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1428048, 1393582
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1428048 - Remove dead code browser/modules/CastingApps.jsm and its reference; r=florian CastingApps.jsm was removed from browser/modules/moz.build file in bug 1393582, but the file itself and its usage was not removed from ContextMenu.jsm MozReview-Commit-ID: DsqJTPP66xE
browser/modules/CastingApps.jsm
browser/modules/ContextMenu.jsm
deleted file mode 100644
--- a/browser/modules/CastingApps.jsm
+++ /dev/null
@@ -1,162 +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";
-var EXPORTED_SYMBOLS = ["CastingApps"];
-
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
-
-
-var CastingApps = {
-  _sendEventToVideo(element, data) {
-    let event = element.ownerDocument.createEvent("CustomEvent");
-    event.initCustomEvent("media-videoCasting", false, true, JSON.stringify(data));
-    element.dispatchEvent(event);
-  },
-
-  makeURI(url, charset, baseURI) {
-    return Services.io.newURI(url, charset, baseURI);
-  },
-
-  getVideo(element) {
-    if (!element) {
-      return null;
-    }
-
-    let extensions = SimpleServiceDiscovery.getSupportedExtensions();
-    let types = SimpleServiceDiscovery.getSupportedMimeTypes();
-
-    // Grab the poster attribute from the <video>
-    let posterURL = element.poster;
-
-    // First, look to see if the <video> has a src attribute
-    let sourceURL = element.src;
-
-    // If empty, try the currentSrc
-    if (!sourceURL) {
-      sourceURL = element.currentSrc;
-    }
-
-    if (sourceURL) {
-      // Use the file extension to guess the mime type
-      let sourceURI = this.makeURI(sourceURL, null, this.makeURI(element.baseURI));
-      if (this.allowableExtension(sourceURI, extensions)) {
-        return { element, source: sourceURI.spec, poster: posterURL, sourceURI};
-      }
-    }
-
-    // Next, look to see if there is a <source> child element that meets
-    // our needs
-    let sourceNodes = element.getElementsByTagName("source");
-    for (let sourceNode of sourceNodes) {
-      let sourceURI = this.makeURI(sourceNode.src, null, this.makeURI(sourceNode.baseURI));
-
-      // Using the type attribute is our ideal way to guess the mime type. Otherwise,
-      // fallback to using the file extension to guess the mime type
-      if (this.allowableMimeType(sourceNode.type, types) || this.allowableExtension(sourceURI, extensions)) {
-        return { element, source: sourceURI.spec, poster: posterURL, sourceURI, type: sourceNode.type };
-      }
-    }
-
-    return null;
-  },
-
-  sendVideoToService(videoElement, service) {
-    if (!service)
-      return;
-
-    let video = this.getVideo(videoElement);
-    if (!video) {
-      return;
-    }
-
-    // Make sure we have a player app for the given service
-    let app = SimpleServiceDiscovery.findAppForService(service);
-    if (!app)
-      return;
-
-    video.title = videoElement.ownerGlobal.top.document.title;
-    if (video.element) {
-      // If the video is currently playing on the device, pause it
-      if (!video.element.paused) {
-        video.element.pause();
-      }
-    }
-
-    app.stop(() => {
-      app.start(started => {
-        if (!started) {
-          Cu.reportError("CastingApps: Unable to start app");
-          return;
-        }
-
-        app.remoteMedia(remoteMedia => {
-          if (!remoteMedia) {
-            Cu.reportError("CastingApps: Failed to create remotemedia");
-            return;
-          }
-
-          this.session = {
-            service,
-            app,
-            remoteMedia,
-            data: {
-              title: video.title,
-              source: video.source,
-              poster: video.poster
-            },
-            videoRef: Cu.getWeakReference(video.element)
-          };
-        }, this);
-      });
-    });
-  },
-
-  getServicesForVideo(videoElement) {
-    let video = this.getVideo(videoElement);
-    if (!video) {
-      return {};
-    }
-
-    let filteredServices = SimpleServiceDiscovery.services.filter(service => {
-      return this.allowableExtension(video.sourceURI, service.extensions) ||
-             this.allowableMimeType(video.type, service.types);
-    });
-
-    return filteredServices;
-  },
-
-  getServicesForMirroring() {
-    return SimpleServiceDiscovery.services.filter(service => service.mirror);
-  },
-
-  // RemoteMedia callback API methods
-  onRemoteMediaStart(remoteMedia) {
-    if (!this.session) {
-      return;
-    }
-
-    remoteMedia.load(this.session.data);
-
-    let video = this.session.videoRef.get();
-    if (video) {
-      this._sendEventToVideo(video, { active: true });
-    }
-  },
-
-  onRemoteMediaStop(remoteMedia) {
-  },
-
-  onRemoteMediaStatus(remoteMedia) {
-  },
-
-  allowableExtension(uri, extensions) {
-    return (uri instanceof Ci.nsIURL) && extensions.includes(uri.fileExtension);
-  },
-
-  allowableMimeType(type, types) {
-    return types.includes(type);
-  }
-};
--- a/browser/modules/ContextMenu.jsm
+++ b/browser/modules/ContextMenu.jsm
@@ -10,17 +10,16 @@ var EXPORTED_SYMBOLS = ["ContextMenu"];
 
 Cu.importGlobalProperties(["URL"]);
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   E10SUtils: "resource://gre/modules/E10SUtils.jsm",
-  CastingApps: "resource:///modules/CastingApps.jsm",
   BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
   PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
   findCssSelector: "resource://gre/modules/css-selector.js",
   SpellCheckHelper: "resource://gre/modules/InlineSpellChecker.jsm",
   LoginManagerContent: "resource://gre/modules/LoginManagerContent.jsm",
   WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   InlineSpellCheckerContent: "resource://gre/modules/InlineSpellCheckerContent.jsm",