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

fix edge support

This commit is contained in:
Kyle Spearrin 2018-01-15 11:04:28 -05:00
parent 6ab4641812
commit fa9bfa915d
3 changed files with 29 additions and 27 deletions

View File

@ -199,11 +199,11 @@ class BrowserApi {
}
static downloadFile(win: Window, blobData: any, blobOptions: any, fileName: string) {
if (win.navigator.msSaveOrOpenBlob || BrowserApi.isSafariApi) {
if (BrowserApi.isSafariApi) {
const tab = BrowserApi.createNewTab(BrowserApi.getAssetUrl('downloader/index.html'));
const madeTab = BrowserApi.makeTabObject(tab);
setTimeout(() => {
BrowserApi.tabSendMessage(madeTab, {
const tabToSend = BrowserApi.makeTabObject(tab);
setTimeout(async () => {
BrowserApi.tabSendMessage(tabToSend, {
command: 'downloaderPageData',
data: {
blobData: blobData,
@ -214,12 +214,16 @@ class BrowserApi {
}, 1000);
} else {
const blob = new Blob([blobData], blobOptions);
const a = win.document.createElement('a');
a.href = win.URL.createObjectURL(blob);
a.download = fileName;
win.document.body.appendChild(a);
a.click();
win.document.body.removeChild(a);
if (navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName);
} else {
const a = win.document.createElement('a');
a.href = win.URL.createObjectURL(blob);
a.download = fileName;
win.document.body.appendChild(a);
a.click();
win.document.body.removeChild(a);
}
}
}

View File

@ -2,16 +2,14 @@ document.addEventListener('DOMContentLoaded', () => {
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf('Safari') !== -1 &&
navigator.userAgent.indexOf('Chrome') === -1;
if (isSafari) {
safari.self.addEventListener('message', (msgEvent: any) => {
doDownload(msgEvent.message);
}, false);
} else if (navigator.userAgent.indexOf(' Edge/') !== -1) {
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: any) => {
doDownload(msg);
});
if (!isSafari) {
return;
}
safari.self.addEventListener('message', (msgEvent: any) => {
doDownload(msgEvent.message);
}, false);
function doDownload(msg: any) {
if (msg.command === 'downloaderPageData' && msg.data) {
const blob = new Blob([msg.data.blobData], msg.data.blobOptions);

View File

@ -73,15 +73,15 @@ export class ExportController {
await Promise.all(promises);
const foldersMap = new Map<string, any>();
for (const f of decFolders) {
decFolders.forEach((f: any) => {
foldersMap.set(f.id, f);
}
});
const exportCiphers = [];
for (const c of decCiphers) {
const exportCiphers: any[] = [];
decCiphers.forEach((c: any) => {
// only export logins and secure notes
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
continue;
return;
}
const cipher: any = {
@ -99,7 +99,7 @@ export class ExportController {
};
if (c.fields) {
for (const f of c.fields) {
c.fields.forEach((f: any) => {
if (!cipher.fields) {
cipher.fields = '';
} else {
@ -107,7 +107,7 @@ export class ExportController {
}
cipher.fields += ((f.name || '') + ': ' + f.value);
}
});
}
switch (c.type) {
@ -122,11 +122,11 @@ export class ExportController {
cipher.type = 'note';
break;
default:
continue;
return;
}
exportCiphers.push(cipher);
}
});
const csv = papa.unparse(exportCiphers);
return csv;