2020-02-25 12:41:13 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-01-29 12:30:17 +00:00
|
|
|
import Platform from '../react/Platform';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the current environment is a mobile device.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isMobileBrowser() {
|
|
|
|
return Platform.OS === 'android' || Platform.OS === 'ios';
|
|
|
|
}
|
2020-02-25 12:41:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the chrome extensions defined in the config file are installed or not.
|
|
|
|
*
|
|
|
|
* @param {Object} config - Objects containing info about the configured extensions.
|
|
|
|
*
|
|
|
|
* @returns {Promise[]}
|
|
|
|
*/
|
|
|
|
export function checkChromeExtensionsInstalled(config: Object = {}) {
|
|
|
|
const isExtensionInstalled = info => new Promise(resolve => {
|
|
|
|
const img = new Image();
|
|
|
|
|
|
|
|
img.src = `chrome-extension://${info.id}/${info.path}`;
|
|
|
|
img.onload = function() {
|
|
|
|
resolve(true);
|
|
|
|
};
|
|
|
|
img.onerror = function() {
|
|
|
|
resolve(false);
|
|
|
|
};
|
|
|
|
});
|
|
|
|
const extensionInstalledFunction = info => isExtensionInstalled(info);
|
|
|
|
|
|
|
|
return Promise.all(
|
|
|
|
(config.chromeExtensionsInfo || []).map(info => extensionInstalledFunction(info))
|
|
|
|
);
|
|
|
|
}
|