Skip to content

Commit c677d9e

Browse files
committed
Add trusted domains for #93332
1 parent 9640830 commit c677d9e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/vs/workbench/contrib/url/common/trustedDomains.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1414

1515
const TRUSTED_DOMAINS_URI = URI.parse('trustedDomains:/Trusted Domains');
1616

17+
export const TRUSTED_DOMAINS_STORAGE_KEY = 'http.linkProtectionTrustedDomains';
18+
export const TRUSTED_DOMAINS_CONTENT_STORAGE_KEY = 'http.linkProtectionTrustedDomainsContent';
19+
1720
export const manageTrustedDomainSettingsCommand = {
1821
id: 'workbench.action.manageTrustedDomain',
1922
description: {
@@ -98,9 +101,9 @@ export async function configureOpenerTrustedDomainsHandler(
98101
: pickedResult.id === 'trustSubdomain' ? topLevelDomain : '*';
99102

100103
if (trustedDomains.indexOf(itemToTrust) === -1) {
101-
storageService.remove('http.linkProtectionTrustedDomainsContent', StorageScope.GLOBAL);
104+
storageService.remove(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, StorageScope.GLOBAL);
102105
storageService.store(
103-
'http.linkProtectionTrustedDomains',
106+
TRUSTED_DOMAINS_STORAGE_KEY,
104107
JSON.stringify([...trustedDomains, itemToTrust]),
105108
StorageScope.GLOBAL
106109
);
@@ -120,7 +123,7 @@ export function readTrustedDomains(storageService: IStorageService, productServi
120123

121124
let trustedDomains: string[] = [];
122125
try {
123-
const trustedDomainsSrc = storageService.get('http.linkProtectionTrustedDomains', StorageScope.GLOBAL);
126+
const trustedDomainsSrc = storageService.get(TRUSTED_DOMAINS_STORAGE_KEY, StorageScope.GLOBAL);
124127
if (trustedDomainsSrc) {
125128
trustedDomains = JSON.parse(trustedDomainsSrc);
126129
}

src/vs/workbench/contrib/url/common/trustedDomainsFileSystemProvider.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { FileDeleteOptions, FileOverwriteOptions, FileSystemProviderCapabilities
1111
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
1212
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1313
import { VSBuffer } from 'vs/base/common/buffer';
14-
import { readTrustedDomains } from 'vs/workbench/contrib/url/common/trustedDomains';
14+
import { readTrustedDomains, TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, TRUSTED_DOMAINS_STORAGE_KEY } from 'vs/workbench/contrib/url/common/trustedDomains';
1515
import { IProductService } from 'vs/platform/product/common/productService';
16+
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
1617

1718
const TRUSTED_DOMAINS_SCHEMA = 'trustedDomains';
1819

@@ -76,9 +77,13 @@ export class TrustedDomainsFileSystemProvider implements IFileSystemProviderWith
7677
constructor(
7778
@IFileService private readonly fileService: IFileService,
7879
@IStorageService private readonly storageService: IStorageService,
79-
@IProductService private readonly productService: IProductService
80+
@IProductService private readonly productService: IProductService,
81+
@IStorageKeysSyncRegistryService private readonly storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
8082
) {
8183
this.fileService.registerProvider(TRUSTED_DOMAINS_SCHEMA, this);
84+
85+
this.storageKeysSyncRegistryService.registerStorageKey({ key: TRUSTED_DOMAINS_STORAGE_KEY, version: 1 });
86+
this.storageKeysSyncRegistryService.registerStorageKey({ key: TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, version: 1 });
8287
}
8388

8489
stat(resource: URI): Promise<IStat> {
@@ -87,7 +92,7 @@ export class TrustedDomainsFileSystemProvider implements IFileSystemProviderWith
8792

8893
readFile(resource: URI): Promise<Uint8Array> {
8994
let trustedDomainsContent = this.storageService.get(
90-
'http.linkProtectionTrustedDomainsContent',
95+
TRUSTED_DOMAINS_CONTENT_STORAGE_KEY,
9196
StorageScope.GLOBAL
9297
);
9398

@@ -110,9 +115,9 @@ export class TrustedDomainsFileSystemProvider implements IFileSystemProviderWith
110115
const trustedDomainsContent = VSBuffer.wrap(content).toString();
111116
const trustedDomains = parse(trustedDomainsContent);
112117

113-
this.storageService.store('http.linkProtectionTrustedDomainsContent', trustedDomainsContent, StorageScope.GLOBAL);
118+
this.storageService.store(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, trustedDomainsContent, StorageScope.GLOBAL);
114119
this.storageService.store(
115-
'http.linkProtectionTrustedDomains',
120+
TRUSTED_DOMAINS_STORAGE_KEY,
116121
JSON.stringify(trustedDomains) || '',
117122
StorageScope.GLOBAL
118123
);

0 commit comments

Comments
 (0)