Skip to content

Commit 6c10fb4

Browse files
committed
Remove 'trusted' notebook document
See microsoft#118584 for more
1 parent 9aac6ab commit 6c10fb4

File tree

5 files changed

+23
-65
lines changed

5 files changed

+23
-65
lines changed

src/vs/vscode.proposed.d.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,22 +1041,15 @@ declare module 'vscode' {
10411041
}
10421042

10431043
export class NotebookDocumentMetadata {
1044-
/**
1045-
* Whether the document is trusted, default to true
1046-
* When false, insecure outputs like HTML, JavaScript, SVG will not be rendered.
1047-
*/
1048-
readonly trusted: boolean;
1049-
10501044
/**
10511045
* Additional attributes of the document metadata.
10521046
*/
10531047
readonly [key: string]: any;
10541048

10551049
/**
10561050
* Create a new notebook document metadata
1057-
* @param trusted Whether the document metadata is trusted.
10581051
*/
1059-
constructor(trusted?: boolean);
1052+
constructor();
10601053

10611054
/**
10621055
* Derived a new document metadata from this metadata.
@@ -1065,7 +1058,7 @@ declare module 'vscode' {
10651058
* @return A new NotebookDocumentMetadata that reflects the given change. Will return `this` NotebookDocumentMetadata if the change
10661059
* is not changing anything.
10671060
*/
1068-
with(change: { trusted?: boolean | null, [key: string]: any }): NotebookDocumentMetadata
1061+
with(change: { [key: string]: any }): NotebookDocumentMetadata
10691062
}
10701063

