summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-09 21:58:32 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-13 23:11:56 -0500
commit2fef2bf5a87d142310ca79a75894098984ab1ffa (patch)
tree8e177a0cfd334ea1285dc7ce313ba92569efa431 /ext
parentf78671346696ddac23e9f858f567e5db065effec (diff)
Move apiGetEnvironmentInfo implementation into Backend
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/api.js30
-rw-r--r--ext/bg/js/backend.js30
2 files changed, 30 insertions, 30 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 82166007..49a6c14f 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -89,34 +89,8 @@ function apiInjectStylesheet(css, sender) {
return utilBackend()._onApiInjectStylesheet({css}, sender);
}
-async function apiGetEnvironmentInfo() {
- const browser = await _apiGetBrowser();
- const platform = await new Promise((resolve) => chrome.runtime.getPlatformInfo(resolve));
- return {
- browser,
- platform: {
- os: platform.os
- }
- };
-}
-
-async function _apiGetBrowser() {
- if (EXTENSION_IS_BROWSER_EDGE) {
- return 'edge';
- }
- if (typeof browser !== 'undefined') {
- try {
- const info = await browser.runtime.getBrowserInfo();
- if (info.name === 'Fennec') {
- return 'firefox-mobile';
- }
- } catch (e) {
- // NOP
- }
- return 'firefox';
- } else {
- return 'chrome';
- }
+function apiGetEnvironmentInfo() {
+ return utilBackend()._onApiGetEnvironmentInfo();
}
async function apiClipboardGet() {
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index df021ea2..62c077a2 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -464,8 +464,15 @@ class Backend {
});
}
- _onApiGetEnvironmentInfo() {
- return apiGetEnvironmentInfo();
+ async _onApiGetEnvironmentInfo() {
+ const browser = await Backend._getBrowser();
+ const platform = await new Promise((resolve) => chrome.runtime.getPlatformInfo(resolve));
+ return {
+ browser,
+ platform: {
+ os: platform.os
+ }
+ };
}
_onApiClipboardGet() {
@@ -638,6 +645,25 @@ class Backend {
// Edge throws exception for no reason here.
}
}
+
+ static async _getBrowser() {
+ if (EXTENSION_IS_BROWSER_EDGE) {
+ return 'edge';
+ }
+ if (typeof browser !== 'undefined') {
+ try {
+ const info = await browser.runtime.getBrowserInfo();
+ if (info.name === 'Fennec') {
+ return 'firefox-mobile';
+ }
+ } catch (e) {
+ // NOP
+ }
+ return 'firefox';
+ } else {
+ return 'chrome';
+ }
+ }
}
Backend._messageHandlers = new Map([