444
445
serialize(): ISerializedBrowserPermissionsSnapshot {
446
>
const origins: Record<string, Partial<Record<PermissionCategory, PermissionDecision>>> = {};
browserPermissions.ts
447
>
for (const [origin, categories] of this._data) {
448
>
const entry: Partial<Record<PermissionCategory, PermissionDecision>> = {};
449
>
for (const [category, state] of categories) {
450
>
entry[category] = state;
451
>
}
452
>
origins[origin] = entry;
453
>
}
454
>
return { origins };
455
>
}
456
457
hydrate(snapshot: ISerializedBrowserPermissionsSnapshot | undefined): void {
459
>
if (snapshot?.origins && typeof snapshot.origins === 'object') {
460
>
for (const [origin, categories] of Object.entries(snapshot.origins)) {
461
>
if (!categories || typeof categories !== 'object') {
462
continue;
463
}
465
>
if (!key) {
466
continue;
467
}
469
>
for (const [category, state] of Object.entries(categories)) {
470
>
if (!VALID_CATEGORIES.has(category) || (state !== 'allow' && state !== 'deny')) {
471
continue;
472
}
474
>
target = new Map();
475
>
this._data.set(key, target);
476
>
}
477
>
target.set(category as PermissionCategory, state);
478
>
}
479
>
}
480
>
}
481
>
this._onDidChange.fire();
482
>
}
483
}