|
@@ -20,20 +20,6 @@ let chromeExtInstalled = false;
|
20
|
20
|
*/
|
21
|
21
|
let chromeExtUpdateRequired = false;
|
22
|
22
|
|
23
|
|
-/**
|
24
|
|
- * Whether the jidesha extension for firefox is installed for the domain on
|
25
|
|
- * which we are running. Null designates an unknown value.
|
26
|
|
- * @type {null}
|
27
|
|
- */
|
28
|
|
-let firefoxExtInstalled = null;
|
29
|
|
-
|
30
|
|
-/**
|
31
|
|
- * If set to true, detection of an installed firefox extension will be started
|
32
|
|
- * again the next time obtainScreenOnFirefox is called (e.g. next time the
|
33
|
|
- * user tries to enable screen sharing).
|
34
|
|
- */
|
35
|
|
-let reDetectFirefoxExtension = false;
|
36
|
|
-
|
37
|
23
|
let gumFunction = null;
|
38
|
24
|
|
39
|
25
|
/**
|
|
@@ -106,15 +92,13 @@ const ScreenObtainer = {
|
106
|
92
|
* @param {boolean} [options.desktopSharingChromeDisabled]
|
107
|
93
|
* @param {boolean} [options.desktopSharingChromeExtId]
|
108
|
94
|
* @param {boolean} [options.desktopSharingFirefoxDisabled]
|
109
|
|
- * @param {boolean} [options.desktopSharingFirefoxExtId] (deprecated)
|
110
|
95
|
* @param {Function} gum GUM method
|
111
|
96
|
*/
|
112
|
97
|
init(options = {
|
113
|
98
|
disableDesktopSharing: false,
|
114
|
99
|
desktopSharingChromeDisabled: false,
|
115
|
100
|
desktopSharingChromeExtId: null,
|
116
|
|
- desktopSharingFirefoxDisabled: false,
|
117
|
|
- desktopSharingFirefoxExtId: null
|
|
101
|
+ desktopSharingFirefoxDisabled: false
|
118
|
102
|
}, gum) {
|
119
|
103
|
this.options = options;
|
120
|
104
|
gumFunction = gum;
|
|
@@ -227,8 +211,6 @@ const ScreenObtainer = {
|
227
|
211
|
return null;
|
228
|
212
|
}
|
229
|
213
|
|
230
|
|
- initFirefoxExtensionDetection(options);
|
231
|
|
-
|
232
|
214
|
return this.obtainScreenOnFirefox;
|
233
|
215
|
}
|
234
|
216
|
|
|
@@ -254,58 +236,7 @@ const ScreenObtainer = {
|
254
|
236
|
* @param errorCallback
|
255
|
237
|
*/
|
256
|
238
|
obtainScreenOnFirefox(options, callback, errorCallback) {
|
257
|
|
- let extensionRequired = false;
|
258
|
|
- const { desktopSharingFirefoxMaxVersionExtRequired } = this.options;
|
259
|
|
-
|
260
|
|
- if (desktopSharingFirefoxMaxVersionExtRequired === -1
|
261
|
|
- || (desktopSharingFirefoxMaxVersionExtRequired >= 0
|
262
|
|
- && !browser.isVersionGreaterThan(
|
263
|
|
- desktopSharingFirefoxMaxVersionExtRequired))) {
|
264
|
|
- extensionRequired = true;
|
265
|
|
- logger.log(
|
266
|
|
- `Jidesha extension required on firefox version ${
|
267
|
|
- browser.getVersion()}`);
|
268
|
|
- }
|
269
|
|
-
|
270
|
|
- if (!extensionRequired || firefoxExtInstalled === true) {
|
271
|
|
- obtainWebRTCScreen(options.gumOptions, callback, errorCallback);
|
272
|
|
-
|
273
|
|
- return;
|
274
|
|
- }
|
275
|
|
-
|
276
|
|
- if (reDetectFirefoxExtension) {
|
277
|
|
- reDetectFirefoxExtension = false;
|
278
|
|
- initFirefoxExtensionDetection(this.options);
|
279
|
|
- }
|
280
|
|
-
|
281
|
|
- // Give it some (more) time to initialize, and assume lack of
|
282
|
|
- // extension if it hasn't.
|
283
|
|
- if (firefoxExtInstalled === null) {
|
284
|
|
- window.setTimeout(
|
285
|
|
- () => {
|
286
|
|
- if (firefoxExtInstalled === null) {
|
287
|
|
- firefoxExtInstalled = false;
|
288
|
|
- }
|
289
|
|
- this.obtainScreenOnFirefox(
|
290
|
|
- options, callback, errorCallback);
|
291
|
|
- },
|
292
|
|
- 300);
|
293
|
|
- logger.log(
|
294
|
|
- 'Waiting for detection of jidesha on firefox to finish.');
|
295
|
|
-
|
296
|
|
- return;
|
297
|
|
- }
|
298
|
|
-
|
299
|
|
- // We need an extension and it isn't installed.
|
300
|
|
-
|
301
|
|
- // Make sure we check for the extension when the user clicks again.
|
302
|
|
- firefoxExtInstalled = null;
|
303
|
|
- reDetectFirefoxExtension = true;
|
304
|
|
-
|
305
|
|
- // Make sure desktopsharing knows that we failed, so that it doesn't get
|
306
|
|
- // stuck in 'switching' mode.
|
307
|
|
- errorCallback(
|
308
|
|
- new JitsiTrackError(JitsiTrackErrors.FIREFOX_EXTENSION_NEEDED));
|
|
239
|
+ obtainWebRTCScreen(options.gumOptions, callback, errorCallback);
|
309
|
240
|
},
|
310
|
241
|
|
311
|
242
|
/**
|
|
@@ -782,44 +713,4 @@ function onGetStreamResponse(
|
782
|
713
|
}
|
783
|
714
|
}
|
784
|
715
|
|
785
|
|
-/**
|
786
|
|
- * Starts the detection of an installed jidesha extension for firefox.
|
787
|
|
- * @param options supports "desktopSharingFirefoxDisabled",
|
788
|
|
- * "desktopSharingFirefoxExtId"
|
789
|
|
- */
|
790
|
|
-function initFirefoxExtensionDetection(options) {
|
791
|
|
- if (options.desktopSharingFirefoxDisabled) {
|
792
|
|
- return;
|
793
|
|
- }
|
794
|
|
- if (firefoxExtInstalled === false || firefoxExtInstalled === true) {
|
795
|
|
- return;
|
796
|
|
- }
|
797
|
|
- if (!options.desktopSharingFirefoxExtId) {
|
798
|
|
- firefoxExtInstalled = false;
|
799
|
|
-
|
800
|
|
- return;
|
801
|
|
- }
|
802
|
|
-
|
803
|
|
- const img = document.createElement('img');
|
804
|
|
-
|
805
|
|
- img.onload = () => {
|
806
|
|
- logger.log('Detected firefox screen sharing extension.');
|
807
|
|
- firefoxExtInstalled = true;
|
808
|
|
- };
|
809
|
|
- img.onerror = () => {
|
810
|
|
- logger.log('Detected lack of firefox screen sharing extension.');
|
811
|
|
- firefoxExtInstalled = false;
|
812
|
|
- };
|
813
|
|
-
|
814
|
|
- // The jidesha extension exposes an empty image file under the url:
|
815
|
|
- // "chrome://EXT_ID/content/DOMAIN.png"
|
816
|
|
- // Where EXT_ID is the ID of the extension with "@" replaced by ".", and
|
817
|
|
- // DOMAIN is a domain whitelisted by the extension.
|
818
|
|
- const extId = options.desktopSharingFirefoxExtId.replace('@', '.');
|
819
|
|
- const domain = document.location.hostname;
|
820
|
|
- const src = `chrome://${extId}/content/${domain}.png`;
|
821
|
|
-
|
822
|
|
- img.setAttribute('src', src);
|
823
|
|
-}
|
824
|
|
-
|
825
|
716
|
export default ScreenObtainer;
|