summaryrefslogtreecommitdiffstats
path: root/dom/presentation/PresentationDeviceInfoManager.jsm
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-06 16:03:39 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:31:16 +0200
commit8c41fcd24048154e3526e506157d337a2ab434e8 (patch)
treecadcee4433f470969e8e14591f6d7d89c1c9f39b /dom/presentation/PresentationDeviceInfoManager.jsm
parent27f4e60be80610b4be361f51257a5501852ed795 (diff)
downloadUXP-8c41fcd24048154e3526e506157d337a2ab434e8.tar
UXP-8c41fcd24048154e3526e506157d337a2ab434e8.tar.gz
UXP-8c41fcd24048154e3526e506157d337a2ab434e8.tar.lz
UXP-8c41fcd24048154e3526e506157d337a2ab434e8.tar.xz
UXP-8c41fcd24048154e3526e506157d337a2ab434e8.zip
Issue #1390 - Get rid of the Presentation API
Diffstat (limited to 'dom/presentation/PresentationDeviceInfoManager.jsm')
-rw-r--r--dom/presentation/PresentationDeviceInfoManager.jsm104
1 files changed, 0 insertions, 104 deletions
diff --git a/dom/presentation/PresentationDeviceInfoManager.jsm b/dom/presentation/PresentationDeviceInfoManager.jsm
deleted file mode 100644
index 205982b9c..000000000
--- a/dom/presentation/PresentationDeviceInfoManager.jsm
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /
-/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
-/* 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";
-
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-this.EXPORTED_SYMBOLS = ["PresentationDeviceInfoService"];
-
-function log(aMsg) {
- //dump("PresentationDeviceInfoManager.jsm: " + aMsg + "\n");
-}
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "presentationDeviceManager",
- "@mozilla.org/presentation-device/manager;1",
- "nsIPresentationDeviceManager");
-
-XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
- "@mozilla.org/parentprocessmessagemanager;1",
- "nsIMessageBroadcaster");
-
-this.PresentationDeviceInfoService = {
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIMessageListener,
- Ci.nsIObserver]),
-
- init: function() {
- log("init");
- ppmm.addMessageListener("PresentationDeviceInfoManager:GetAll", this);
- ppmm.addMessageListener("PresentationDeviceInfoManager:ForceDiscovery", this);
- Services.obs.addObserver(this, "presentation-device-change", false);
- },
-
- getAll: function(aData, aMm) {
- log("getAll");
- let deviceArray = presentationDeviceManager.getAvailableDevices().QueryInterface(Ci.nsIArray);
- if (!deviceArray) {
- aData.error = "DataError";
- aMm.sendAsyncMessage("PresentationDeviceInfoManager:GetAll:Result:Error", aData);
- return;
- }
-
- aData.devices = [];
- for (let i = 0; i < deviceArray.length; i++) {
- let device = deviceArray.queryElementAt(i, Ci.nsIPresentationDevice);
- aData.devices.push({
- id: device.id,
- name: device.name,
- type: device.type,
- });
- }
- aMm.sendAsyncMessage("PresentationDeviceInfoManager:GetAll:Result:Ok", aData);
- },
-
- forceDiscovery: function() {
- log("forceDiscovery");
- presentationDeviceManager.forceDiscovery();
- },
-
- observe: function(aSubject, aTopic, aData) {
- log("observe: " + aTopic);
-
- let device = aSubject.QueryInterface(Ci.nsIPresentationDevice);
- let data = {
- type: aData,
- deviceInfo: {
- id: device.id,
- name: device.name,
- type: device.type,
- },
- };
- ppmm.broadcastAsyncMessage("PresentationDeviceInfoManager:OnDeviceChange", data);
- },
-
- receiveMessage: function(aMessage) {
- if (!aMessage.target.assertPermission("presentation-device-manage")) {
- debug("receive message " + aMessage.name +
- " from a content process with no 'presentation-device-manage' privileges.");
- return null;
- }
-
- let msg = aMessage.data || {};
- let mm = aMessage.target;
-
- log("receiveMessage: " + aMessage.name);
- switch (aMessage.name) {
- case "PresentationDeviceInfoManager:GetAll": {
- this.getAll(msg, mm);
- break;
- }
- case "PresentationDeviceInfoManager:ForceDiscovery": {
- this.forceDiscovery();
- break;
- }
- }
- },
-};
-
-this.PresentationDeviceInfoService.init();