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

@@ -218,14 +218,15 @@ nsContextMenu.prototype = {
this.showItem("context-sendaudio", this.onAudio);
this.setItemAttr("context-sendvideo", "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
// SimpleServiceDiscovery.services), but SimpleServiceDiscovery is garanteed
// to be already loaded, since we load it on startup, and CastingApps isn't,
// so check SimpleServiceDiscovery.services first to avoid needing to load
// CastingApps.jsm if we don't need to.
let shouldShowCast = this.mediaURL &&
SimpleServiceDiscovery.services.length > 0 &&
CastingApps.getServicesForVideo(this.target).length > 0;
// SimpleServiceDiscovery.services), but SimpleServiceDiscovery is guaranteed
// to be already loaded, since we load it on startup in nsBrowserGlue,
// and CastingApps isn't, so check SimpleServiceDiscovery.services first
// to avoid needing to load CastingApps.jsm if we don't need to.
shouldShowCast = shouldShowCast && this.mediaURL &&
SimpleServiceDiscovery.services.length > 0 &&
CastingApps.getServicesForVideo(this.target).length > 0;
this.setItemAttr("context-castvideo", "disabled", !shouldShowCast);
},