mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
[PM-5189] Reworking project structure to ensure we can better differentiate the inline menu feature from other features
This commit is contained in:
@@ -6,31 +6,31 @@ import { PageDetail } from "../../services/abstractions/autofill.service";
|
|||||||
|
|
||||||
import { LockedVaultPendingNotificationsData } from "./notification.background";
|
import { LockedVaultPendingNotificationsData } from "./notification.background";
|
||||||
|
|
||||||
type PageDetailsForTab = Record<
|
export type PageDetailsForTab = Record<
|
||||||
chrome.runtime.MessageSender["tab"]["id"],
|
chrome.runtime.MessageSender["tab"]["id"],
|
||||||
Map<chrome.runtime.MessageSender["frameId"], PageDetail>
|
Map<chrome.runtime.MessageSender["frameId"], PageDetail>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type SubFrameOffsetData = {
|
export type SubFrameOffsetData = {
|
||||||
frameId?: number;
|
frameId?: number;
|
||||||
url?: string;
|
url?: string;
|
||||||
top: number;
|
top: number;
|
||||||
left: number;
|
left: number;
|
||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
type SubFrameOffsetsForTab = Record<
|
export type SubFrameOffsetsForTab = Record<
|
||||||
chrome.runtime.MessageSender["tab"]["id"],
|
chrome.runtime.MessageSender["tab"]["id"],
|
||||||
Map<chrome.runtime.MessageSender["frameId"], SubFrameOffsetData>
|
Map<chrome.runtime.MessageSender["frameId"], SubFrameOffsetData>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type WebsiteIconData = {
|
export type WebsiteIconData = {
|
||||||
imageEnabled: boolean;
|
imageEnabled: boolean;
|
||||||
image: string;
|
image: string;
|
||||||
fallbackImage: string;
|
fallbackImage: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OverlayAddNewItemMessage = {
|
export type OverlayAddNewItemMessage = {
|
||||||
login?: {
|
login?: {
|
||||||
uri?: string;
|
uri?: string;
|
||||||
hostname: string;
|
hostname: string;
|
||||||
@@ -39,14 +39,14 @@ type OverlayAddNewItemMessage = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type FocusedFieldData = {
|
export type FocusedFieldData = {
|
||||||
focusedFieldStyles: Partial<CSSStyleDeclaration>;
|
focusedFieldStyles: Partial<CSSStyleDeclaration>;
|
||||||
focusedFieldRects: Partial<DOMRect>;
|
focusedFieldRects: Partial<DOMRect>;
|
||||||
tabId?: number;
|
tabId?: number;
|
||||||
frameId?: number;
|
frameId?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OverlayBackgroundExtensionMessage = {
|
export type OverlayBackgroundExtensionMessage = {
|
||||||
command: string;
|
command: string;
|
||||||
portKey?: string;
|
portKey?: string;
|
||||||
tab?: chrome.tabs.Tab;
|
tab?: chrome.tabs.Tab;
|
||||||
@@ -64,14 +64,14 @@ type OverlayBackgroundExtensionMessage = {
|
|||||||
data?: LockedVaultPendingNotificationsData;
|
data?: LockedVaultPendingNotificationsData;
|
||||||
} & OverlayAddNewItemMessage;
|
} & OverlayAddNewItemMessage;
|
||||||
|
|
||||||
type OverlayPortMessage = {
|
export type OverlayPortMessage = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
command: string;
|
command: string;
|
||||||
direction?: string;
|
direction?: string;
|
||||||
overlayCipherId?: string;
|
overlayCipherId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OverlayCipherData = {
|
export type OverlayCipherData = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: CipherType;
|
type: CipherType;
|
||||||
@@ -82,15 +82,15 @@ type OverlayCipherData = {
|
|||||||
card?: string;
|
card?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type BackgroundMessageParam = {
|
export type BackgroundMessageParam = {
|
||||||
message: OverlayBackgroundExtensionMessage;
|
message: OverlayBackgroundExtensionMessage;
|
||||||
};
|
};
|
||||||
type BackgroundSenderParam = {
|
export type BackgroundSenderParam = {
|
||||||
sender: chrome.runtime.MessageSender;
|
sender: chrome.runtime.MessageSender;
|
||||||
};
|
};
|
||||||
type BackgroundOnMessageHandlerParams = BackgroundMessageParam & BackgroundSenderParam;
|
export type BackgroundOnMessageHandlerParams = BackgroundMessageParam & BackgroundSenderParam;
|
||||||
|
|
||||||
type OverlayBackgroundExtensionMessageHandlers = {
|
export type OverlayBackgroundExtensionMessageHandlers = {
|
||||||
[key: string]: CallableFunction;
|
[key: string]: CallableFunction;
|
||||||
openAutofillInlineMenu: () => void;
|
openAutofillInlineMenu: () => void;
|
||||||
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||||
@@ -120,15 +120,15 @@ type OverlayBackgroundExtensionMessageHandlers = {
|
|||||||
deletedCipher: () => void;
|
deletedCipher: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PortMessageParam = {
|
export type PortMessageParam = {
|
||||||
message: OverlayPortMessage;
|
message: OverlayPortMessage;
|
||||||
};
|
};
|
||||||
type PortConnectionParam = {
|
export type PortConnectionParam = {
|
||||||
port: chrome.runtime.Port;
|
port: chrome.runtime.Port;
|
||||||
};
|
};
|
||||||
type PortOnMessageHandlerParams = PortMessageParam & PortConnectionParam;
|
export type PortOnMessageHandlerParams = PortMessageParam & PortConnectionParam;
|
||||||
|
|
||||||
type InlineMenuButtonPortMessageHandlers = {
|
export type InlineMenuButtonPortMessageHandlers = {
|
||||||
[key: string]: CallableFunction;
|
[key: string]: CallableFunction;
|
||||||
autofillInlineMenuButtonClicked: ({ port }: PortConnectionParam) => void;
|
autofillInlineMenuButtonClicked: ({ port }: PortConnectionParam) => void;
|
||||||
closeAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
closeAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
||||||
@@ -138,7 +138,7 @@ type InlineMenuButtonPortMessageHandlers = {
|
|||||||
updateAutofillInlineMenuColorScheme: () => void;
|
updateAutofillInlineMenuColorScheme: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type InlineMenuListPortMessageHandlers = {
|
export type InlineMenuListPortMessageHandlers = {
|
||||||
[key: string]: CallableFunction;
|
[key: string]: CallableFunction;
|
||||||
checkAutofillInlineMenuButtonFocused: () => void;
|
checkAutofillInlineMenuButtonFocused: () => void;
|
||||||
forceCloseAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
forceCloseAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
||||||
@@ -151,24 +151,8 @@ type InlineMenuListPortMessageHandlers = {
|
|||||||
updateAutofillInlineMenuListHeight: ({ message, port }: PortOnMessageHandlerParams) => void;
|
updateAutofillInlineMenuListHeight: ({ message, port }: PortOnMessageHandlerParams) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface OverlayBackground {
|
export interface OverlayBackground {
|
||||||
init(): Promise<void>;
|
init(): Promise<void>;
|
||||||
removePageDetails(tabId: number): void;
|
removePageDetails(tabId: number): void;
|
||||||
updateOverlayCiphers(): void;
|
updateOverlayCiphers(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
|
||||||
PageDetailsForTab,
|
|
||||||
SubFrameOffsetData,
|
|
||||||
SubFrameOffsetsForTab,
|
|
||||||
WebsiteIconData,
|
|
||||||
OverlayBackgroundExtensionMessage,
|
|
||||||
OverlayPortMessage,
|
|
||||||
FocusedFieldData,
|
|
||||||
OverlayCipherData,
|
|
||||||
OverlayAddNewItemMessage,
|
|
||||||
OverlayBackgroundExtensionMessageHandlers,
|
|
||||||
InlineMenuButtonPortMessageHandlers,
|
|
||||||
InlineMenuListPortMessageHandlers,
|
|
||||||
OverlayBackground,
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ import {
|
|||||||
} from "../spec/autofill-mocks";
|
} from "../spec/autofill-mocks";
|
||||||
import { flushPromises, sendMockExtensionMessage, sendPortMessage } from "../spec/testing-utils";
|
import { flushPromises, sendMockExtensionMessage, sendPortMessage } from "../spec/testing-utils";
|
||||||
|
|
||||||
import OverlayBackground from "./overlay.background";
|
import { OverlayBackground } from "./overlay.background";
|
||||||
|
|
||||||
describe("OverlayBackground", () => {
|
describe("OverlayBackground", () => {
|
||||||
const mockUserId = Utils.newGuid() as UserId;
|
const mockUserId = Utils.newGuid() as UserId;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import {
|
|||||||
SubFrameOffsetsForTab,
|
SubFrameOffsetsForTab,
|
||||||
} from "./abstractions/overlay.background";
|
} from "./abstractions/overlay.background";
|
||||||
|
|
||||||
class OverlayBackground implements OverlayBackgroundInterface {
|
export class OverlayBackground implements OverlayBackgroundInterface {
|
||||||
private readonly openUnlockPopout = openUnlockPopout;
|
private readonly openUnlockPopout = openUnlockPopout;
|
||||||
private readonly openViewVaultItemPopout = openViewVaultItemPopout;
|
private readonly openViewVaultItemPopout = openViewVaultItemPopout;
|
||||||
private readonly openAddEditVaultItemPopout = openAddEditVaultItemPopout;
|
private readonly openAddEditVaultItemPopout = openAddEditVaultItemPopout;
|
||||||
@@ -1047,5 +1047,3 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OverlayBackground;
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from "../spec/testing-utils";
|
} from "../spec/testing-utils";
|
||||||
|
|
||||||
import NotificationBackground from "./notification.background";
|
import NotificationBackground from "./notification.background";
|
||||||
import OverlayBackground from "./overlay.background";
|
import { OverlayBackground } from "./overlay.background";
|
||||||
import TabsBackground from "./tabs.background";
|
import TabsBackground from "./tabs.background";
|
||||||
|
|
||||||
describe("TabsBackground", () => {
|
describe("TabsBackground", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import MainBackground from "../../background/main.background";
|
import MainBackground from "../../background/main.background";
|
||||||
|
|
||||||
|
import { OverlayBackground } from "./abstractions/overlay.background";
|
||||||
import NotificationBackground from "./notification.background";
|
import NotificationBackground from "./notification.background";
|
||||||
import OverlayBackground from "./overlay.background";
|
|
||||||
|
|
||||||
export default class TabsBackground {
|
export default class TabsBackground {
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ import {
|
|||||||
|
|
||||||
import ContextMenusBackground from "../autofill/background/context-menus.background";
|
import ContextMenusBackground from "../autofill/background/context-menus.background";
|
||||||
import NotificationBackground from "../autofill/background/notification.background";
|
import NotificationBackground from "../autofill/background/notification.background";
|
||||||
import OverlayBackground from "../autofill/background/overlay.background";
|
import { OverlayBackground } from "../autofill/background/overlay.background";
|
||||||
import TabsBackground from "../autofill/background/tabs.background";
|
import TabsBackground from "../autofill/background/tabs.background";
|
||||||
import WebRequestBackground from "../autofill/background/web-request.background";
|
import WebRequestBackground from "../autofill/background/web-request.background";
|
||||||
import { CipherContextMenuHandler } from "../autofill/browser/cipher-context-menu-handler";
|
import { CipherContextMenuHandler } from "../autofill/browser/cipher-context-menu-handler";
|
||||||
|
|||||||
Reference in New Issue
Block a user