소스 검색

Configurable (sub)optimal and unsupported browsers (#4351)

* Configurable (sub)optimal and unsupported browsers

* maybe this helps somehow
j8
virtuacoplenny 6 년 전
부모
커밋
bf67a4a675

+ 11
- 1
interface_config.js 파일 보기

@@ -167,7 +167,17 @@ var interfaceConfig = {
167 167
      *
168 168
      * @type {boolean}
169 169
      */
170
-    RECENT_LIST_ENABLED: true
170
+    RECENT_LIST_ENABLED: true,
171
+
172
+    // Names of browsers which should show a warning stating the current browser
173
+    // has a suboptimal experience. Browsers which are not listed as optimal or
174
+    // unsupported are considered suboptimal. Valid values are:
175
+    // chrome, edge, electron, firefox, nwjs, opera, safari
176
+    OPTIMAL_BROWSERS: [ 'chrome', 'firefox', 'nwjs', 'electron' ],
177
+
178
+    // Browsers, in addition to those which do not fully support WebRTC, that
179
+    // are not supported and should show the unsupported browser page.
180
+    UNSUPPORTED_BROWSERS: []
171 181
 
172 182
     /**
173 183
      * How many columns the tile view can expand to. The respected range is

+ 78
- 2
react/features/base/environment/environment.js 파일 보기

@@ -3,15 +3,74 @@
3 3
 import JitsiMeetJS from '../lib-jitsi-meet';
4 4
 import { Platform } from '../react';
5 5
 
6
-import { isBlacklistedEnvironment } from './isBlacklistedEnvironment';
6
+const { browser } = JitsiMeetJS.util;
7
+
8
+const DEFAULT_OPTIMAL_BROWSERS = [
9
+    'chrome',
10
+    'electron',
11
+    'firefox',
12
+    'nwjs'
13
+];
14
+
15
+const DEFAULT_UNSUPPORTED_BROWSERS = [];
16
+
17
+const browserNameToCheck = {
18
+    chrome: browser.isChrome.bind(browser),
19
+    edge: browser.isEdge.bind(browser),
20
+    electron: browser.isElectron.bind(browser),
21
+    firefox: browser.isFirefox.bind(browser),
22
+    nwjs: browser.isNWJS.bind(browser),
23
+    opera: browser.isOpera.bind(browser),
24
+    safari: browser.isSafari.bind(browser)
25
+};
26
+
27
+declare var interfaceConfig: Object;
28
+
29
+/**
30
+ * Returns whether or not jitsi is optimized and targeted for the  provided
31
+ * browser name.
32
+ *
33
+ * @param {string} browserName - The name of the browser to check.
34
+ * @returns {boolean}
35
+ */
36
+export function isBrowsersOptimal(browserName: string) {
37
+    return (interfaceConfig.OPTIMAL_BROWSERS || DEFAULT_OPTIMAL_BROWSERS)
38
+        .includes(browserName);
39
+}
40
+
41
+/**
42
+ * Returns whether or not the current browser or the list of passed in browsers
43
+ * is considered suboptimal. Suboptimal means it is a supported browser but has
44
+ * not been explicitly listed as being optimal, possibly due to functionality
45
+ * issues.
46
+ *
47
+ * @param {Array<string>} [browsers] - A list of browser names to check. Will
48
+ * default to a whitelist.
49
+ * @returns {boolean}
50
+ */
51
+export function isSuboptimalBrowser() {
52
+    const optimalBrowsers
53
+        = interfaceConfig.OPTIMAL_BROWSERS || DEFAULT_OPTIMAL_BROWSERS;
54
+
55
+    return !_isCurrentBrowserInList(optimalBrowsers) && isSupportedBrowser();
56
+}
7 57
 
8 58
 /**
9 59
  * Returns whether or not the current browser should allow the app to display.
60
+ * A supported browser is assumed to be able to support WebRtc.
10 61
  *
11 62
  * @returns {boolean}
12 63
  */
13 64
 export function isSupportedBrowser() {
14
-    if (navigator.product === 'ReactNative' || isBlacklistedEnvironment()) {
65
+    if (navigator.product === 'ReactNative') {
66
+        return false;
67
+    }
68
+
69
+    const isBlacklistedBrowser = _isCurrentBrowserInList(
70
+        interfaceConfig.UNSUPPORTED_BROWSERS || DEFAULT_UNSUPPORTED_BROWSERS
71
+    );
72
+
73
+    if (isBlacklistedBrowser) {
15 74
         return false;
16 75
     }
17 76
 
@@ -23,3 +82,20 @@ export function isSupportedBrowser() {
23 82
         || Platform.OS === 'ios'
24 83
         || JitsiMeetJS.isWebRtcSupported();
25 84
 }
85
+
86
+/**
87
+ * Runs various browser checks to know if the current browser is found within
88
+ * the list.
89
+ *
90
+ * @param {Array<string>} list - Browser names to check. The names should be
91
+ * keys in {@link browserNameToCheck}.
92
+ * @private
93
+ * @returns {boolean}
94
+ */
95
+function _isCurrentBrowserInList(list) {
96
+    return Boolean(list.find(browserName => {
97
+        const checkFunction = browserNameToCheck[browserName];
98
+
99
+        return checkFunction ? checkFunction.call(browser) : false;
100
+    }));
101
+}

+ 0
- 11
react/features/base/environment/isBlacklistedEnvironment.js 파일 보기

@@ -1,11 +0,0 @@
1
-/**
2
- * Returns whether or not the current browser is supported for showing meeting
3
- * based on any custom overrides. This file should be overridden with branding
4
- * as needed to fit deployment needs.
5
- *
6
- * @returns {boolean} True the browser is unsupported due to being  blacklisted
7
- * by the logic within this function.
8
- */
9
-export function isBlacklistedEnvironment() {
10
-    return false;
11
-}

+ 2
- 11
react/features/conference/functions.js 파일 보기

@@ -1,5 +1,5 @@
1 1
 import { translateToHTML } from '../base/i18n';
2
-import { browser } from '../base/lib-jitsi-meet';
2
+import { isSuboptimalBrowser } from '../base/environment';
3 3
 import { toState } from '../base/redux';
4 4
 
5 5
 import { getName } from '../app';
@@ -17,16 +17,7 @@ import { getOverlayToRender } from '../overlay';
17 17
  * @returns {void}
18 18
  */
19 19
 export function maybeShowSuboptimalExperienceNotification(dispatch, t) {
20
-    if (!browser.isChrome()
21
-            && !browser.isFirefox()
22
-            && !browser.isNWJS()
23
-            && !browser.isElectron()
24
-
25
-            // Adding react native to the list of recommended browsers is not
26
-            // necessary for now because the function won't be executed at all
27
-            // in this case but I'm adding it for completeness.
28
-            && !browser.isReactNative()
29
-    ) {
20
+    if (isSuboptimalBrowser()) {
30 21
         dispatch(
31 22
             showWarningNotification(
32 23
                 {

+ 17
- 4
react/features/unsupported-browser/components/UnsupportedDesktopBrowser.js 파일 보기

@@ -2,6 +2,7 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 
5
+import { isBrowsersOptimal } from '../../base/environment';
5 6
 import { translate } from '../../base/i18n';
6 7
 
7 8
 import { CHROME, FIREFOX } from './browserLinks';
@@ -47,14 +48,26 @@ class UnsupportedDesktopBrowser extends Component<Props> {
47 48
                     Please try again with the latest version of&nbsp;
48 49
                     <a
49 50
                         className = { `${_SNS}__link` }
50
-                        href = { CHROME } >Chrome</a> and&nbsp;
51
-                    <a
52
-                        className = { `${_SNS}__link` }
53
-                        href = { FIREFOX }>Firefox</a>
51
+                        href = { CHROME } >Chrome</a>&nbsp;
52
+                    {
53
+                        this._showFirefox() && <>and <a
54
+                            className = { `${_SNS}__link` }
55
+                            href = { FIREFOX }>Firefox</a></>
56
+                    }
54 57
                 </p>
55 58
             </div>
56 59
         );
57 60
     }
61
+
62
+    /**
63
+     * Returns whether or not a link to download Firefox is displayed.
64
+     *
65
+     * @private
66
+     * @returns {boolean}
67
+     */
68
+    _showFirefox() {
69
+        return isBrowsersOptimal('firefox');
70
+    }
58 71
 }
59 72
 
60 73
 export default translate(UnsupportedDesktopBrowser);

Loading…
취소
저장