Skip to content

Commit 966aeb0

Browse files
author
Matt Bierner
committed
Move useSameOriginForRoot into options
1 parent d2d8e45 commit 966aeb0

5 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/vs/workbench/api/electron-browser/mainThreadWebview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ class WebviewEditor extends BaseWebviewEditor {
220220
this.contextKey,
221221
this.findInputFocusContextKey,
222222
{
223-
enableWrappedPostMessage: true
224-
},
225-
false);
223+
enableWrappedPostMessage: true,
224+
useSameOriginForRoot: false
225+
});
226226

227227
this._webview.onDidClickLink(this.onDidClickLink, this, this._contentDisposables);
228228

src/vs/workbench/parts/extensions/browser/extensionEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export class ExtensionEditor extends BaseEditor {
421421
.then<void>(body => {
422422
const allowedBadgeProviders = this.extensionsWorkbenchService.allowedBadgeProviders;
423423
const webViewOptions = allowedBadgeProviders.length > 0 ? { allowScripts: false, allowSvgs: false, svgWhiteList: allowedBadgeProviders } : {};
424-
this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions, false);
424+
this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions);
425425
const removeLayoutParticipant = arrays.insert(this.layoutParticipants, this.activeWebview);
426426
this.contentDisposables.push(toDisposable(removeLayoutParticipant));
427427
this.activeWebview.contents = body;

src/vs/workbench/parts/html/browser/htmlPreviewPart.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ export class HtmlPreviewPart extends WebviewEditor {
9797
this._contextViewService,
9898
this.contextKey,
9999
this.findInputFocusContextKey,
100-
webviewOptions,
101-
true);
100+
{
101+
...webviewOptions,
102+
useSameOriginForRoot: true
103+
});
102104

103105
if (this.input && this.input instanceof HtmlInput) {
104106
const state = this.loadViewState(this.input.getResource());

src/vs/workbench/parts/html/browser/webview.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface WebviewOptions {
2424
readonly allowSvgs?: boolean;
2525
readonly svgWhiteList?: string[];
2626
readonly enableWrappedPostMessage?: boolean;
27+
readonly useSameOriginForRoot?: boolean;
2728
}
2829

2930
export class Webview {
@@ -44,8 +45,7 @@ export class Webview {
4445
private readonly _contextViewService: IContextViewService,
4546
private readonly _contextKey: IContextKey<boolean>,
4647
private readonly _findInputContextKey: IContextKey<boolean>,
47-
private _options: WebviewOptions,
48-
useSameOriginForRoot: boolean
48+
private _options: WebviewOptions
4949
) {
5050
this._webview = document.createElement('webview');
5151
this._webview.setAttribute('partition', this._options.allowSvgs ? 'webview' : `webview${Date.now()}`);
@@ -62,7 +62,7 @@ export class Webview {
6262
this._webview.style.outline = '0';
6363

6464
this._webview.preload = require.toUrl('./webview-pre.js');
65-
this._webview.src = useSameOriginForRoot ? require.toUrl('./webview.html') : 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E';
65+
this._webview.src = this._options.useSameOriginForRoot ? require.toUrl('./webview.html') : 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E';
6666

6767
this._ready = new Promise<this>(resolve => {
6868
const subscription = addDisposableListener(this._webview, 'ipc-message', (event) => {
@@ -76,7 +76,7 @@ export class Webview {
7676
});
7777
});
7878

79-
if (!useSameOriginForRoot) {
79+
if (!this._options.useSameOriginForRoot) {
8080
let loaded = false;
8181
this._disposables.push(addDisposableListener(this._webview, 'did-start-loading', () => {
8282
if (loaded) {

src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ export class ReleaseNotesEditor extends WebviewEditor {
9797
this._contextViewService,
9898
this.contextKey,
9999
this.findInputFocusContextKey,
100-
{},
101-
false);
100+
{});
102101

103102
if (this.input && this.input instanceof ReleaseNotesInput) {
104103
const state = this.loadViewState(this.input.version);

0 commit comments

Comments
 (0)