|
@@ -22,60 +22,12 @@ let chromeExtUpdateRequired = false;
|
22
|
22
|
|
23
|
23
|
let gumFunction = null;
|
24
|
24
|
|
25
|
|
-/**
|
26
|
|
- * The error returned by chrome when trying to start inline installation from
|
27
|
|
- * popup.
|
28
|
|
- */
|
29
|
|
-const CHROME_EXTENSION_POPUP_ERROR
|
30
|
|
- = 'Inline installs can not be initiated from pop-up windows.';
|
31
|
|
-
|
32
|
|
-/**
|
33
|
|
- * The error returned by chrome when trying to start inline installation from
|
34
|
|
- * iframe.
|
35
|
|
- */
|
36
|
|
-const CHROME_EXTENSION_IFRAME_ERROR
|
37
|
|
- = 'Chrome Web Store installations can only be started by the top frame.';
|
38
|
|
-
|
39
|
|
-/**
|
40
|
|
- * The error returned by chrome when trying to start inline installation
|
41
|
|
- * not from the "main" whitelisted site.
|
42
|
|
- * @type {string}
|
43
|
|
- */
|
44
|
|
-const CHROME_EXTENSION_INLINE_ERROR
|
45
|
|
- = 'Installs can only be initiated by one of'
|
46
|
|
- + ' the Chrome Web Store item\'s verified sites.';
|
47
|
|
-
|
48
|
|
-/**
|
49
|
|
- * The error returned by chrome when trying to start inline installation
|
50
|
|
- * with extension that doesn't support inline installation.
|
51
|
|
- *
|
52
|
|
- * @type {string}
|
53
|
|
- */
|
54
|
|
-const CHROME_EXTENSION_INLINE_NOT_SUPPORTED_ERROR
|
55
|
|
- = 'Inline installation is not supported for this item. '
|
56
|
|
- + 'The user will be redirected to the Chrome Web Store.';
|
57
|
|
-
|
58
|
25
|
/**
|
59
|
26
|
* The error message returned by chrome when the extension is installed.
|
60
|
27
|
*/
|
61
|
28
|
const CHROME_NO_EXTENSION_ERROR_MSG // eslint-disable-line no-unused-vars
|
62
|
29
|
= 'Could not establish connection. Receiving end does not exist.';
|
63
|
30
|
|
64
|
|
-/**
|
65
|
|
- * The error message returned by chrome when the extension install action needs
|
66
|
|
- * to be initiated by a user gesture.
|
67
|
|
- * @type {string}
|
68
|
|
- */
|
69
|
|
-const CHROME_USER_GESTURE_REQ_ERROR
|
70
|
|
- = 'Chrome Web Store installations can only be initated by a user gesture.';
|
71
|
|
-
|
72
|
|
-/**
|
73
|
|
- * The error message returned by chrome when the extension install has been
|
74
|
|
- * cancelled by the user.
|
75
|
|
- * @type {string}
|
76
|
|
- */
|
77
|
|
-const CHROME_USER_CANCEL_EXTENSION_INSTALL = 'User cancelled install';
|
78
|
|
-
|
79
|
31
|
/**
|
80
|
32
|
* Handles obtaining a stream from a screen capture on different browsers.
|
81
|
33
|
*/
|
|
@@ -308,45 +260,8 @@ const ScreenObtainer = {
|
308
|
260
|
/* eslint-enable no-alert */
|
309
|
261
|
}
|
310
|
262
|
|
311
|
|
- // for opera there is no inline install
|
312
|
|
- // extension "Download Chrome Extension" allows us to open
|
313
|
|
- // the chrome webstore and install from there and then activate our
|
314
|
|
- // extension
|
315
|
|
- if (browser.isOpera()) {
|
316
|
|
- this.handleExternalInstall(options, streamCallback,
|
317
|
|
- failCallback);
|
318
|
|
-
|
319
|
|
- return;
|
320
|
|
- }
|
321
|
|
-
|
322
|
|
- try {
|
323
|
|
- chrome.webstore.install(
|
324
|
|
- getWebStoreInstallUrl(this.options),
|
325
|
|
- arg => {
|
326
|
|
- logger.log('Extension installed successfully', arg);
|
327
|
|
- chromeExtInstalled = true;
|
328
|
|
-
|
329
|
|
- // We need to give a moment to the endpoint to become
|
330
|
|
- // available.
|
331
|
|
- waitForExtensionAfterInstall(this.options, 200, 10)
|
332
|
|
- .then(() => {
|
333
|
|
- doGetStreamFromExtension(
|
334
|
|
- doGetStreamFromExtensionOptions,
|
335
|
|
- streamCallback,
|
336
|
|
- failCallback);
|
337
|
|
- })
|
338
|
|
- .catch(() => {
|
339
|
|
- this.handleExtensionInstallationError(options,
|
340
|
|
- streamCallback, failCallback);
|
341
|
|
- });
|
342
|
|
- },
|
343
|
|
- this.handleExtensionInstallationError.bind(this,
|
344
|
|
- options, streamCallback, failCallback)
|
345
|
|
- );
|
346
|
|
- } catch (e) {
|
347
|
|
- this.handleExtensionInstallationError(options, streamCallback,
|
348
|
|
- failCallback, e);
|
349
|
|
- }
|
|
263
|
+ this.handleExternalInstall(options, streamCallback,
|
|
264
|
+ failCallback);
|
350
|
265
|
}
|
351
|
266
|
},
|
352
|
267
|
|
|
@@ -360,40 +275,6 @@ const ScreenObtainer = {
|
360
|
275
|
failCallback, e);
|
361
|
276
|
},
|
362
|
277
|
|
363
|
|
- handleExtensionInstallationError(options, streamCallback, failCallback, e) {
|
364
|
|
- const webStoreInstallUrl = getWebStoreInstallUrl(this.options);
|
365
|
|
-
|
366
|
|
- if ((CHROME_EXTENSION_POPUP_ERROR === e
|
367
|
|
- || CHROME_EXTENSION_IFRAME_ERROR === e
|
368
|
|
- || CHROME_EXTENSION_INLINE_ERROR === e
|
369
|
|
- || CHROME_EXTENSION_INLINE_NOT_SUPPORTED_ERROR === e)
|
370
|
|
- && options.interval > 0
|
371
|
|
- && typeof options.checkAgain === 'function'
|
372
|
|
- && typeof options.listener === 'function') {
|
373
|
|
- this.handleExternalInstall(options, streamCallback,
|
374
|
|
- failCallback, e);
|
375
|
|
-
|
376
|
|
- return;
|
377
|
|
- }
|
378
|
|
-
|
379
|
|
- const msg
|
380
|
|
- = `Failed to install the extension from ${webStoreInstallUrl}`;
|
381
|
|
-
|
382
|
|
- logger.log(msg, e);
|
383
|
|
-
|
384
|
|
- let error;
|
385
|
|
-
|
386
|
|
- if (e === CHROME_USER_CANCEL_EXTENSION_INSTALL) {
|
387
|
|
- error = JitsiTrackErrors.CHROME_EXTENSION_USER_CANCELED;
|
388
|
|
- } else if (e === CHROME_USER_GESTURE_REQ_ERROR) {
|
389
|
|
- error = JitsiTrackErrors.CHROME_EXTENSION_USER_GESTURE_REQUIRED;
|
390
|
|
- } else {
|
391
|
|
- error = JitsiTrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR;
|
392
|
|
- }
|
393
|
|
-
|
394
|
|
- failCallback(new JitsiTrackError(error, msg));
|
395
|
|
- },
|
396
|
|
-
|
397
|
278
|
/* eslint-enable max-params */
|
398
|
279
|
|
399
|
280
|
checkForChromeExtensionOnInterval(options, streamCallback, failCallback) {
|