mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
[PM-5189] Working through implementation scaffolding
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
|||||||
openViewVaultItemPopout,
|
openViewVaultItemPopout,
|
||||||
openAddEditVaultItemPopout,
|
openAddEditVaultItemPopout,
|
||||||
} from "../../vault/popup/utils/vault-popout-window";
|
} from "../../vault/popup/utils/vault-popout-window";
|
||||||
import { AutofillService } from "../services/abstractions/autofill.service";
|
import { AutofillService, PageDetail } from "../services/abstractions/autofill.service";
|
||||||
import { AutofillOverlayElement, AutofillOverlayPort } from "../utils/autofill-overlay.enum";
|
import { AutofillOverlayElement, AutofillOverlayPort } from "../utils/autofill-overlay.enum";
|
||||||
|
|
||||||
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
|
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
|
||||||
@@ -41,6 +41,7 @@ import {
|
|||||||
OverlayPortMessage,
|
OverlayPortMessage,
|
||||||
WebsiteIconData,
|
WebsiteIconData,
|
||||||
PageDetailsForTab,
|
PageDetailsForTab,
|
||||||
|
SubFrameOffsetsForTab,
|
||||||
} from "./abstractions/overlay.background";
|
} from "./abstractions/overlay.background";
|
||||||
|
|
||||||
class OverlayBackground implements OverlayBackgroundInterface {
|
class OverlayBackground implements OverlayBackgroundInterface {
|
||||||
@@ -49,6 +50,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
private readonly openAddEditVaultItemPopout = openAddEditVaultItemPopout;
|
private readonly openAddEditVaultItemPopout = openAddEditVaultItemPopout;
|
||||||
private overlayLoginCiphers: Map<string, CipherView> = new Map();
|
private overlayLoginCiphers: Map<string, CipherView> = new Map();
|
||||||
private pageDetailsForTab: PageDetailsForTab = {};
|
private pageDetailsForTab: PageDetailsForTab = {};
|
||||||
|
private subFrameOffsetsForTab: SubFrameOffsetsForTab = {};
|
||||||
private userAuthStatus: AuthenticationStatus = AuthenticationStatus.LoggedOut;
|
private userAuthStatus: AuthenticationStatus = AuthenticationStatus.LoggedOut;
|
||||||
private overlayButtonPort: chrome.runtime.Port;
|
private overlayButtonPort: chrome.runtime.Port;
|
||||||
private overlayListPort: chrome.runtime.Port;
|
private overlayListPort: chrome.runtime.Port;
|
||||||
@@ -209,6 +211,11 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
details: message.details,
|
details: message.details,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (pageDetails.frameId !== 0 && pageDetails.details.fields.length) {
|
||||||
|
// NOT SURE I WANT THIS
|
||||||
|
void this.buildSubFrameOffset(pageDetails);
|
||||||
|
}
|
||||||
|
|
||||||
const pageDetailsMap = this.pageDetailsForTab[sender.tab.id];
|
const pageDetailsMap = this.pageDetailsForTab[sender.tab.id];
|
||||||
if (!pageDetailsMap) {
|
if (!pageDetailsMap) {
|
||||||
this.pageDetailsForTab[sender.tab.id] = new Map([[sender.frameId, pageDetails]]);
|
this.pageDetailsForTab[sender.tab.id] = new Map([[sender.frameId, pageDetails]]);
|
||||||
@@ -218,8 +225,14 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
pageDetailsMap.set(sender.frameId, pageDetails);
|
pageDetailsMap.set(sender.frameId, pageDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildFrameOffset(frameId: number, tabId: number) {
|
private async buildSubFrameOffset({ tab, frameId, details }: PageDetail) {
|
||||||
return frameId ? 10 : 0;
|
const frameDetails = await BrowserApi.getFrameDetails({
|
||||||
|
tabId: tab.id,
|
||||||
|
frameId,
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
console.log(frameDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
bgUnlockPopoutOpened: () => this.blurAndRemoveOverlay(),
|
bgUnlockPopoutOpened: () => this.blurAndRemoveOverlay(),
|
||||||
bgVaultItemRepromptPopoutOpened: () => this.blurAndRemoveOverlay(),
|
bgVaultItemRepromptPopoutOpened: () => this.blurAndRemoveOverlay(),
|
||||||
updateAutofillOverlayVisibility: ({ message }) => this.updateAutofillOverlayVisibility(message),
|
updateAutofillOverlayVisibility: ({ message }) => this.updateAutofillOverlayVisibility(message),
|
||||||
|
getSubFrameOffsets: () => this.getSubFrameOffsets(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,6 +250,8 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
this.autofillOverlayContentService.autofillOverlayVisibility = data?.autofillOverlayVisibility;
|
this.autofillOverlayContentService.autofillOverlayVisibility = data?.autofillOverlayVisibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getSubFrameOffsets() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the extension message listeners for the content script.
|
* Sets up the extension message listeners for the content script.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -269,6 +269,12 @@ export class BrowserApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getFrameDetails(
|
||||||
|
details: chrome.webNavigation.GetFrameDetails,
|
||||||
|
): Promise<chrome.webNavigation.GetFrameResultDetails> {
|
||||||
|
return new Promise((resolve) => chrome.webNavigation.getFrame(details, resolve));
|
||||||
|
}
|
||||||
|
|
||||||
// Keep track of all the events registered in a Safari popup so we can remove
|
// Keep track of all the events registered in a Safari popup so we can remove
|
||||||
// them when the popup gets unloaded, otherwise we cause a memory leak
|
// them when the popup gets unloaded, otherwise we cause a memory leak
|
||||||
private static trackedChromeEventListeners: [
|
private static trackedChromeEventListeners: [
|
||||||
|
|||||||
Reference in New Issue
Block a user