1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

PM-15998 - Update browser context menu options when the page domain is a blocked domain (#13378)

* update main context menu handler to skip creating menu entries which do not pass blocked uri checks

* refactor to remove menu entries which do not pass blocked uri checks

* allow context menu autofill items without a password if they have other autofillable attributes

* include ciphers without passwords in autofill context menu options and track context menu state
This commit is contained in:
Jonathan Prusik
2025-02-18 15:27:01 -05:00
committed by GitHub
parent f798760dc5
commit a2c23aa661
5 changed files with 255 additions and 54 deletions

View File

@@ -1374,17 +1374,41 @@ export default class MainBackground {
return;
}
await this.mainContextMenuHandler?.init();
const contextMenuIsEnabled = await this.mainContextMenuHandler?.init();
if (!contextMenuIsEnabled) {
this.onUpdatedRan = this.onReplacedRan = false;
return;
}
const tab = await BrowserApi.getTabFromCurrentWindow();
if (tab) {
await this.cipherContextMenuHandler?.update(tab.url);
const currentUriIsBlocked = await firstValueFrom(
this.domainSettingsService.blockedInteractionsUris$.pipe(
map((blockedInteractionsUris) => {
if (blockedInteractionsUris && tab?.url?.length) {
const tabURL = new URL(tab.url);
const tabIsBlocked = Object.keys(blockedInteractionsUris).some((blockedHostname) =>
tabURL.hostname.endsWith(blockedHostname),
);
if (tabIsBlocked) {
return true;
}
}
return false;
}),
),
);
await this.cipherContextMenuHandler?.update(tab.url, currentUriIsBlocked);
this.onUpdatedRan = this.onReplacedRan = false;
}
}
async updateOverlayCiphers() {
// overlayBackground null in popup only contexts
// `overlayBackground` is null in popup only contexts
if (this.overlayBackground) {
await this.overlayBackground.updateOverlayCiphers();
}