diff options
author | Omar Rizwan <omar@omar.website> | 2021-02-02 23:07:24 -0800 |
---|---|---|
committer | Omar Rizwan <omar@omar.website> | 2021-02-02 23:07:24 -0800 |
commit | a465ad6a8fbb64184dcdcfa451dbb2aa9346ac2d (patch) | |
tree | bc358f2f67341695a09516ca1f1b1c7296c34224 /extension/background.js | |
parent | f5b00deb7e5aac26049a24ad61a789a252920f8e (diff) | |
download | TabFS-a465ad6a8fbb64184dcdcfa451dbb2aa9346ac2d.tar.gz TabFS-a465ad6a8fbb64184dcdcfa451dbb2aa9346ac2d.zip |
safari: checkpoint as I try to get the terrible wiring right
Diffstat (limited to 'extension/background.js')
-rw-r--r-- | extension/background.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/extension/background.js b/extension/background.js index 5e487cf..e6fba2b 100644 --- a/extension/background.js +++ b/extension/background.js @@ -673,6 +673,10 @@ function findRoute(path) { let port; async function onMessage(req) { + // Safari / Safari extension app API forces you to adopt their + // {name, userInfo} structure for the request. + if (req.name === 'ToSafari') req = req.userInfo; + if (req.buf) req.buf = atob(req.buf); console.log('req', req); @@ -712,6 +716,16 @@ function tryConnect() { port = chrome.runtime.connectNative('com.rsnous.tabfs'); port.onMessage.addListener(onMessage); port.onDisconnect.addListener(p => {console.log('disconnect', p)}); + + // Safari is very weird -- it has this native app that we have to talk to, + // so we poke that app to wake it up, get it to start the TabFS process, + // and get it to start calling us whenever TabFS wants to do an FS call. + // Is there a better way to do this? + if (chrome.runtime.getURL('/').startsWith('safari-web-extension://')) { // Safari-only + chrome.runtime.sendNativeMessage('com.rsnous.tabfs', {op: 'safari_did_connect'}, function(resp) { + console.log(resp); + }); + } } if (!TESTING) { |