internal runtime messages in safari
This commit is contained in:
parent
2156916f0b
commit
b6a8594d08
|
@ -273,6 +273,14 @@ export default class MainBackground {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendInternalRuntimeMessage(message: any) {
|
||||||
|
if (!this.isSafari) {
|
||||||
|
throw new Error('Only safari can send internal runtime messages.');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.runtimeBackground.processMessage(message, { tab: null }, () => { /* No response needed. */ });
|
||||||
|
}
|
||||||
|
|
||||||
private async buildContextMenu() {
|
private async buildContextMenu() {
|
||||||
if (this.isSafari || !chrome.contextMenus || this.buildingContextMenu) {
|
if (this.isSafari || !chrome.contextMenus || this.buildingContextMenu) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default class RuntimeBackground {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async processMessage(msg: any, sender: any, sendResponse: any) {
|
async processMessage(msg: any, sender: any, sendResponse: any) {
|
||||||
switch (msg.command) {
|
switch (msg.command) {
|
||||||
case 'loggedIn':
|
case 'loggedIn':
|
||||||
case 'unlocked':
|
case 'unlocked':
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { BrowserApi } from '../browser/browserApi';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MessagingService,
|
MessagingService,
|
||||||
PlatformUtilsService,
|
PlatformUtilsService,
|
||||||
|
@ -8,10 +10,12 @@ export default class BrowserMessagingService implements MessagingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
send(subscriber: string, arg: any = {}) {
|
send(subscriber: string, arg: any = {}) {
|
||||||
|
const message = Object.assign({}, { command: subscriber }, arg);
|
||||||
|
|
||||||
if (this.platformUtilsService.isSafari()) {
|
if (this.platformUtilsService.isSafari()) {
|
||||||
// send message
|
const bgPage = BrowserApi.getBackgroundPage();
|
||||||
|
bgPage.bitwardenMain.sendInternalRuntimeMessage(message);
|
||||||
} else {
|
} else {
|
||||||
const message = Object.assign({}, { command: subscriber }, arg);
|
|
||||||
chrome.runtime.sendMessage(message);
|
chrome.runtime.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue