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:
parent
b6a8594d08
commit
64e2debb77
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user