浏览代码

feat(ScreenObtainer): CHROME_EXTENSION_USER_GESTURE_REQUIRED

CHROME_EXTENSION_USER_GESTURE_REQUIRED will be triggered if
the extension installation fails, because the request to get desktop
stream did not originate in user gesture handler (a button click for
example).
master
paweldomas 7 年前
父节点
当前提交
5dd206721e
共有 3 个文件被更改,包括 29 次插入3 次删除
  1. 4
    0
      JitsiTrackError.js
  2. 10
    0
      JitsiTrackErrors.js
  3. 15
    3
      modules/RTC/ScreenObtainer.js

+ 4
- 0
JitsiTrackError.js 查看文件

@@ -8,6 +8,10 @@ TRACK_ERROR_TO_MESSAGE_MAP[JitsiTrackErrors.FIREFOX_EXTENSION_NEEDED]
8 8
     = 'Firefox extension is not installed';
9 9
 TRACK_ERROR_TO_MESSAGE_MAP[JitsiTrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR]
10 10
     = 'Failed to install Chrome extension';
11
+TRACK_ERROR_TO_MESSAGE_MAP[
12
+    JitsiTrackErrors.CHROME_EXTENSION_USER_GESTURE_REQUIRED]
13
+    = 'Failed to install Chrome extension - installations can only be initiated'
14
+        + ' by a user gesture.';
11 15
 TRACK_ERROR_TO_MESSAGE_MAP[JitsiTrackErrors.CHROME_EXTENSION_USER_CANCELED]
12 16
     = 'User canceled Chrome\'s screen sharing prompt';
13 17
 TRACK_ERROR_TO_MESSAGE_MAP[JitsiTrackErrors.CHROME_EXTENSION_GENERIC_ERROR]

+ 10
- 0
JitsiTrackErrors.js 查看文件

@@ -15,6 +15,16 @@ export const CHROME_EXTENSION_GENERIC_ERROR
15 15
 export const CHROME_EXTENSION_INSTALLATION_ERROR
16 16
     = 'gum.chrome_extension_installation_error';
17 17
 
18
+/**
19
+ * This error indicates that the attempt to start screensharing was initiated by
20
+ * a script which did not originate in user gesture handler. It means that
21
+ * you should to trigger the action again in response to a button click for
22
+ * example.
23
+ * @type {string}
24
+ */
25
+export const CHROME_EXTENSION_USER_GESTURE_REQUIRED
26
+    = 'gum.chrome_extension_user_gesture_required';
27
+
18 28
 /**
19 29
  * An error which indicates that user canceled screen sharing window
20 30
  * selection dialog in jidesha extension for Chrome.

+ 15
- 3
modules/RTC/ScreenObtainer.js 查看文件

@@ -56,6 +56,14 @@ const CHROME_EXTENSION_IFRAME_ERROR
56 56
 const CHROME_NO_EXTENSION_ERROR_MSG // eslint-disable-line no-unused-vars
57 57
     = 'Could not establish connection. Receiving end does not exist.';
58 58
 
59
+/**
60
+ * The error message returned by chrome when the extension install action needs
61
+ * to be initiated by a user gesture.
62
+ * @type {string}
63
+ */
64
+const CHROME_USER_GESTURE_REQ_ERROR
65
+    = 'Chrome Web Store installations can only be initated by a user gesture.';
66
+
59 67
 /**
60 68
  * Handles obtaining a stream from a screen capture on different browsers.
61 69
  */
@@ -394,9 +402,13 @@ const ScreenObtainer = {
394 402
             = `Failed to install the extension from ${webStoreInstallUrl}`;
395 403
 
396 404
         logger.log(msg, e);
397
-        failCallback(new JitsiTrackError(
398
-            JitsiTrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR,
399
-            msg));
405
+
406
+        const error
407
+            = e === CHROME_USER_GESTURE_REQ_ERROR
408
+                ? JitsiTrackErrors.CHROME_EXTENSION_USER_GESTURE_REQUIRED
409
+                : JitsiTrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR;
410
+
411
+        failCallback(new JitsiTrackError(error, msg));
400 412
     },
401 413
 
402 414
     /* eslint-enable max-params */

正在加载...
取消
保存