From d5ab36e57763c743ac6c5cbb728656a5e95352be Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Thu, 14 May 2020 14:44:11 -0400 Subject: [PATCH] try revert getAppPath --- src/browser/browserApi.ts | 10 ++++++++++ src/safari/safari/SafariExtensionViewController.swift | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/browser/browserApi.ts b/src/browser/browserApi.ts index a536f7a694..ede5779c16 100644 --- a/src/browser/browserApi.ts +++ b/src/browser/browserApi.ts @@ -133,6 +133,16 @@ export class BrowserApi { } } + static getAssetUrl(path: string): Promise { + if (BrowserApi.isChromeApi) { + return Promise.resolve(chrome.extension.getURL(path)); + } else if (BrowserApi.isSafariApi) { + return SafariApp.sendMessageToApp('getAppPath'); + } else { + return Promise.resolve(null); + } + } + static messageListener(name: string, callback: (message: any, sender: any, response: any) => void) { if (BrowserApi.isChromeApi) { chrome.runtime.onMessage.addListener((msg: any, sender: any, response: any) => { diff --git a/src/safari/safari/SafariExtensionViewController.swift b/src/safari/safari/SafariExtensionViewController.swift index 41aab17003..dba308c947 100644 --- a/src/safari/safari/SafariExtensionViewController.swift +++ b/src/safari/safari/SafariExtensionViewController.swift @@ -205,6 +205,13 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe } } } + } else if command == "getAppPath" { + SFSafariExtension.getBaseURI(completionHandler: { uri in + if uri != nil { + m!.responseData = uri!.absoluteString + self.replyMessage(message: m!) + } + }) } }