[PM-4415] Starting work on a fallback approach to triggering a notification

This commit is contained in:
Cesar Gonzalez 2024-10-08 10:57:29 -05:00
parent 09121c7c55
commit 9ce9111e32
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
1 changed files with 26 additions and 0 deletions

View File

@ -24,6 +24,7 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
private activeFormSubmissionRequests: ActiveFormSubmissionRequests = new Set();
private modifyLoginCipherFormData: ModifyLoginCipherFormDataForTab = new Map();
private clearLoginCipherFormDataSubject: Subject<void> = new Subject();
private notificationFallbackTimeout: number | NodeJS.Timeout | null;
private readonly formSubmissionRequestMethods: Set<string> = new Set(["POST", "PUT", "PATCH"]);
private readonly extensionMessageHandlers: OverlayNotificationsExtensionMessageHandlers = {
formFieldSubmitted: ({ message, sender }) => this.storeModifiedLoginFormData(message, sender),
@ -126,6 +127,10 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
message: OverlayNotificationsExtensionMessage,
sender: chrome.runtime.MessageSender,
) => {
if (!this.websiteOriginsWithFields.has(sender.tab.id)) {
return;
}
const { uri, username, password, newPassword } = message;
if (!username && !password && !newPassword) {
return;
@ -142,6 +147,21 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
}
this.modifyLoginCipherFormData.set(sender.tab.id, formData);
// CG TODO: In progress idea for fallback notification
if (this.notificationFallbackTimeout) {
clearTimeout(this.notificationFallbackTimeout);
this.notificationFallbackTimeout = null;
}
this.notificationFallbackTimeout = setTimeout(() => {
this.notificationFallbackTimeout = null;
this.setupNotificationInitTrigger(
sender.tab.id,
"",
this.modifyLoginCipherFormData.get(sender.tab.id),
).catch((error) => this.logService.error(error));
}, 5000);
};
/**
@ -317,6 +337,12 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
return;
}
// CG TODO: In progress idea for fallback notification
if (this.notificationFallbackTimeout) {
clearTimeout(this.notificationFallbackTimeout);
this.notificationFallbackTimeout = null;
}
this.setupNotificationInitTrigger(details.tabId, details.requestId, modifyLoginData).catch(
(error) => this.logService.error(error),
);