aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2020-10-16 21:56:49 -0700
committerOmar Rizwan <omar.rizwan@gmail.com>2020-10-16 21:56:49 -0700
commit74b1b0f789ea4e310a138c4b6d476a78d49cf557 (patch)
tree268d1a06984d0430d987ac0f350e3e2d6e3f7629 /extension
parent53de6736feb5ab5d5a3039190ea770bfddc67ccf (diff)
Starting to move to native messaging.
Why? The WebSocket stuff is broken right now, and I want to get rid of the dep...
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js18
-rw-r--r--extension/manifest.json8
2 files changed, 18 insertions, 8 deletions
diff --git a/extension/background.js b/extension/background.js
index b204876..a53dae0 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -289,9 +289,9 @@ async function releasedir(path) {
if (route.releasedir) return route.releasedir(path);
}
-let ws;
-async function onmessage(event) {
- const req = JSON.parse(event.data);
+let port;
+/* let ws;*/
+async function onMessage(req) {
console.log('req', req);
let response = { op: req.op, error: unix.EIO };
@@ -371,14 +371,18 @@ async function onmessage(event) {
};
function tryConnect() {
- ws = new WebSocket("ws://localhost:8888");
+ port = chrome.runtime.connectNative('com.rsnous.TabFS');
updateToolbarIcon();
- ws.onopen = ws.onclose = updateToolbarIcon;
- ws.onmessage = onmessage;
+ port.onMessage.addListener(onMessage);
+
+ /* ws = new WebSocket("ws://localhost:8888");
+ * updateToolbarIcon();
+ * ws.onopen = ws.onclose = updateToolbarIcon;
+ * ws.onmessage = onmessage;*/
}
function updateToolbarIcon() {
- if (ws && ws.readyState == 1) { // OPEN
+ if (port && port.onMessage) { // OPEN
chrome.browserAction.setBadgeBackgroundColor({color: 'blue'});
chrome.browserAction.setBadgeText({text: 'f'});
} else {
diff --git a/extension/manifest.json b/extension/manifest.json
index ac424f1..7900406 100644
--- a/extension/manifest.json
+++ b/extension/manifest.json
@@ -5,12 +5,18 @@
"description": "Connects to TabFS filesystem",
"version": "1.0",
- "permissions": ["tabs", "debugger"],
+ "permissions": ["tabs", "debugger", "nativeMessaging"],
"browser_action": {},
"background": {
"scripts": ["background.js"],
"persistent": true
+ },
+
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "tabfs@rsnous.com"
+ }
}
}