mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PM-3455] Allow adding and autofilling Cards and Identities via Context Menu (#6050)
* PoC autofill card and identity from context menu * PoC trigger identity and card autofills via messages * update card and identity cipher titles in the context menu * remove unused url argument from loadOptions * do not show no logins message for card and identity sub-menu * allow context menu actions to create identity or card ciphers * open new single-action windows for cipher creation when requested from the context menu * add context menu items for adding a login cipher when none are available to the page * adjust titles for Card and Identity context menu items * fix translations and add no ciphers available messages to submenus * cleanup and update tests * remove unrelated changes * pass uri of context menu page to cipher creation view * Apply suggestions from code review Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com> * cleanup * handle cipher edit background messages with browserPopoutWindowService as well * consolidate doAutoFillNonLoginActiveTab into doAutoFillActiveTab * cleanup --------- Co-authored-by: Cesar Gonzalez <cesar.a.gonzalezcs@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import { SystemService } from "@bitwarden/common/platform/abstractions/system.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
|
||||
import { AutofillService } from "../autofill/services/abstractions/autofill.service";
|
||||
import { BrowserApi } from "../platform/browser/browser-api";
|
||||
@@ -123,12 +124,28 @@ export default class RuntimeBackground {
|
||||
}
|
||||
break;
|
||||
case "openAddEditCipher": {
|
||||
const addEditCipherUrl =
|
||||
cipherId == null
|
||||
? "popup/index.html#/edit-cipher"
|
||||
: "popup/index.html#/edit-cipher?cipherId=" + cipherId;
|
||||
const isNewCipher = !cipherId;
|
||||
const cipherType = msg.data?.cipherType;
|
||||
const senderTab = sender.tab;
|
||||
|
||||
if (!senderTab) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (isNewCipher) {
|
||||
await this.browserPopoutWindowService.openCipherCreation(senderTab.windowId, {
|
||||
cipherType,
|
||||
senderTabId: senderTab.id,
|
||||
senderTabURI: senderTab.url,
|
||||
});
|
||||
} else {
|
||||
await this.browserPopoutWindowService.openCipherEdit(senderTab.windowId, {
|
||||
cipherId,
|
||||
senderTabId: senderTab.id,
|
||||
senderTabURI: senderTab.url,
|
||||
});
|
||||
}
|
||||
|
||||
BrowserApi.openBitwardenExtensionTab(addEditCipherUrl, true);
|
||||
break;
|
||||
}
|
||||
case "closeTab":
|
||||
@@ -174,6 +191,34 @@ export default class RuntimeBackground {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "autofill_card": {
|
||||
await this.autofillService.doAutoFillActiveTab(
|
||||
[
|
||||
{
|
||||
frameId: sender.frameId,
|
||||
tab: msg.tab,
|
||||
details: msg.details,
|
||||
},
|
||||
],
|
||||
false,
|
||||
CipherType.Card
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "autofill_identity": {
|
||||
await this.autofillService.doAutoFillActiveTab(
|
||||
[
|
||||
{
|
||||
frameId: sender.frameId,
|
||||
tab: msg.tab,
|
||||
details: msg.details,
|
||||
},
|
||||
],
|
||||
false,
|
||||
CipherType.Identity
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "contextMenu":
|
||||
clearTimeout(this.autofillTimeout);
|
||||
this.pageDetailsToAutoFill.push({
|
||||
|
||||
Reference in New Issue
Block a user