10711064
export interface NotebookDocumentContentOptions {

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,45 +3008,16 @@ export class NotebookCellMetadata {
30083008
}
30093009

30103010
export class NotebookDocumentMetadata {
3011-
readonly trusted: boolean;
30123011
readonly [key: string]: any;
30133012

3014-
constructor(trusted?: boolean);
3015-
constructor(data: Record<string, any>);
3016-
constructor(trustedOrData: boolean | Record<string, any> = true) {
3017-
if (typeof trustedOrData === 'object') {
3018-
Object.assign(this, trustedOrData);
3019-
this.trusted = trustedOrData.trusted ?? true;
3020-
} else {
3021-
this.trusted = trustedOrData;
3022-
}
3013+
constructor(data: Record<string, any> = {}) {
3014+
Object.assign(this, data);
30233015
}
30243016

30253017
with(change: {
3026-
trusted?: boolean | null,
30273018
[key: string]: any
30283019
}): NotebookDocumentMetadata {
3029-
3030-
let { trusted, ...remaining } = change;
3031-
3032-
if (trusted === undefined) {
3033-
trusted = this.trusted;
3034-
} else if (trusted === null) {
3035-
trusted = undefined;
3036-
}
3037-
3038-
if (trusted === this.trusted &&
3039-
Object.keys(remaining).length === 0
3040-
) {
3041-
return this;
3042-
}
3043-
3044-
return new NotebookDocumentMetadata(
3045-
{
3046-
trusted,
3047-
...remaining
3048-
}
3049-
);
3020+
return new NotebookDocumentMetadata(change);
30503021
}
30513022
}
30523023

src/vs/workbench/contrib/notebook/browser/notebookEditorKernelManager.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ export class NotebookEditorKernelManager extends Disposable {
4040
return;
4141
}
4242

43-
if (!notebook.metadata.trusted) {
44-
return;
45-
}
46-
4743
let kernel = this.getSelectedOrSuggestedKernel(notebook);
4844
if (!kernel) {
4945
await this._commandService.executeCommand('notebook.selectKernel');

src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,44 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as glob from 'vs/base/common/glob';
7-
import { localize } from 'vs/nls';
86
import { getPixelRatio, getZoomLevel } from 'vs/base/browser/browser';
97
import { Emitter, Event } from 'vs/base/common/event';
8+
import * as glob from 'vs/base/common/glob';
109
import { Iterable } from 'vs/base/common/iterator';
10+
import { Lazy } from 'vs/base/common/lazy';
1111
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
1212
import { ResourceMap } from 'vs/base/common/map';
13+
import { Schemas } from 'vs/base/common/network';
1314
import { URI } from 'vs/base/common/uri';
1415
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
1516
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
1617
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
18+
import { localize } from 'vs/nls';
1719
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
1820
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
21+
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
22+
import { IFileService } from 'vs/platform/files/common/files';
1923
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
24+
import { Registry } from 'vs/platform/registry/common/platform';
2025
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
2126
import { NotebookExtensionDescription } from 'vs/workbench/api/common/extHost.protocol';
27+
import { EditorExtensions, IEditorInput } from 'vs/workbench/common/editor';
28+
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
2229
import { Memento } from 'vs/workbench/common/memento';
2330
import { INotebookEditorContribution, notebookMarkupRendererExtensionPoint, notebookProviderExtensionPoint, notebookRendererExtensionPoint } from 'vs/workbench/contrib/notebook/browser/extensionPoint';
2431
import { NotebookEditorOptions, updateEditorTopPadding } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
32+
import { NotebookDiffEditorInput } from 'vs/workbench/contrib/notebook/browser/notebookDiffEditorInput';
2533
import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
2634
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
27-
import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, BUILTIN_RENDERER_ID, CellUri, DisplayOrderKey, INotebookExclusiveDocumentFilter, INotebookMarkupRendererInfo, INotebookRendererInfo, INotebookTextModel, IOrderedMimeType, IOutputDto, mimeTypeIsAlwaysSecure, mimeTypeSupportedByCore, NotebookDataDto, NotebookEditorPriority, NotebookRendererMatch, NotebookTextDiffEditorPreview, RENDERER_NOT_AVAILABLE, sortMimeTypes, TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon';
35+
import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, BUILTIN_RENDERER_ID, CellUri, DisplayOrderKey, INotebookExclusiveDocumentFilter, INotebookMarkupRendererInfo, INotebookRendererInfo, INotebookTextModel, IOrderedMimeType, IOutputDto, mimeTypeSupportedByCore, NotebookDataDto, NotebookEditorPriority, NotebookRendererMatch, NotebookTextDiffEditorPreview, RENDERER_NOT_AVAILABLE, sortMimeTypes, TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon';
36+
import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
2837
import { NotebookMarkupRendererInfo as NotebookMarkupRendererInfo } from 'vs/workbench/contrib/notebook/common/notebookMarkdownRenderer';
2938
import { NotebookOutputRendererInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer';
3039
import { NotebookEditorDescriptor, NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider';
3140
import { ComplexNotebookProviderInfo, INotebookContentProvider, INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
41+
import { ContributedEditorPriority, DiffEditorInputFactoryFunction, EditorInputFactoryFunction, IEditorAssociationsRegistry, IEditorOverrideService, IEditorType, IEditorTypesHandler } from 'vs/workbench/services/editor/common/editorOverrideService';
3242
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
3343
import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
34-
import { Registry } from 'vs/platform/registry/common/platform';
35-
import { Schemas } from 'vs/base/common/network';
36-
import { Lazy } from 'vs/base/common/lazy';
37-
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
38-
import { NotebookDiffEditorInput } from 'vs/workbench/contrib/notebook/browser/notebookDiffEditorInput';
39-
import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
40-
import { ContributedEditorPriority, DiffEditorInputFactoryFunction, EditorInputFactoryFunction, IEditorAssociationsRegistry, IEditorOverrideService, IEditorType, IEditorTypesHandler } from 'vs/workbench/services/editor/common/editorOverrideService';
41-
import { EditorExtensions, IEditorInput } from 'vs/workbench/common/editor';
42-
import { IFileService } from 'vs/platform/files/common/files';
43-
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
4444

4545
export class NotebookProviderInfoStore extends Disposable {
4646

@@ -599,36 +599,36 @@ export class NotebookService extends Disposable implements INotebookService, IEd
599599
orderMimeTypes.push({
600600
mimeType: mimeType,
601601
rendererId: handler.id,
602-
isTrusted: textModel.metadata.trusted
602+
isTrusted: true
603603
});
604604

605605
for (let i = 1; i < handlers.length; i++) {
606606
orderMimeTypes.push({
607607
mimeType: mimeType,
608608
rendererId: handlers[i].id,
609-
isTrusted: textModel.metadata.trusted
609+
isTrusted: true
610610
});
611611
}
612612

613613
if (mimeTypeSupportedByCore(mimeType)) {
614614
orderMimeTypes.push({
615615
mimeType: mimeType,
616616
rendererId: BUILTIN_RENDERER_ID,
617-
isTrusted: mimeTypeIsAlwaysSecure(mimeType) || textModel.metadata.trusted
617+
isTrusted: true // TODO@roblourens mimeTypeIsAlwaysSecure(mimeType) || this.workspaceTrustManagementService.isWorkpaceTrusted()
618618
});
619619
}
620620
} else {
621621
if (mimeTypeSupportedByCore(mimeType)) {
622622
orderMimeTypes.push({
623623
mimeType: mimeType,
624624
rendererId: BUILTIN_RENDERER_ID,
625-
isTrusted: mimeTypeIsAlwaysSecure(mimeType) || textModel.metadata.trusted
625+
isTrusted: true // TODO@roblourens mimeTypeIsAlwaysSecure(mimeType) || this.workspaceTrustManagementService.isWorkpaceTrusted()
626626
});
627627
} else {
628628
orderMimeTypes.push({
629629
mimeType: mimeType,
630630
rendererId: RENDERER_NOT_AVAILABLE,
631-
isTrusted: textModel.metadata.trusted
631+
isTrusted: true
632632
});
633633
}
634634
}

src/vs/workbench/contrib/notebook/common/notebookCommon.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ export enum NotebookRunState {
6161

6262
export const notebookDocumentMetadataDefaults: Required<NotebookDocumentMetadata> = {
6363
custom: {},
64-
trusted: true
6564
};
6665

6766
export interface NotebookDocumentMetadata {
6867
custom?: { [key: string]: unknown };
69-
trusted: boolean;
7068
[key: string]: unknown;
7169
}
7270

0 commit comments

Comments
 (0)