Browse Source

Add new firefoxextension api to screensharing service.

pull/238/head
Evan Theurer 11 years ago
parent
commit
9289ad558f
  1. 49
      static/js/services/screensharing.js

49
static/js/services/screensharing.js

@ -33,7 +33,7 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter'
}]; }];
// screensharing // 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); $templateCache.put('/dialogs/screensharedialogff.html', screenshareDialogFF);
@ -43,6 +43,9 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter'
chromeExtension.e.on("available", _.bind(function() { chromeExtension.e.on("available", _.bind(function() {
this.initialize(); this.initialize();
}, this)); }, this));
firefoxExtension.e.on("available", _.bind(function() {
this.initialize();
}, this));
}; };
Screensharing.prototype.initialize = function() { Screensharing.prototype.initialize = function() {
@ -137,7 +140,7 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter'
// Firefox 36 got screen sharing support. // Firefox 36 got screen sharing support.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=923225 // See https://bugzilla.mozilla.org/show_bug.cgi?id=923225
if ($window.webrtcDetectedVersion >= 36) { if ($window.webrtcDetectedVersion >= 36 && firefoxExtension.available) {
this.supported = true; this.supported = true;
this.prepare = function(options) { this.prepare = function(options) {
// To work, the current domain must be whitelisted in // 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. // No support for screen sharing.
} }
var that = null;
var waiting = null;
var prepareAlternative = null;
// Auto install support. // Auto install support.
if (!this.supported && chromeExtension.autoinstall.install) { if (!this.supported && chromeExtension.autoinstall.install) {
this.supported = this.autoinstall = true; this.supported = this.autoinstall = true;
var that = this; that = this;
var waiting = false; waiting = false;
var prepareAlternative = this.prepare; prepareAlternative = this.prepare;
this.prepare = function(options) { this.prepare = function(options) {
var d = $q.defer(); var d = $q.defer();
var install = chromeExtension.autoinstall.install(); var install = chromeExtension.autoinstall.install();
@ -230,6 +237,38 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter'
} }
waiting = false; 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 { } else {
this.autoinstall = false; this.autoinstall = false;
} }

Loading…
Cancel
Save