Bug 1890427 - Part 2: Use an observer to regenerate backups when a password is deleted. r=backup-reviewers,kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D218873
This commit is contained in:
Mike Conley
2024-09-04 17:56:56 +00:00
parent 5c50c56a5d
commit a534022f9b
2 changed files with 68 additions and 1 deletions

View File

@@ -3159,6 +3159,7 @@ export class BackupService extends EventTarget {
this.#placesObserver
);
Services.obs.addObserver(this.#observer, "passwordmgr-storage-changed");
Services.obs.addObserver(this.#observer, "quit-application-granted");
}
@@ -3185,6 +3186,7 @@ export class BackupService extends EventTarget {
this.#placesObserver
);
Services.obs.removeObserver(this.#observer, "passwordmgr-storage-changed");
Services.obs.removeObserver(this.#observer, "quit-application-granted");
this.#observer = null;
}
@@ -3199,8 +3201,10 @@ export class BackupService extends EventTarget {
* quit-application-granted topic.
* @param {string} topic
* The topic that the notification belongs to.
* @param {string} data
* Optional data that was included with the notification.
*/
onObserve(_subject, topic) {
onObserve(_subject, topic, data) {
switch (topic) {
case "idle": {
this.onIdle();
@@ -3211,6 +3215,12 @@ export class BackupService extends EventTarget {
this.#backupWriteAbortController.abort();
break;
}
case "passwordmgr-storage-changed": {
if (data == "removeLogin" || data == "removeAllLogins") {
this.#debounceRegeneration();
}
break;
}
}
}