Bug 1111967 - honor browser.casting.enabled pref for casting on desktop, r=mconley

This commit is contained in:
Gijs Kruitbosch
2015-03-09 13:15:55 +00:00
parent 70d0d8884e
commit e238e351a8
5 changed files with 23 additions and 9 deletions

View File

@@ -285,6 +285,7 @@ pref("browser.slowStartup.maxSamples", 5);
pref("browser.aboutHomeSnippets.updateUrl", "https://snippets.cdn.mozilla.net/%STARTPAGE_VERSION%/%NAME%/%VERSION%/%APPBUILDID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/"); pref("browser.aboutHomeSnippets.updateUrl", "https://snippets.cdn.mozilla.net/%STARTPAGE_VERSION%/%NAME%/%VERSION%/%APPBUILDID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/");
pref("browser.enable_automatic_image_resizing", true); pref("browser.enable_automatic_image_resizing", true);
pref("browser.casting.enabled", true);
pref("browser.chrome.site_icons", true); pref("browser.chrome.site_icons", true);
pref("browser.chrome.favicons", true); pref("browser.chrome.favicons", true);
// browser.warnOnQuit == false will override all other possible prompts when quitting or restarting // browser.warnOnQuit == false will override all other possible prompts when quitting or restarting

View File

@@ -2949,7 +2949,10 @@ function BrowserFullScreen()
} }
function mirrorShow(popup) { function mirrorShow(popup) {
let services = CastingApps.getServicesForMirroring(); let services = [];
if (Services.prefs.getBoolPref("browser.casting.enabled")) {
services = CastingApps.getServicesForMirroring();
}
popup.ownerDocument.getElementById("menu_mirrorTabCmd").hidden = !services.length; popup.ownerDocument.getElementById("menu_mirrorTabCmd").hidden = !services.length;
} }
@@ -2959,8 +2962,11 @@ function mirrorMenuItemClicked(event) {
} }
function populateMirrorTabMenu(popup) { function populateMirrorTabMenu(popup) {
let videoEl = this.target;
popup.innerHTML = null; popup.innerHTML = null;
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
return;
}
let videoEl = this.target;
let doc = popup.ownerDocument; let doc = popup.ownerDocument;
let services = CastingApps.getServicesForMirroring(); let services = CastingApps.getServicesForMirroring();
services.forEach(service => { services.forEach(service => {

View File

@@ -105,6 +105,9 @@ addMessageListener("MixedContent:ReenableProtection", function() {
}); });
addMessageListener("SecondScreen:tab-mirror", function(message) { addMessageListener("SecondScreen:tab-mirror", function(message) {
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
return;
}
let app = SimpleServiceDiscovery.findAppForService(message.data.service); let app = SimpleServiceDiscovery.findAppForService(message.data.service);
if (app) { if (app) {
let width = content.innerWidth; let width = content.innerWidth;

View File

@@ -218,12 +218,13 @@ nsContextMenu.prototype = {
this.showItem("context-sendaudio", this.onAudio); this.showItem("context-sendaudio", this.onAudio);
this.setItemAttr("context-sendvideo", "disabled", !this.mediaURL); this.setItemAttr("context-sendvideo", "disabled", !this.mediaURL);
this.setItemAttr("context-sendaudio", "disabled", !this.mediaURL); this.setItemAttr("context-sendaudio", "disabled", !this.mediaURL);
let shouldShowCast = Services.prefs.getBoolPref("browser.casting.enabled");
// getServicesForVideo alone would be sufficient here (it depends on // getServicesForVideo alone would be sufficient here (it depends on
// SimpleServiceDiscovery.services), but SimpleServiceDiscovery is garanteed // SimpleServiceDiscovery.services), but SimpleServiceDiscovery is guaranteed
// to be already loaded, since we load it on startup, and CastingApps isn't, // to be already loaded, since we load it on startup in nsBrowserGlue,
// so check SimpleServiceDiscovery.services first to avoid needing to load // and CastingApps isn't, so check SimpleServiceDiscovery.services first
// CastingApps.jsm if we don't need to. // to avoid needing to load CastingApps.jsm if we don't need to.
let shouldShowCast = this.mediaURL && shouldShowCast = shouldShowCast && this.mediaURL &&
SimpleServiceDiscovery.services.length > 0 && SimpleServiceDiscovery.services.length > 0 &&
CastingApps.getServicesForVideo(this.target).length > 0; CastingApps.getServicesForVideo(this.target).length > 0;
this.setItemAttr("context-castvideo", "disabled", !shouldShowCast); this.setItemAttr("context-castvideo", "disabled", !shouldShowCast);

View File

@@ -987,6 +987,9 @@ BrowserGlue.prototype = {
}, },
_initServiceDiscovery: function () { _initServiceDiscovery: function () {
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
return;
}
var rokuDevice = { var rokuDevice = {
id: "roku:ecp", id: "roku:ecp",
target: "roku:ecp", target: "roku:ecp",