forked from mirrors/gecko-dev
backup-settings changes: - adds a new button in the Backup section of about:preferences / about:settings - shows the turn on dialog after pressing the button Turn on dialog behaviour (implemented): - pressing the cancel will close the dialog - pressing the confirm button will set the pref browser.backup.scheduled.enabled=true and close the dialog - pressing the passwords checkbox will show more options Turn on dialog behaviour (not implemented): - requiring a password for the backup (see Bug 1895981) - modifying the save location and showing a file picker (see Bug 1895943) Other changes: - tests for backup-settings and the turn on dialog - Storybook template for the turn on dialog Lo-fi Figma designs: https://www.figma.com/design/vNbX4c0ws0L1qr0mxpKvsW/Fx-Backup?node-id=147-4558&t=PYLY0QMN1n8GR9vW-0 Differential Revision: https://phabricator.services.mozilla.com/D209769
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/**
|
|
* A JSWindowActor that is responsible for marshalling information between
|
|
* the BackupService singleton and any registered UI widgets that need to
|
|
* represent data from that service. Any UI widgets that want to receive
|
|
* state updates from BackupService should emit a BackupUI:InitWidget
|
|
* event in a document that this actor pair is registered for.
|
|
*/
|
|
export class BackupUIChild extends JSWindowActorChild {
|
|
#inittedWidgets = new WeakSet();
|
|
|
|
/**
|
|
* Handles custom events fired by widgets that want to register with
|
|
* BackupUIChild.
|
|
*
|
|
* @param {Event} event
|
|
* The custom event that the widget fired.
|
|
*/
|
|
handleEvent(event) {
|
|
/**
|
|
* BackupUI:InitWidget sends a message to the parent to request the BackupService state
|
|
* which will result in a `backupServiceState` property of the widget to be set when that
|
|
* state is received. Subsequent state updates will also cause that state property to
|
|
* be set.
|
|
*/
|
|
if (event.type == "BackupUI:InitWidget") {
|
|
this.#inittedWidgets.add(event.target);
|
|
this.sendAsyncMessage("RequestState");
|
|
} else if (event.type == "BackupUI:ScheduledBackupsConfirm") {
|
|
this.sendAsyncMessage("ScheduledBackupsConfirm");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handles messages sent by BackupUIParent.
|
|
*
|
|
* @param {ReceiveMessageArgument} message
|
|
* The message received from the BackupUIParent.
|
|
*/
|
|
receiveMessage(message) {
|
|
if (message.name == "StateUpdate") {
|
|
let widgets = ChromeUtils.nondeterministicGetWeakSetKeys(
|
|
this.#inittedWidgets
|
|
);
|
|
for (let widget of widgets) {
|
|
if (widget.isConnected) {
|
|
// Note: we might need to switch to using Cu.cloneInto here in the
|
|
// event that these widgets are embedded in a non-parent-process
|
|
// context, like in an onboarding card.
|
|
widget.backupServiceState = message.data.state;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|