1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

global message handler for popop

This commit is contained in:
Kyle Spearrin 2018-01-13 20:30:14 -05:00
parent b6a8594d08
commit 64e2debb77
2 changed files with 16 additions and 3 deletions

View File

@ -25,7 +25,7 @@ export class MainController implements ng.IController {
}
});
BrowserApi.messageListener((msg: any, sender: any, sendResponse: any) => {
$window.bitwardenPopupMainMessageListener = (msg: any, sender: any, sendResponse: any) => {
if (msg.command === 'syncCompleted') {
$scope.$broadcast('syncCompleted', msg.successfully);
} else if (msg.command === 'syncStarted') {
@ -38,13 +38,16 @@ export class MainController implements ng.IController {
}
$state.go('home');
});
} else if (msg.command === 'collectPageDetailsResponse' && msg.sender === 'currentController') {
} else if (msg.command === 'collectPageDetailsResponse' &&
msg.sender === 'currentController') {
$scope.$broadcast('collectPageDetailsResponse', {
frameId: sender.frameId,
tab: msg.tab,
details: msg.details,
});
}
});
};
BrowserApi.messageListener($window.bitwardenPopupMainMessageListener);
}
}

View File

@ -15,6 +15,16 @@ export default class BrowserMessagingService implements MessagingService {
if (this.platformUtilsService.isSafari()) {
const bgPage = BrowserApi.getBackgroundPage();
bgPage.bitwardenMain.sendInternalRuntimeMessage(message);
if (!safari.extension.popovers || !safari.extension.popovers.length) {
return;
}
const popover = safari.extension.popovers[0];
const popoverPage = popover.contentWindow;
if (popover.visible && popoverPage.bitwardenPopupMainMessageListener) {
popoverPage.bitwardenPopupMainMessageListener(message);
}
} else {
chrome.runtime.sendMessage(message);
}