diff --git a/static/js/services/screensharing.js b/static/js/services/screensharing.js index 2cc5c54f..96b3d1e7 100644 --- a/static/js/services/screensharing.js +++ b/static/js/services/screensharing.js @@ -33,7 +33,7 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' }]; // screensharing - return ["$window", "$q", "$timeout", "chromeExtension", "dialogs", "$templateCache", function($window, $q, $timeout, chromeExtension, dialogs, $templateCache) { + return ["$window", "$q", "$timeout", "chromeExtension", "firefoxExtension", "dialogs", "$templateCache", function($window, $q, $timeout, chromeExtension, firefoxExtension, dialogs, $templateCache) { $templateCache.put('/dialogs/screensharedialogff.html', screenshareDialogFF); @@ -43,6 +43,9 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' chromeExtension.e.on("available", _.bind(function() { this.initialize(); }, this)); + firefoxExtension.e.on("available", _.bind(function() { + this.initialize(); + }, this)); }; Screensharing.prototype.initialize = function() { @@ -137,7 +140,7 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' // Firefox 36 got screen sharing support. // See https://bugzilla.mozilla.org/show_bug.cgi?id=923225 - if ($window.webrtcDetectedVersion >= 36) { + if ($window.webrtcDetectedVersion >= 36 && firefoxExtension.available) { this.supported = true; this.prepare = function(options) { // To work, the current domain must be whitelisted in @@ -165,12 +168,16 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' // No support for screen sharing. } + var that = null; + var waiting = null; + var prepareAlternative = null; + // Auto install support. if (!this.supported && chromeExtension.autoinstall.install) { this.supported = this.autoinstall = true; - var that = this; - var waiting = false; - var prepareAlternative = this.prepare; + that = this; + waiting = false; + prepareAlternative = this.prepare; this.prepare = function(options) { var d = $q.defer(); var install = chromeExtension.autoinstall.install(); @@ -230,6 +237,38 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' } waiting = false; }; + } else if (!this.supported && firefoxExtension.autoinstall.install) { + this.supported = this.autoinstall = true; + that = this; + waiting = false; + prepareAlternative = this.prepare; + this.prepare = function(options) { + var d = $q.defer(); + var install = firefoxExtension.autoinstall.install(); + install.then(function() { + // Do install of firefox extension + console.log('installing extension'); + }, function(err) { + console.log("Auto install of extension failed.", err); + if (prepareAlternative) { + var alternative = prepareAlternative(options); + alternative.then(function(id) { + d.resolve(id); + }, function() { + d.reject(err); + }); + } else { + d.reject(err); + } + }); + return d.promise; + }; + this.cancel = function() { + if (firefoxExtension.autoinstall.cancel) { + firefoxExtension.autoinstall.cancel(); + } + waiting = false; + }; } else { this.autoinstall = false; }