1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-02 08:40:08 +01:00

load bitwardenApplicationVersion for safari app

This commit is contained in:
Kyle Spearrin 2019-08-20 15:34:34 -04:00
parent 78343d3e60
commit d139f9a366
3 changed files with 34 additions and 23 deletions

View File

@ -161,8 +161,7 @@ export class BrowserApi {
if (BrowserApi.isChromeApi) {
return chrome.runtime.getManifest().version;
} else if (BrowserApi.isSafariApi) {
// TODO
return null;
return (window as any).bitwardenApplicationVersion;
} else {
return null;
}

View File

@ -68,7 +68,10 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
}
let command = m!.command
// print(command)
if command == "storage_get" {
if command == "windowLoaded" {
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
webView.evaluateJavaScript("window.bitwardenApplicationVersion = '\(version)';", completionHandler: nil)
} else if command == "storage_get" {
let obj = UserDefaults.standard.string(forKey: m!.data!)
m!.responseData = obj
replyMessage(message: m!)

View File

@ -1,23 +1,32 @@
<!DOCTYPE html>
<html class="browser_safari">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bitwarden</title>
<base href="">
<link href="main.css" rel="stylesheet">
</head>
<body>
<app-root>
<div id="loading"><i class="fa fa-spinner fa-spin fa-3x"></i></div>
</app-root>
<script type="text/javascript">
window.safariAppExtension = true;
window.bitwardenLocaleStrings = null;
</script>
<script type="text/javascript" src="../vendor.js"></script>
<script type="text/javascript" src="../background.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bitwarden</title>
<base href="">
<link href="main.css" rel="stylesheet">
</head>
<body>
<app-root>
<div id="loading"><i class="fa fa-spinner fa-spin fa-3x"></i></div>
</app-root>
<script type="text/javascript">
window.safariAppExtension = true;
window.bitwardenLocaleStrings = null;
window.bitwardenApplicationVersion = null;
document.addEventListener('DOMContentLoaded', (event) => {
window.webkit.messageHandlers.bitwardenApp.postMessage(JSON.stringify({
command: 'windowLoaded'
}));
});
</script>
<script type="text/javascript" src="../vendor.js"></script>
<script type="text/javascript" src="../background.js"></script>
<script type="text/javascript" src="vendor.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>